2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.onap.policy.brms.api;
23 import org.onap.policy.api.NotificationScheme;
24 import org.onap.policy.api.PolicyEngine;
25 import org.onap.policy.api.PolicyException;
26 import org.onap.policy.common.logging.flexlogger.FlexLogger;
27 import org.onap.policy.common.logging.flexlogger.Logger;
28 import org.onap.policy.xacml.api.XACMLErrorConstants;
31 * BRMSGateway: This application acts as the Gateway interface between the PDP XACML and PDP Drools.
32 * The listens for BRMS based policies and pushes them to the specified Policy Repository, from
33 * where the PDP Drools reads the Rule Jar.
39 private static final Logger logger = FlexLogger.getLogger(BrmsGateway.class);
40 private static final String CONFIGFILE = "config.properties";
42 private static PolicyEngine policyEngine = null;
44 private BrmsGateway() {
45 // Default private constructor
48 public static void main(final String[] args) throws Exception {
49 // Initialize Handler.
50 logger.info("Initializing BRMS Handler");
51 BrmsHandler brmsHandler = null;
53 brmsHandler = new BrmsHandler(CONFIGFILE);
54 } catch (final PolicyException e) {
55 logger.error("Check your property file: " + e.getMessage(), e);
59 // Set Handler with Auto Notification and initialize policyEngine
61 logger.info("Initializing policyEngine with Auto Notifications");
62 policyEngine = new PolicyEngine(CONFIGFILE, NotificationScheme.AUTO_ALL_NOTIFICATIONS, brmsHandler);
63 } catch (final Exception e) {
64 logger.error(XACMLErrorConstants.ERROR_UNKNOWN + "Error while Initializing Policy Engine " + e.getMessage(),
69 final Runnable runnable = () -> {
73 } catch (final InterruptedException e) {
74 logger.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR + "Thread Exception " + e.getMessage());
75 Thread.currentThread().interrupt();
79 final Thread thread = new Thread(runnable);
83 public static PolicyEngine getPolicyEngine() {