summaryrefslogtreecommitdiffstats
path: root/policy-management/src/main/java/org/openecomp
diff options
context:
space:
mode:
Diffstat (limited to 'policy-management/src/main/java/org/openecomp')
-rw-r--r--policy-management/src/main/java/org/openecomp/policy/drools/controller/internal/MavenDroolsController.java13
-rw-r--r--policy-management/src/main/java/org/openecomp/policy/drools/features/PolicyControllerFeatureAPI.java41
-rw-r--r--policy-management/src/main/java/org/openecomp/policy/drools/features/PolicyEngineFeatureAPI.java164
-rw-r--r--policy-management/src/main/java/org/openecomp/policy/drools/system/PolicyEngine.java297
-rw-r--r--policy-management/src/main/java/org/openecomp/policy/drools/system/internal/AggregatedPolicyController.java11
5 files changed, 447 insertions, 79 deletions
diff --git a/policy-management/src/main/java/org/openecomp/policy/drools/controller/internal/MavenDroolsController.java b/policy-management/src/main/java/org/openecomp/policy/drools/controller/internal/MavenDroolsController.java
index 2c5708d3..76bc5151 100644
--- a/policy-management/src/main/java/org/openecomp/policy/drools/controller/internal/MavenDroolsController.java
+++ b/policy-management/src/main/java/org/openecomp/policy/drools/controller/internal/MavenDroolsController.java
@@ -519,11 +519,13 @@ public class MavenDroolsController implements DroolsController {
this.getArtifactId(),
topic,
event);
+ } catch (UnsupportedOperationException uoe) {
+ if (logger.isInfoEnabled())
+ logger.info("DECODE:"+ this + ":" + topic + ":" + event);
+ return true;
} catch (Exception e) {
- logger.error(MessageCodes.EXCEPTION_ERROR, e,
- "DECODE:"+ this.getGroupId() + ":" +
- this.getArtifactId() + ":" + topic + ":" + event,
- this.toString());
+ e.printStackTrace();
+ logger.error("DECODE:"+ this + ":" + topic + ":" + event);
return true;
}
@@ -709,8 +711,7 @@ public class MavenDroolsController implements DroolsController {
builder.append("MavenDroolsController [policyContainer=")
.append((policyContainer != null) ? policyContainer.getName() : "NULL").append(":")
.append(", alive=")
- .append(alive).append(", locked=").append(locked).append(", decoderConfigurations=")
- .append(decoderConfigurations).append(", encoderConfigurations=").append(encoderConfigurations)
+ .append(alive).append(", locked=")
.append(", modelClassLoaderHash=").append(modelClassLoaderHash).append("]");
return builder.toString();
}
diff --git a/policy-management/src/main/java/org/openecomp/policy/drools/features/PolicyControllerFeatureAPI.java b/policy-management/src/main/java/org/openecomp/policy/drools/features/PolicyControllerFeatureAPI.java
new file mode 100644
index 00000000..3418d067
--- /dev/null
+++ b/policy-management/src/main/java/org/openecomp/policy/drools/features/PolicyControllerFeatureAPI.java
@@ -0,0 +1,41 @@
+package org.openecomp.policy.drools.features;
+
+import java.util.Properties;
+
+import org.openecomp.policy.drools.system.PolicyController;
+import org.openecomp.policy.drools.utils.OrderedService;
+import org.openecomp.policy.drools.utils.OrderedServiceImpl;
+
+public interface PolicyControllerFeatureAPI extends OrderedService {
+
+ /**
+ * called before creating a controller with name 'name' and
+ * properties 'properties'
+ *
+ * @param name name of the the controller
+ * @param properties configuration properties
+ *
+ * @return a policy controller. A take over of the creation operation
+ * is performed by returning a non-null policy controller.
+ * 'null' indicates that no take over has taken place, and processing should
+ * continue to the next feature provider.
+ */
+ public PolicyController beforeCreate(String name, Properties properties);
+
+ /**
+ * called after creating a controller with name 'name'
+ *
+ * @param controller controller
+ *
+ * @return true if this feature intercepts and takes ownership
+ * of the operation preventing the invocation of
+ * lower priority features. False, otherwise.
+ */
+ public boolean afterCreate(PolicyController controller);
+
+ /**
+ * Feature providers implementing this interface
+ */
+ public static final OrderedServiceImpl<PolicyControllerFeatureAPI> providers =
+ new OrderedServiceImpl<PolicyControllerFeatureAPI>(PolicyControllerFeatureAPI.class);
+}
diff --git a/policy-management/src/main/java/org/openecomp/policy/drools/features/PolicyEngineFeatureAPI.java b/policy-management/src/main/java/org/openecomp/policy/drools/features/PolicyEngineFeatureAPI.java
new file mode 100644
index 00000000..c8298dde
--- /dev/null
+++ b/policy-management/src/main/java/org/openecomp/policy/drools/features/PolicyEngineFeatureAPI.java
@@ -0,0 +1,164 @@
+package org.openecomp.policy.drools.features;
+
+import java.util.Properties;
+
+import org.openecomp.policy.drools.system.PolicyEngine;
+import org.openecomp.policy.drools.utils.OrderedService;
+import org.openecomp.policy.drools.utils.OrderedServiceImpl;
+
+/**
+ * Policy Engine Feature API.
+ * Provides Interception Points during the Policy Engine lifecycle.
+ */
+public interface PolicyEngineFeatureAPI extends OrderedService {
+
+ /**
+ * intercept before the Policy Engine is configured.
+ *
+ * @return true if this feature intercepts and takes ownership
+ * of the operation preventing the invocation of
+ * lower priority features. False, otherwise.
+ */
+ public boolean beforeConfigure(PolicyEngine engine, Properties properties);
+
+ /**
+ * intercept after the Policy Engine is configured.
+ *
+ * @return true if this feature intercepts and takes ownership
+ * of the operation preventing the invocation of
+ * lower priority features. False, otherwise.
+ */
+ public boolean afterConfigure(PolicyEngine engine);
+
+ /**
+ * intercept before the Policy Engine goes active.
+ *
+ * @return true if this feature intercepts and takes ownership
+ * of the operation preventing the invocation of
+ * lower priority features. False, otherwise.
+ */
+ public boolean beforeActivate(PolicyEngine engine);
+
+ /**
+ * intercept after the Policy Engine goes active.
+ *
+ * @return true if this feature intercepts and takes ownership
+ * of the operation preventing the invocation of
+ * lower priority features. False, otherwise.
+ */
+ public boolean afterActivate(PolicyEngine engine);
+
+ /**
+ * intercept before the Policy Engine goes standby.
+ *
+ * @return true if this feature intercepts and takes ownership
+ * of the operation preventing the invocation of
+ * lower priority features. False, otherwise.
+ */
+ public boolean beforeDeactivate(PolicyEngine engine);
+
+ /**
+ * intercept after the Policy Engine goes standby.
+ *
+ * @return true if this feature intercepts and takes ownership
+ * of the operation preventing the invocation of
+ * lower priority features. False, otherwise.
+ */
+ public boolean afterDeactivate(PolicyEngine engine);
+
+ /**
+ * intercept before the Policy Engine is started.
+ *
+ * @return true if this feature intercepts and takes ownership
+ * of the operation preventing the invocation of
+ * lower priority features. False, otherwise.
+ */
+ public boolean beforeStart(PolicyEngine engine);
+
+ /**
+ * intercept after the Policy Engine is started.
+ *
+ * @return true if this feature intercepts and takes ownership
+ * of the operation preventing the invocation of
+ * lower priority features. False, otherwise.
+ */
+ public boolean afterStart(PolicyEngine engine);
+
+ /**
+ * intercept before the Policy Engine is stopped.
+ *
+ * @return true if this feature intercepts and takes ownership
+ * of the operation preventing the invocation of
+ * lower priority features. False, otherwise..
+ */
+ public boolean beforeStop(PolicyEngine engine);
+
+ /**
+ * intercept after the Policy Engine is stopped
+ *
+ * @return true if this feature intercepts and takes ownership
+ * of the operation preventing the invocation of
+ * lower priority features. False, otherwise.d.
+ */
+ public boolean afterStop(PolicyEngine engine);
+
+ /**
+ * intercept before the Policy Engine is locked
+ *
+ * @return true if this feature intercepts and takes ownership
+ * of the operation preventing the invocation of
+ * lower priority features. False, otherwise.
+ */
+ public boolean beforeLock(PolicyEngine engine);
+
+ /**
+ * intercept after the Policy Engine is locked
+ *
+ * @return true if this feature intercepts and takes ownership
+ * of the operation preventing the invocation of
+ * lower priority features. False, otherwise..
+ */
+ public boolean afterLock(PolicyEngine engine);
+
+ /**
+ * intercept before the Policy Engine is locked
+ *
+ * @return true if this feature intercepts and takes ownership
+ * of the operation preventing the invocation of
+ * lower priority features. False, otherwise.
+ */
+ public boolean beforeUnlock(PolicyEngine engine);
+
+ /**
+ * intercept after the Policy Engine is locked
+ *
+ * @return true if this feature intercepts and takes ownership
+ * of the operation preventing the invocation of
+ * lower priority features. False, otherwise.
+ */
+ public boolean afterUnlock(PolicyEngine engine);
+
+ /**
+ * intercept the Policy Engine is shut down
+ *
+ * @return true if this feature intercepts and takes ownership
+ * of the operation preventing the invocation of
+ * lower priority features. False, otherwise..
+ */
+ public boolean beforeShutdown(PolicyEngine engine);
+
+ /**
+ * called after the Policy Engine is shut down
+ *
+ * @return true if this feature intercepts and takes ownership
+ * of the operation preventing the invocation of
+ * lower priority features. False, otherwise.
+ */
+ public boolean afterShutdown(PolicyEngine engine);
+
+ /**
+ * Feature providers implementing this interface
+ */
+ public static final OrderedServiceImpl<PolicyEngineFeatureAPI> providers =
+ new OrderedServiceImpl<PolicyEngineFeatureAPI>(PolicyEngineFeatureAPI.class);
+}
diff --git a/policy-management/src/main/java/org/openecomp/policy/drools/system/PolicyEngine.java b/policy-management/src/main/java/org/openecomp/policy/drools/system/PolicyEngine.java
index 33f2a098..6933003e 100644
--- a/policy-management/src/main/java/org/openecomp/policy/drools/system/PolicyEngine.java
+++ b/policy-management/src/main/java/org/openecomp/policy/drools/system/PolicyEngine.java
@@ -28,7 +28,6 @@ import org.openecomp.policy.common.logging.eelf.MessageCodes;
import org.openecomp.policy.common.logging.flexlogger.FlexLogger;
import org.openecomp.policy.common.logging.flexlogger.Logger;
import org.openecomp.policy.drools.controller.DroolsController;
-import org.openecomp.policy.drools.core.FeatureAPI;
import org.openecomp.policy.drools.core.jmx.PdpJmxListener;
import org.openecomp.policy.drools.event.comm.Topic;
import org.openecomp.policy.drools.event.comm.Topic.CommInfrastructure;
@@ -36,6 +35,8 @@ import org.openecomp.policy.drools.event.comm.TopicEndpoint;
import org.openecomp.policy.drools.event.comm.TopicListener;
import org.openecomp.policy.drools.event.comm.TopicSink;
import org.openecomp.policy.drools.event.comm.TopicSource;
+import org.openecomp.policy.drools.features.PolicyControllerFeatureAPI;
+import org.openecomp.policy.drools.features.PolicyEngineFeatureAPI;
import org.openecomp.policy.drools.http.server.HttpServletServer;
import org.openecomp.policy.drools.persistence.SystemPersistence;
import org.openecomp.policy.drools.properties.Lockable;
@@ -329,19 +330,33 @@ class PolicyEngineManager implements PolicyEngine {
*/
protected List<HttpServletServer> httpServers = new ArrayList<HttpServletServer>();
+ /**
+ * gson parser to decode configuration requests
+ */
protected Gson decoder = new GsonBuilder().disableHtmlEscaping().create();
-
+
/**
* {@inheritDoc}
*/
@Override
- public void configure(Properties properties) throws IllegalArgumentException {
+ public synchronized void configure(Properties properties) throws IllegalArgumentException {
if (properties == null) {
logger.warn("No properties provided");
throw new IllegalArgumentException("No properties provided");
}
+ /* policy-engine dispatch pre configure hook */
+ for (PolicyEngineFeatureAPI feature : PolicyEngineFeatureAPI.providers.getList()) {
+ try {
+ if (feature.beforeConfigure(this, properties))
+ return;
+ } catch (Exception e) {
+ System.out.println("ERROR: Feature API: " + feature.getClass().getName() + e.getMessage());
+ e.printStackTrace();
+ }
+ }
+
this.properties = properties;
try {
@@ -365,6 +380,17 @@ class PolicyEngineManager implements PolicyEngine {
logger.error(MessageCodes.EXCEPTION_ERROR, e, "PolicyEngine", "configure");
}
+ /* policy-engine dispatch post configure hook */
+ for (PolicyEngineFeatureAPI feature : PolicyEngineFeatureAPI.providers.getList()) {
+ try {
+ if (feature.afterConfigure(this))
+ return;
+ } catch (Exception e) {
+ System.out.println("ERROR: Feature API: " + feature.getClass().getName() + e.getMessage());
+ e.printStackTrace();
+ }
+ }
+
return;
}
@@ -372,7 +398,7 @@ class PolicyEngineManager implements PolicyEngine {
* {@inheritDoc}
*/
@Override
- public PolicyController createPolicyController(String name, Properties properties)
+ public synchronized PolicyController createPolicyController(String name, Properties properties)
throws IllegalArgumentException, IllegalStateException {
// check if a PROPERTY_CONTROLLER_NAME property is present
@@ -388,19 +414,31 @@ class PolicyEngineManager implements PolicyEngine {
name = propertyControllerName;
}
- // feature hook
- for (FeatureAPI feature : FeatureAPI.impl.getList()) {
- feature.beforeCreateController(name, properties);
+ PolicyController controller;
+ for (PolicyControllerFeatureAPI controllerFeature : PolicyControllerFeatureAPI.providers.getList()) {
+ try {
+ controller = controllerFeature.beforeCreate(name, properties);
+ if (controller != null)
+ return controller;
+ } catch (Exception e) {
+ System.out.println("ERROR: Feature API: " + controllerFeature.getClass().getName() + e.getMessage());
+ e.printStackTrace();
+ }
}
- PolicyController controller = PolicyController.factory.build(name, properties);
+ controller = PolicyController.factory.build(name, properties);
if (this.isLocked())
controller.lock();
// feature hook
- for (FeatureAPI feature : FeatureAPI.impl.getList()) {
- // NOTE: this should change to the actual controller object
- feature.afterCreateController(name);
+ for (PolicyControllerFeatureAPI controllerFeature : PolicyControllerFeatureAPI.providers.getList()) {
+ try {
+ if (controllerFeature.afterCreate(controller))
+ return controller;
+ } catch (Exception e) {
+ System.out.println("ERROR: Feature API: " + controllerFeature.getClass().getName() + e.getMessage());
+ e.printStackTrace();
+ }
}
return controller;
@@ -573,22 +611,24 @@ class PolicyEngineManager implements PolicyEngine {
* {@inheritDoc}
*/
@Override
- public boolean start() throws IllegalStateException {
-
- if (this.locked) {
- throw new IllegalStateException("Engine is locked");
- }
-
- // Features hook
- for (FeatureAPI feature : FeatureAPI.impl.getList()) {
- feature.beforeStartEngine();
- }
+ public synchronized boolean start() throws IllegalStateException {
- synchronized(this) {
- this.alive = true;
+ /* policy-engine dispatch pre start hook */
+ for (PolicyEngineFeatureAPI feature : PolicyEngineFeatureAPI.providers.getList()) {
+ try {
+ if (feature.beforeStart(this))
+ return true;
+ } catch (Exception e) {
+ System.out.println("ERROR: Feature API: " + feature.getClass().getName() + e.getMessage());
+ e.printStackTrace();
+ }
}
-
+
boolean success = true;
+ if (this.locked)
+ throw new IllegalStateException("Engine is locked");
+
+ this.alive = true;
/* Start Policy Engine exclusively-owned (unmanaged) http servers */
@@ -600,6 +640,7 @@ class PolicyEngineManager implements PolicyEngine {
logger.error(MessageCodes.EXCEPTION_ERROR, e, httpServer.toString(), this.toString());
}
}
+
/* Start Policy Engine exclusively-owned (unmanaged) sources */
for (TopicSource source: this.sources) {
@@ -650,9 +691,15 @@ class PolicyEngineManager implements PolicyEngine {
PdpJmxListener.start();
- // Features hook
- for (FeatureAPI feature : FeatureAPI.impl.getList()) {
- feature.afterStartEngine();
+ /* policy-engine dispatch after start hook */
+ for (PolicyEngineFeatureAPI feature : PolicyEngineFeatureAPI.providers.getList()) {
+ try {
+ if (feature.afterStart(this))
+ return success;
+ } catch (Exception e) {
+ System.out.println("ERROR: Feature API: " + feature.getClass().getName() + e.getMessage());
+ e.printStackTrace();
+ }
}
return success;
@@ -662,18 +709,27 @@ class PolicyEngineManager implements PolicyEngine {
* {@inheritDoc}
*/
@Override
- public boolean stop() {
-
- /* stop regardless of the lock state */
+ public synchronized boolean stop() {
- synchronized(this) {
- if (!this.alive)
- return true;
-
- this.alive = false;
+ /* policy-engine dispatch pre stop hook */
+ for (PolicyEngineFeatureAPI feature : PolicyEngineFeatureAPI.providers.getList()) {
+ try {
+ if (feature.beforeStop(this))
+ return true;
+ } catch (Exception e) {
+ System.out.println("ERROR: Feature API: " + feature.getClass().getName() + e.getMessage());
+ e.printStackTrace();
+ }
}
+ /* stop regardless of the lock state */
+
boolean success = true;
+ if (!this.alive)
+ return true;
+
+ this.alive = false;
+
List<PolicyController> controllers = PolicyController.factory.inventory();
for (PolicyController controller : controllers) {
try {
@@ -719,6 +775,17 @@ class PolicyEngineManager implements PolicyEngine {
}
}
+ /* policy-engine dispatch pre stop hook */
+ for (PolicyEngineFeatureAPI feature : PolicyEngineFeatureAPI.providers.getList()) {
+ try {
+ if (feature.afterStop(this))
+ return success;
+ } catch (Exception e) {
+ System.out.println("ERROR: Feature API: " + feature.getClass().getName() + e.getMessage());
+ e.printStackTrace();
+ }
+ }
+
return success;
}
@@ -726,17 +793,21 @@ class PolicyEngineManager implements PolicyEngine {
* {@inheritDoc}
*/
@Override
- public void shutdown() throws IllegalStateException {
-
- synchronized(this) {
- this.alive = false;
- }
+ public synchronized void shutdown() throws IllegalStateException {
- // feature hook reporting that the Policy Engine is being shut down
- for (FeatureAPI feature : FeatureAPI.impl.getList()) {
- feature.beforeShutdownEngine();
+ /* policy-engine dispatch pre shutdown hook */
+ for (PolicyEngineFeatureAPI feature : PolicyEngineFeatureAPI.providers.getList()) {
+ try {
+ if (feature.beforeShutdown(this))
+ return;
+ } catch (Exception e) {
+ System.out.println("ERROR: Feature API: " + feature.getClass().getName() + e.getMessage());
+ e.printStackTrace();
+ }
}
-
+
+ this.alive = false;
+
/* Shutdown Policy Engine owned (unmanaged) sources */
for (TopicSource source: this.sources) {
try {
@@ -764,10 +835,17 @@ class PolicyEngineManager implements PolicyEngine {
PdpJmxListener.stop();
- // feature hook reporting that the Policy Engine has being shut down
- for (FeatureAPI feature : FeatureAPI.impl.getList()) {
- feature.afterShutdownEngine();
+ /* policy-engine dispatch post shutdown hook */
+ for (PolicyEngineFeatureAPI feature : PolicyEngineFeatureAPI.providers.getList()) {
+ try {
+ if (feature.afterShutdown(this))
+ return;
+ } catch (Exception e) {
+ System.out.println("ERROR: Feature API: " + feature.getClass().getName() + e.getMessage());
+ e.printStackTrace();
+ }
}
+
new Thread(new Runnable() {
@Override
@@ -802,7 +880,7 @@ class PolicyEngineManager implements PolicyEngine {
* {@inheritDoc}
*/
@Override
- public boolean isAlive() {
+ public synchronized boolean isAlive() {
return this.alive;
}
@@ -810,15 +888,24 @@ class PolicyEngineManager implements PolicyEngine {
* {@inheritDoc}
*/
@Override
- public boolean lock() {
+ public synchronized boolean lock() {
- synchronized(this) {
- if (this.locked)
- return true;
-
- this.locked = true;
+ /* policy-engine dispatch pre lock hook */
+ for (PolicyEngineFeatureAPI feature : PolicyEngineFeatureAPI.providers.getList()) {
+ try {
+ if (feature.beforeLock(this))
+ return true;
+ } catch (Exception e) {
+ System.out.println("ERROR: Feature API: " + feature.getClass().getName() + e.getMessage());
+ e.printStackTrace();
+ }
}
+ if (this.locked)
+ return true;
+
+ this.locked = true;
+
boolean success = true;
List<PolicyController> controllers = PolicyController.factory.inventory();
for (PolicyController controller : controllers) {
@@ -830,7 +917,19 @@ class PolicyEngineManager implements PolicyEngine {
}
}
- success = TopicEndpoint.manager.lock();
+ success = TopicEndpoint.manager.lock() && success;
+
+ /* policy-engine dispatch post lock hook */
+ for (PolicyEngineFeatureAPI feature : PolicyEngineFeatureAPI.providers.getList()) {
+ try {
+ if (feature.afterLock(this))
+ return success;
+ } catch (Exception e) {
+ System.out.println("ERROR: Feature API: " + feature.getClass().getName() + e.getMessage());
+ e.printStackTrace();
+ }
+ }
+
return success;
}
@@ -838,14 +937,24 @@ class PolicyEngineManager implements PolicyEngine {
* {@inheritDoc}
*/
@Override
- public boolean unlock() {
- synchronized(this) {
- if (!this.locked)
- return true;
-
- this.locked = false;
+ public synchronized boolean unlock() {
+
+ /* policy-engine dispatch pre unlock hook */
+ for (PolicyEngineFeatureAPI feature : PolicyEngineFeatureAPI.providers.getList()) {
+ try {
+ if (feature.beforeUnlock(this))
+ return true;
+ } catch (Exception e) {
+ System.out.println("ERROR: Feature API: " + feature.getClass().getName() + e.getMessage());
+ e.printStackTrace();
+ }
}
+ if (!this.locked)
+ return true;
+
+ this.locked = false;
+
boolean success = true;
List<PolicyController> controllers = PolicyController.factory.inventory();
for (PolicyController controller : controllers) {
@@ -857,7 +966,19 @@ class PolicyEngineManager implements PolicyEngine {
}
}
- success = TopicEndpoint.manager.unlock();
+ success = TopicEndpoint.manager.unlock() && success;
+
+ /* policy-engine dispatch after unlock hook */
+ for (PolicyEngineFeatureAPI feature : PolicyEngineFeatureAPI.providers.getList()) {
+ try {
+ if (feature.afterUnlock(this))
+ return success;
+ } catch (Exception e) {
+ System.out.println("ERROR: Feature API: " + feature.getClass().getName() + e.getMessage());
+ e.printStackTrace();
+ }
+ }
+
return success;
}
@@ -865,7 +986,7 @@ class PolicyEngineManager implements PolicyEngine {
* {@inheritDoc}
*/
@Override
- public boolean isLocked() {
+ public synchronized boolean isLocked() {
return this.locked;
}
@@ -945,7 +1066,7 @@ class PolicyEngineManager implements PolicyEngine {
* {@inheritDoc}
*/
@Override
- public boolean onTopicEvent(CommInfrastructure commType, String topic, String event) {
+ public void onTopicEvent(CommInfrastructure commType, String topic, String event) {
/* configuration request */
try {
PdpdConfiguration configuration = this.decoder.fromJson(event, PdpdConfiguration.class);
@@ -953,8 +1074,6 @@ class PolicyEngineManager implements PolicyEngine {
} catch (Exception e) {
logger.error(MessageCodes.EXCEPTION_ERROR, e, "CONFIGURATION ERROR IN PDP-D POLICY ENGINE: "+ event + ":" + e.getMessage() + ":" + this);
}
-
- return true;
}
/**
@@ -1131,6 +1250,17 @@ class PolicyEngineManager implements PolicyEngine {
*/
@Override
public synchronized void activate() {
+
+ /* policy-engine dispatch pre activate hook */
+ for (PolicyEngineFeatureAPI feature : PolicyEngineFeatureAPI.providers.getList()) {
+ try {
+ if (feature.beforeActivate(this))
+ return;
+ } catch (Exception e) {
+ System.out.println("ERROR: Feature API: " + feature.getClass().getName() + e.getMessage());
+ e.printStackTrace();
+ }
+ }
// activate 'policy-management'
for (PolicyController policyController : getPolicyControllers()) {
@@ -1147,6 +1277,17 @@ class PolicyEngineManager implements PolicyEngine {
}
this.unlock();
+
+ /* policy-engine dispatch post activate hook */
+ for (PolicyEngineFeatureAPI feature : PolicyEngineFeatureAPI.providers.getList()) {
+ try {
+ if (feature.afterActivate(this))
+ return;
+ } catch (Exception e) {
+ System.out.println("ERROR: Feature API: " + feature.getClass().getName() + e.getMessage());
+ e.printStackTrace();
+ }
+ }
}
/**
@@ -1155,6 +1296,17 @@ class PolicyEngineManager implements PolicyEngine {
@Override
public synchronized void deactivate() {
+ /* policy-engine dispatch pre deactivate hook */
+ for (PolicyEngineFeatureAPI feature : PolicyEngineFeatureAPI.providers.getList()) {
+ try {
+ if (feature.beforeDeactivate(this))
+ return;
+ } catch (Exception e) {
+ System.out.println("ERROR: Feature API: " + feature.getClass().getName() + e.getMessage());
+ e.printStackTrace();
+ }
+ }
+
this.lock();
for (PolicyController policyController : getPolicyControllers()) {
@@ -1167,7 +1319,18 @@ class PolicyEngineManager implements PolicyEngine {
logger.error(MessageCodes.EXCEPTION_ERROR, e, "PolicyEngine.deactivate: cannot start " +
policyController + " because of " + e.getMessage());
}
- }
+ }
+
+ /* policy-engine dispatch post deactivate hook */
+ for (PolicyEngineFeatureAPI feature : PolicyEngineFeatureAPI.providers.getList()) {
+ try {
+ if (feature.afterDeactivate(this))
+ return;
+ } catch (Exception e) {
+ System.out.println("ERROR: Feature API: " + feature.getClass().getName() + e.getMessage());
+ e.printStackTrace();
+ }
+ }
}
@Override
diff --git a/policy-management/src/main/java/org/openecomp/policy/drools/system/internal/AggregatedPolicyController.java b/policy-management/src/main/java/org/openecomp/policy/drools/system/internal/AggregatedPolicyController.java
index 96f9e5bf..3badbd08 100644
--- a/policy-management/src/main/java/org/openecomp/policy/drools/system/internal/AggregatedPolicyController.java
+++ b/policy-management/src/main/java/org/openecomp/policy/drools/system/internal/AggregatedPolicyController.java
@@ -317,18 +317,18 @@ public class AggregatedPolicyController implements PolicyController,
* {@inheritDoc}
*/
@Override
- public boolean onTopicEvent(Topic.CommInfrastructure commType,
+ public void onTopicEvent(Topic.CommInfrastructure commType,
String topic, String event) {
logger.info("EVENT NOTIFICATION: " + commType + ":" + topic + ":" + event + " INTO " + this);
if (this.locked)
- return false;
+ return;
if (!this.alive)
- return true;
+ return;
- return this.droolsController.offer(topic, event);
+ this.droolsController.offer(topic, event);
}
/**
@@ -444,8 +444,7 @@ public class AggregatedPolicyController implements PolicyController,
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
- builder.append("AggregatedPolicyController [name=").append(name).append(", sources=").append(sources)
- .append(", sinks=").append(sinks).append(", alive=").append(alive).append(", locked=").append(locked)
+ builder.append("AggregatedPolicyController [name=").append(name).append(", alive=").append(alive).append(", locked=").append(locked)
.append(", droolsController=").append(droolsController).append("]");
return builder.toString();
}