summaryrefslogtreecommitdiffstats
path: root/policy-management/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'policy-management/src/main')
-rw-r--r--policy-management/src/main/java/org/onap/policy/drools/controller/IndexedDroolsControllerFactory.java47
-rw-r--r--policy-management/src/main/java/org/onap/policy/drools/system/Main.java4
2 files changed, 30 insertions, 21 deletions
diff --git a/policy-management/src/main/java/org/onap/policy/drools/controller/IndexedDroolsControllerFactory.java b/policy-management/src/main/java/org/onap/policy/drools/controller/IndexedDroolsControllerFactory.java
index e8234a46..d2196680 100644
--- a/policy-management/src/main/java/org/onap/policy/drools/controller/IndexedDroolsControllerFactory.java
+++ b/policy-management/src/main/java/org/onap/policy/drools/controller/IndexedDroolsControllerFactory.java
@@ -31,6 +31,7 @@ import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
import org.onap.policy.common.endpoints.event.comm.TopicSink;
import org.onap.policy.common.endpoints.event.comm.TopicSource;
import org.onap.policy.common.endpoints.properties.PolicyEndPointProperties;
+import org.onap.policy.common.utils.services.FeatureApiUtils;
import org.onap.policy.drools.controller.internal.MavenDroolsController;
import org.onap.policy.drools.controller.internal.NullDroolsController;
import org.onap.policy.drools.features.DroolsControllerFeatureApi;
@@ -152,24 +153,8 @@ class IndexedDroolsControllerFactory implements DroolsControllerFactory {
/* new drools controller */
- DroolsController controller = null;
- for (DroolsControllerFeatureApi feature: getProviders()) {
- try {
- controller = feature.beforeInstance(properties,
- newGroupId, newArtifactId, newVersion,
+ DroolsController controller = applyBeforeInstance(properties, newGroupId, newArtifactId, newVersion,
decoderConfigurations, encoderConfigurations);
- if (controller != null) {
- logger.info("feature {} ({}) beforeInstance() has intercepted drools controller {}:{}:{}",
- feature.getName(), feature.getSequenceNumber(),
- newGroupId, newArtifactId, newVersion);
- break;
- }
- } catch (RuntimeException r) {
- logger.error("feature {} ({}) beforeInstance() of drools controller {}:{}:{} failed",
- feature.getName(), feature.getSequenceNumber(),
- newGroupId, newArtifactId, newVersion, r);
- }
- }
if (controller == null) {
controller = new MavenDroolsController(newGroupId, newArtifactId, newVersion, decoderConfigurations,
@@ -180,16 +165,38 @@ class IndexedDroolsControllerFactory implements DroolsControllerFactory {
droolsControllers.put(controllerId, controller);
}
+ final DroolsController controllerFinal = controller;
+
+ FeatureApiUtils.apply(getProviders(),
+ feature -> feature.afterInstance(controllerFinal, properties),
+ (feature, ex) -> logger.error("feature {} ({}) afterInstance() of drools controller {}:{}:{} failed",
+ feature.getName(), feature.getSequenceNumber(),
+ newGroupId, newArtifactId, newVersion, ex));
+
+ return controller;
+ }
+
+ private DroolsController applyBeforeInstance(Properties properties, String newGroupId, String newArtifactId,
+ String newVersion, List<TopicCoderFilterConfiguration> decoderConfigurations,
+ List<TopicCoderFilterConfiguration> encoderConfigurations) {
+ DroolsController controller = null;
for (DroolsControllerFeatureApi feature: getProviders()) {
try {
- feature.afterInstance(controller, properties);
+ controller = feature.beforeInstance(properties,
+ newGroupId, newArtifactId, newVersion,
+ decoderConfigurations, encoderConfigurations);
+ if (controller != null) {
+ logger.info("feature {} ({}) beforeInstance() has intercepted drools controller {}:{}:{}",
+ feature.getName(), feature.getSequenceNumber(),
+ newGroupId, newArtifactId, newVersion);
+ break;
+ }
} catch (RuntimeException r) {
- logger.error("feature {} ({}) afterInstance() of drools controller {}:{}:{} failed",
+ logger.error("feature {} ({}) beforeInstance() of drools controller {}:{}:{} failed",
feature.getName(), feature.getSequenceNumber(),
newGroupId, newArtifactId, newVersion, r);
}
}
-
return controller;
}
diff --git a/policy-management/src/main/java/org/onap/policy/drools/system/Main.java b/policy-management/src/main/java/org/onap/policy/drools/system/Main.java
index 9e6d0432..be0cb820 100644
--- a/policy-management/src/main/java/org/onap/policy/drools/system/Main.java
+++ b/policy-management/src/main/java/org/onap/policy/drools/system/Main.java
@@ -106,7 +106,9 @@ public class Main {
/* 5. Open the engine for dynamic configuration */
PolicyEngineConstants.getManager().open();
- logger.info(String.format(MessageConstants.START_SUCCESS_MSG, MessageConstants.POLICY_DROOLS_PDP));
+ if (logger.isInfoEnabled()) {
+ logger.info(String.format(MessageConstants.START_SUCCESS_MSG, MessageConstants.POLICY_DROOLS_PDP));
+ }
}
private static void setSystemProperties() {