diff options
Diffstat (limited to 'policy-management/src/main/java/org/openecomp/policy/drools/system')
4 files changed, 132 insertions, 13 deletions
diff --git a/policy-management/src/main/java/org/openecomp/policy/drools/system/PolicyController.java b/policy-management/src/main/java/org/openecomp/policy/drools/system/PolicyController.java index 543fd0e3..15d1acf3 100644 --- a/policy-management/src/main/java/org/openecomp/policy/drools/system/PolicyController.java +++ b/policy-management/src/main/java/org/openecomp/policy/drools/system/PolicyController.java @@ -69,9 +69,9 @@ public interface PolicyController extends Startable, Lockable { public boolean updateDrools(DroolsConfiguration newDroolsConfiguration); /** - * Get the Initialization Properties + * Get the Properties */ - public Properties getInitializationProperties(); + public Properties getProperties(); /** * Attempts delivering of an String over communication diff --git a/policy-management/src/main/java/org/openecomp/policy/drools/system/PolicyControllerFactory.java b/policy-management/src/main/java/org/openecomp/policy/drools/system/PolicyControllerFactory.java index e105bbb9..c6020ea6 100644 --- a/policy-management/src/main/java/org/openecomp/policy/drools/system/PolicyControllerFactory.java +++ b/policy-management/src/main/java/org/openecomp/policy/drools/system/PolicyControllerFactory.java @@ -25,12 +25,15 @@ import java.util.HashMap; import java.util.List; import java.util.Properties; -import org.openecomp.policy.drools.controller.DroolsController; 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.features.PolicyControllerFeatureAPI; import org.openecomp.policy.drools.protocol.configuration.DroolsConfiguration; import org.openecomp.policy.drools.system.internal.AggregatedPolicyController; +import com.fasterxml.jackson.annotation.JsonIgnore; + /** * Policy Controller Factory to manage controller creation, destruction, * and retrieval for management interfaces @@ -150,6 +153,25 @@ public interface PolicyControllerFactory { throws IllegalArgumentException, IllegalStateException; /** + * get features attached to the Policy Controllers + * @return list of features + */ + public List<PolicyControllerFeatureAPI> getFeatureProviders(); + + /** + * get named feature attached to the Policy Controllers + * @return the feature + */ + public PolicyControllerFeatureAPI getFeatureProvider(String featureName) + throws IllegalArgumentException; + + /** + * get features attached to the Policy Controllers + * @return list of features + */ + public List<String> getFeatures(); + + /** * returns the current inventory of Policy Controllers * * @return a list of Policy Controllers @@ -461,4 +483,40 @@ class IndexedPolicyControllerFactory implements PolicyControllerFactory { return controllers; } + /** + * {@inheritDoc} + */ + @Override + public List<String> getFeatures() { + List<String> features = new ArrayList<String>(); + for (PolicyControllerFeatureAPI feature : PolicyControllerFeatureAPI.providers.getList()) { + features.add(feature.getName()); + } + return features; + } + + /** + * {@inheritDoc} + */ + @JsonIgnore + @Override + public List<PolicyControllerFeatureAPI> getFeatureProviders() { + return PolicyControllerFeatureAPI.providers.getList(); + } + + /** + * {@inheritDoc} + */ + @Override + public PolicyControllerFeatureAPI getFeatureProvider(String featureName) throws IllegalArgumentException { + if (featureName == null || featureName.isEmpty()) + throw new IllegalArgumentException("A feature name must be provided"); + + for (PolicyControllerFeatureAPI feature : PolicyControllerFeatureAPI.providers.getList()) { + if (feature.getName().equals(featureName)) + return feature; + } + + throw new IllegalArgumentException("Invalid Feature Name: " + featureName); + } } 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 6933003e..d2133374 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 @@ -190,6 +190,25 @@ public interface PolicyEngine extends Startable, Lockable, TopicListener { public Properties getProperties(); /** + * get features attached to the Policy Engine + * @return list of features + */ + public List<PolicyEngineFeatureAPI> getFeatureProviders(); + + /** + * get named feature attached to the Policy Engine + * @return the feature + */ + public PolicyEngineFeatureAPI getFeatureProvider(String featureName) + throws IllegalArgumentException; + + /** + * get features attached to the Policy Engine + * @return list of features + */ + public List<String> getFeatures(); + + /** * Attempts the dispatching of an "event" object * * @param topic topic @@ -1031,6 +1050,7 @@ class PolicyEngineManager implements PolicyEngine { * {@inheritDoc} */ @Override + @JsonIgnore public Properties getProperties() { return this.properties; } @@ -1062,6 +1082,44 @@ class PolicyEngineManager implements PolicyEngine { return this.httpServers; } + + /** + * {@inheritDoc} + */ + @Override + public List<String> getFeatures() { + List<String> features = new ArrayList<String>(); + for (PolicyEngineFeatureAPI feature : PolicyEngineFeatureAPI.providers.getList()) { + features.add(feature.getName()); + } + return features; + } + + /** + * {@inheritDoc} + */ + @JsonIgnore + @Override + public List<PolicyEngineFeatureAPI> getFeatureProviders() { + return PolicyEngineFeatureAPI.providers.getList(); + } + + /** + * {@inheritDoc} + */ + @Override + public PolicyEngineFeatureAPI getFeatureProvider(String featureName) throws IllegalArgumentException { + if (featureName == null || featureName.isEmpty()) + throw new IllegalArgumentException("A feature name must be provided"); + + for (PolicyEngineFeatureAPI feature : PolicyEngineFeatureAPI.providers.getList()) { + if (feature.getName().equals(featureName)) + return feature; + } + + throw new IllegalArgumentException("Invalid Feature Name: " + featureName); + } + /** * {@inheritDoc} */ 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 3badbd08..e41a8898 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 @@ -24,18 +24,19 @@ import java.util.HashMap; import java.util.List; import java.util.Properties; +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.event.comm.Topic; 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.common.logging.flexlogger.FlexLogger; -import org.openecomp.policy.common.logging.flexlogger.Logger; import org.openecomp.policy.drools.persistence.SystemPersistence; import org.openecomp.policy.drools.properties.PolicyProperties; import org.openecomp.policy.drools.protocol.configuration.DroolsConfiguration; import org.openecomp.policy.drools.system.PolicyController; + import com.fasterxml.jackson.annotation.JsonIgnore; /** @@ -440,6 +441,16 @@ public class AggregatedPolicyController implements PolicyController, public DroolsController getDrools() { return this.droolsController; } + + + /** + * {@inheritDoc} + */ + @Override + @JsonIgnore + public Properties getProperties() { + return this.properties; + } @Override public String toString() { @@ -449,13 +460,5 @@ public class AggregatedPolicyController implements PolicyController, return builder.toString(); } - /** - * {@inheritDoc} - */ - @Override - public Properties getInitializationProperties() { - return this.properties; - } - } |