summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--api-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/ActiveStandbyFeatureAPI.java16
-rw-r--r--api-state-management/src/main/java/org/onap/policy/drools/statemanagement/StateManagementFeatureAPI.java48
-rw-r--r--policy-core/src/main/java/org/onap/policy/drools/core/PolicySessionFeatureAPI.java12
-rw-r--r--policy-core/src/main/java/org/onap/policy/drools/core/lock/PolicyResourceLockFeatureApi.java30
-rw-r--r--policy-management/src/main/java/org/onap/policy/drools/features/DroolsControllerFeatureAPI.java4
-rw-r--r--policy-management/src/main/java/org/onap/policy/drools/features/PolicyControllerFeatureAPI.java94
-rw-r--r--policy-management/src/main/java/org/onap/policy/drools/features/PolicyEngineFeatureAPI.java4
-rw-r--r--policy-utils/src/main/java/org/onap/policy/drools/utils/OrderedService.java47
-rw-r--r--policy-utils/src/main/java/org/onap/policy/drools/utils/OrderedServiceImpl.java135
9 files changed, 104 insertions, 286 deletions
diff --git a/api-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/ActiveStandbyFeatureAPI.java b/api-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/ActiveStandbyFeatureAPI.java
index ac1f1ce5..5f99e6bb 100644
--- a/api-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/ActiveStandbyFeatureAPI.java
+++ b/api-active-standby-management/src/main/java/org/onap/policy/drools/activestandby/ActiveStandbyFeatureAPI.java
@@ -2,14 +2,14 @@
* ============LICENSE_START=======================================================
* api-active-standby-management
* ================================================================================
- * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -20,8 +20,8 @@
package org.onap.policy.drools.activestandby;
-import org.onap.policy.drools.utils.OrderedService;
-import org.onap.policy.drools.utils.OrderedServiceImpl;
+import org.onap.policy.common.utils.services.OrderedService;
+import org.onap.policy.common.utils.services.OrderedServiceImpl;
/**
* This interface provides a way to invoke optional features at various points in the code. At
@@ -39,7 +39,7 @@ public interface ActiveStandbyFeatureAPI extends OrderedService {
/**
* Returns the resourceName (PDP ID) for the Drools-PDP that is
* currently designated as active.
- *
+ *
* @return String (resourceName)
*/
public String getPdpdNowActive();
@@ -47,14 +47,14 @@ public interface ActiveStandbyFeatureAPI extends OrderedService {
/**
* Returns the resourceName (PDP ID) for the Drools-PDP that is
* previously designated as active.
- *
+ *
* @return String (resourceName)
*/
public String getPdpdLastActive();
/**
* Returns the resourceName associated with this instance of the feature.
- *
+ *
* @return String (resourceName)
*/
public String getResourceName();
diff --git a/api-state-management/src/main/java/org/onap/policy/drools/statemanagement/StateManagementFeatureAPI.java b/api-state-management/src/main/java/org/onap/policy/drools/statemanagement/StateManagementFeatureAPI.java
index be229ef3..1dd22cd0 100644
--- a/api-state-management/src/main/java/org/onap/policy/drools/statemanagement/StateManagementFeatureAPI.java
+++ b/api-state-management/src/main/java/org/onap/policy/drools/statemanagement/StateManagementFeatureAPI.java
@@ -2,14 +2,14 @@
* ============LICENSE_START=======================================================
* policy-core
* ================================================================================
- * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -27,8 +27,8 @@ import javax.validation.constraints.NotNull;
import org.onap.policy.common.capabilities.Lockable;
import org.onap.policy.common.im.AllSeemsWellException;
import org.onap.policy.common.im.StateManagement;
-import org.onap.policy.drools.utils.OrderedService;
-import org.onap.policy.drools.utils.OrderedServiceImpl;
+import org.onap.policy.common.utils.services.OrderedService;
+import org.onap.policy.common.utils.services.OrderedServiceImpl;
/**
* This interface provides a way to invoke optional features at various points in the code. At
@@ -81,10 +81,10 @@ public interface StateManagementFeatureAPI extends OrderedService, Lockable {
* implemented in the common modules IntegrityMonitor where it will cause the testTransaction to
* fail if any module has set the value ALLNOTWELL, stopping the forward progress counter and
* eventually causing the operational state to become disabled.
- *
+ *
* <p>ALLSEEMSWELL is passed to the method when the client is healthy ALLNOTWELL is passed to the
* method when the client is disabled
- *
+ *
* @param key - This should be a unique identifier for the entity making the call (e.g., class
* name)
* @param asw - This is the indicator of health. See constants: ALLSEEMSWELL or ALLNOTWELL
@@ -98,42 +98,42 @@ public interface StateManagementFeatureAPI extends OrderedService, Lockable {
/**
* This method is called to add an Observer to receive notifications of state changes.
- *
+ *
* @param stateChangeObserver observer
*/
public void addObserver(Observer stateChangeObserver);
/**
* Returns the X.731 Administrative State for this resource.
- *
+ *
* @return String (locked, unlocked)
*/
public String getAdminState();
/**
* Returns the X.731 Operational State for this resource.
- *
+ *
* @return String (enabled, disabled)
- */
+ */
public String getOpState();
/**
* Returns the X.731 Availability Status for this resource.
- *
+ *
* @return String (failed; dependency; dependency,failed)
- */
+ */
public String getAvailStatus();
/**
* Returns the X.731 Standby Status for this resource.
- *
+ *
* @return String (providingservice, hotstandby or coldstandby)
- */
+ */
public String getStandbyStatus();
/**
* Returns the X.731 Standby Status for the named resource
- *
+ *
* @param String (resourceName)
* @return String (providingservice, hotstandby or coldstandby)
*/
@@ -143,7 +143,7 @@ public interface StateManagementFeatureAPI extends OrderedService, Lockable {
* This method moves the X.731 Operational State for the named resource into a value of disabled
* and the Availability Status to a value of failed. As a consequence the Standby Status value
* will take a value of coldstandby.
- *
+ *
* @param resourceName resource name
* @throws Exception exception
*/
@@ -153,7 +153,7 @@ public interface StateManagementFeatureAPI extends OrderedService, Lockable {
* This method moves the X.731 Operational State for this resource into a value of disabled and
* the Availability Status to a value of failed. As a consequence the Standby Status value will
* take a value of coldstandby.
- *
+ *
* @throws Exception exception
*/
public void disableFailed() throws Exception;
@@ -163,7 +163,7 @@ public interface StateManagementFeatureAPI extends OrderedService, Lockable {
* providingservice. If the current value is coldstandby, no change is made. If the current
* value is null, it will move to providingservice assuming the Operational State is enabled and
* Administrative State is unlocked.
- *
+ *
* @throws Exception exception
*/
public void promote() throws Exception;
@@ -172,7 +172,7 @@ public interface StateManagementFeatureAPI extends OrderedService, Lockable {
* This method moves the X.731 Standby Status for this resource from providingservice to
* hotstandby. If the current value is null, it will move to hotstandby assuming the Operational
* State is enabled and Administrative State is unlocked. Else, it will move to coldstandby
- *
+ *
* @throws Exception exception
*/
public void demote() throws Exception;
@@ -180,14 +180,14 @@ public interface StateManagementFeatureAPI extends OrderedService, Lockable {
/**
* Returns the resourceName associated with this instance of the
* StateManagementFeature.
- *
+ *
* @return String (resourceName)
*/
public String getResourceName();
/**
* This Lockable method will lock the StateManagement object Admin state.
- *
+ *
* @return true if successful, false otherwise
*/
@Override
@@ -195,7 +195,7 @@ public interface StateManagementFeatureAPI extends OrderedService, Lockable {
/**
* This Lockable method will unlock the StateManagement object Admin state.
- *
+ *
* @return true if successfull, false otherwise
*/
@Override
@@ -203,7 +203,7 @@ public interface StateManagementFeatureAPI extends OrderedService, Lockable {
/**
* This Lockable method indicates the Admin state StateManagement object.
- *
+ *
* @return true if locked, false otherwise
*/
@Override
diff --git a/policy-core/src/main/java/org/onap/policy/drools/core/PolicySessionFeatureAPI.java b/policy-core/src/main/java/org/onap/policy/drools/core/PolicySessionFeatureAPI.java
index 3e49ee5b..56595901 100644
--- a/policy-core/src/main/java/org/onap/policy/drools/core/PolicySessionFeatureAPI.java
+++ b/policy-core/src/main/java/org/onap/policy/drools/core/PolicySessionFeatureAPI.java
@@ -2,14 +2,14 @@
* ============LICENSE_START=======================================================
* policy-core
* ================================================================================
- * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -21,8 +21,8 @@
package org.onap.policy.drools.core;
import org.kie.api.runtime.KieSession;
-import org.onap.policy.drools.utils.OrderedService;
-import org.onap.policy.drools.utils.OrderedServiceImpl;
+import org.onap.policy.common.utils.services.OrderedService;
+import org.onap.policy.common.utils.services.OrderedServiceImpl;
/**
* This interface provides a way to invoke optional features at various
@@ -30,7 +30,7 @@ import org.onap.policy.drools.utils.OrderedServiceImpl;
* application, the code iterates through this list, invoking these optional
* methods. Most of the methods here are notification only -- these tend to
* return a 'void' value. In other cases, such as 'activatePolicySession',
- * may
+ * may
*/
public interface PolicySessionFeatureAPI extends OrderedService {
/**
diff --git a/policy-core/src/main/java/org/onap/policy/drools/core/lock/PolicyResourceLockFeatureApi.java b/policy-core/src/main/java/org/onap/policy/drools/core/lock/PolicyResourceLockFeatureApi.java
index 66766453..ff7de049 100644
--- a/policy-core/src/main/java/org/onap/policy/drools/core/lock/PolicyResourceLockFeatureApi.java
+++ b/policy-core/src/main/java/org/onap/policy/drools/core/lock/PolicyResourceLockFeatureApi.java
@@ -2,14 +2,14 @@
* ============LICENSE_START=======================================================
* api-resource-locks
* ================================================================================
- * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2018-2019 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -20,17 +20,17 @@
package org.onap.policy.drools.core.lock;
-import org.onap.policy.drools.utils.OrderedService;
-import org.onap.policy.drools.utils.OrderedServiceImpl;
+import org.onap.policy.common.utils.services.OrderedService;
+import org.onap.policy.common.utils.services.OrderedServiceImpl;
/**
* Resource locks. Each lock has an "owner", which is intended to be unique across a
* single instance of a running PolicyEngine.
- *
+ *
* <p>This interface provides a way to invoke optional features at various points in the
* code. At appropriate points in the application, the code iterates through this list,
* invoking these optional methods.
- *
+ *
* <p>Implementers may choose to implement a level of locking appropriate to the application.
* For instance, they may choose to implement an engine-wide locking scheme, or they may
* choose to implement a global locking scheme (e.g., through a shared DB).
@@ -71,7 +71,7 @@ public interface PolicyResourceLockFeatureApi extends OrderedService {
/**
* This method is called before a lock is acquired on a resource.
- *
+ *
* @param resourceId resource id
* @param owner owner
* @param holdSec the amount of time, in seconds, that the lock should be held
@@ -84,7 +84,7 @@ public interface PolicyResourceLockFeatureApi extends OrderedService {
/**
* This method is called after a lock for a resource has been acquired or denied.
- *
+ *
* @param resourceId resource id
* @param owner owner
* @param locked {@code true} if the lock was acquired, {@code false} if it was denied
@@ -98,7 +98,7 @@ public interface PolicyResourceLockFeatureApi extends OrderedService {
/**
* This method is called before a lock is refreshed on a resource. It may be invoked
* repeatedly to extend the time that a lock is held.
- *
+ *
* @param resourceId resource id
* @param owner owner
* @param holdSec the amount of time, in seconds, that the lock should be held
@@ -112,7 +112,7 @@ public interface PolicyResourceLockFeatureApi extends OrderedService {
/**
* This method is called after a lock for a resource has been refreshed (or after the
* refresh has been denied).
- *
+ *
* @param resourceId resource id
* @param owner owner
* @param locked {@code true} if the lock was acquired, {@code false} if it was denied
@@ -125,7 +125,7 @@ public interface PolicyResourceLockFeatureApi extends OrderedService {
/**
* This method is called before a lock on a resource is released.
- *
+ *
* @param resourceId resource id
* @param owner owner
* @return the result, where <b>OPER_DENIED</b> indicates that the lock is not
@@ -137,7 +137,7 @@ public interface PolicyResourceLockFeatureApi extends OrderedService {
/**
* This method is called after a lock on a resource is released.
- *
+ *
* @param resourceId resource id
* @param owner owner
* @param unlocked {@code true} if the lock was released, {@code false} if the owner
@@ -151,7 +151,7 @@ public interface PolicyResourceLockFeatureApi extends OrderedService {
/**
* This method is called before a check is made to determine if a resource is locked.
- *
+ *
* @param resourceId resource id
* @return the result, where <b>OPER_ACCEPTED</b> indicates that the resource is
* locked, while <b>OPER_DENIED</b> indicates that it is not
@@ -163,7 +163,7 @@ public interface PolicyResourceLockFeatureApi extends OrderedService {
/**
* This method is called before a check is made to determine if a particular owner
* holds the lock on a resource.
- *
+ *
* @param resourceId resource id
* @param owner owner
* @return the result, where <b>OPER_ACCEPTED</b> indicates that the resource is
diff --git a/policy-management/src/main/java/org/onap/policy/drools/features/DroolsControllerFeatureAPI.java b/policy-management/src/main/java/org/onap/policy/drools/features/DroolsControllerFeatureAPI.java
index d8663f10..d11bd145 100644
--- a/policy-management/src/main/java/org/onap/policy/drools/features/DroolsControllerFeatureAPI.java
+++ b/policy-management/src/main/java/org/onap/policy/drools/features/DroolsControllerFeatureAPI.java
@@ -21,9 +21,9 @@
package org.onap.policy.drools.features;
import org.onap.policy.common.endpoints.event.comm.TopicSink;
+import org.onap.policy.common.utils.services.OrderedService;
+import org.onap.policy.common.utils.services.OrderedServiceImpl;
import org.onap.policy.drools.controller.DroolsController;
-import org.onap.policy.drools.utils.OrderedService;
-import org.onap.policy.drools.utils.OrderedServiceImpl;
/**
* Drools Controller Feature API. Hooks into the Drools Controller operations.
diff --git a/policy-management/src/main/java/org/onap/policy/drools/features/PolicyControllerFeatureAPI.java b/policy-management/src/main/java/org/onap/policy/drools/features/PolicyControllerFeatureAPI.java
index 286948ed..40958427 100644
--- a/policy-management/src/main/java/org/onap/policy/drools/features/PolicyControllerFeatureAPI.java
+++ b/policy-management/src/main/java/org/onap/policy/drools/features/PolicyControllerFeatureAPI.java
@@ -2,14 +2,14 @@
* ============LICENSE_START=======================================================
* policy-management
* ================================================================================
- * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -23,27 +23,27 @@ package org.onap.policy.drools.features;
import java.util.Properties;
import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
+import org.onap.policy.common.utils.services.OrderedService;
+import org.onap.policy.common.utils.services.OrderedServiceImpl;
import org.onap.policy.drools.system.PolicyController;
-import org.onap.policy.drools.utils.OrderedService;
-import org.onap.policy.drools.utils.OrderedServiceImpl;
public interface PolicyControllerFeatureAPI extends OrderedService {
/**
* Feature providers implementing this interface.
*/
- public static final OrderedServiceImpl<PolicyControllerFeatureAPI> providers =
+ public static final OrderedServiceImpl<PolicyControllerFeatureAPI> providers =
new OrderedServiceImpl<>(PolicyControllerFeatureAPI.class);
/**
- * called before creating a controller with name 'name' and
+ * 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.
+ * 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.
*/
@@ -53,11 +53,11 @@ public interface PolicyControllerFeatureAPI extends OrderedService {
/**
* 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
+ * of the operation preventing the invocation of
* lower priority features. False, otherwise.
*/
public default boolean afterCreate(PolicyController controller) {
@@ -66,9 +66,9 @@ public interface PolicyControllerFeatureAPI extends OrderedService {
/**
* intercept before the Policy Controller is started.
- *
+ *
* @return true if this feature intercepts and takes ownership
- * of the operation preventing the invocation of
+ * of the operation preventing the invocation of
* lower priority features. False, otherwise.
*/
public default boolean beforeStart(PolicyController controller) {
@@ -77,9 +77,9 @@ public interface PolicyControllerFeatureAPI extends OrderedService {
/**
* intercept after the Policy Controller is started.
- *
+ *
* @return true if this feature intercepts and takes ownership
- * of the operation preventing the invocation of
+ * of the operation preventing the invocation of
* lower priority features. False, otherwise.
*/
public default boolean afterStart(PolicyController controller) {
@@ -88,9 +88,9 @@ public interface PolicyControllerFeatureAPI extends OrderedService {
/**
* intercept before the Policy Controller is stopped.
- *
+ *
* @return true if this feature intercepts and takes ownership
- * of the operation preventing the invocation of
+ * of the operation preventing the invocation of
* lower priority features. False, otherwise..
*/
public default boolean beforeStop(PolicyController controller) {
@@ -99,9 +99,9 @@ public interface PolicyControllerFeatureAPI extends OrderedService {
/**
* intercept after the Policy Controller is stopped.
- *
+ *
* @return true if this feature intercepts and takes ownership
- * of the operation preventing the invocation of
+ * of the operation preventing the invocation of
* lower priority features. False, otherwise.d.
*/
public default boolean afterStop(PolicyController controller) {
@@ -110,9 +110,9 @@ public interface PolicyControllerFeatureAPI extends OrderedService {
/**
* intercept before the Policy Controller is locked.
- *
+ *
* @return true if this feature intercepts and takes ownership
- * of the operation preventing the invocation of
+ * of the operation preventing the invocation of
* lower priority features. False, otherwise.
*/
public default boolean beforeLock(PolicyController controller) {
@@ -121,9 +121,9 @@ public interface PolicyControllerFeatureAPI extends OrderedService {
/**
* intercept after the Policy Controller is locked.
- *
+ *
* @return true if this feature intercepts and takes ownership
- * of the operation preventing the invocation of
+ * of the operation preventing the invocation of
* lower priority features. False, otherwise..
*/
public default boolean afterLock(PolicyController controller) {
@@ -132,9 +132,9 @@ public interface PolicyControllerFeatureAPI extends OrderedService {
/**
* intercept before the Policy Controller is locked.
- *
+ *
* @return true if this feature intercepts and takes ownership
- * of the operation preventing the invocation of
+ * of the operation preventing the invocation of
* lower priority features. False, otherwise.
*/
public default boolean beforeUnlock(PolicyController controller) {
@@ -143,9 +143,9 @@ public interface PolicyControllerFeatureAPI extends OrderedService {
/**
* intercept after the Policy Controller is locked.
- *
+ *
* @return true if this feature intercepts and takes ownership
- * of the operation preventing the invocation of
+ * of the operation preventing the invocation of
* lower priority features. False, otherwise.
*/
public default boolean afterUnlock(PolicyController controller) {
@@ -154,9 +154,9 @@ public interface PolicyControllerFeatureAPI extends OrderedService {
/**
* intercept before the Policy Controller is shut down.
- *
+ *
* @return true if this feature intercepts and takes ownership
- * of the operation preventing the invocation of
+ * of the operation preventing the invocation of
* lower priority features. False, otherwise..
*/
public default boolean beforeShutdown(PolicyController controller) {
@@ -165,9 +165,9 @@ public interface PolicyControllerFeatureAPI extends OrderedService {
/**
* called after the Policy Controller is shut down.
- *
+ *
* @return true if this feature intercepts and takes ownership
- * of the operation preventing the invocation of
+ * of the operation preventing the invocation of
* lower priority features. False, otherwise.
*/
public default boolean afterShutdown(PolicyController controller) {
@@ -176,9 +176,9 @@ public interface PolicyControllerFeatureAPI extends OrderedService {
/**
* intercept before the Policy Controller is halted.
- *
+ *
* @return true if this feature intercepts and takes ownership
- * of the operation preventing the invocation of
+ * of the operation preventing the invocation of
* lower priority features. False, otherwise..
*/
public default boolean beforeHalt(PolicyController controller) {
@@ -187,9 +187,9 @@ public interface PolicyControllerFeatureAPI extends OrderedService {
/**
* called after the Policy Controller is halted.
- *
+ *
* @return true if this feature intercepts and takes ownership
- * of the operation preventing the invocation of
+ * of the operation preventing the invocation of
* lower priority features. False, otherwise.
*/
public default boolean afterHalt(PolicyController controller) {
@@ -199,9 +199,9 @@ public interface PolicyControllerFeatureAPI extends OrderedService {
/**
* intercept before the Policy Controller is offered an event.
- *
+ *
* @return true if this feature intercepts and takes ownership.
- * of the operation preventing the invocation of
+ * of the operation preventing the invocation of
* lower priority features. False, otherwise.
*/
public default boolean beforeOffer(PolicyController controller,
@@ -213,24 +213,24 @@ public interface PolicyControllerFeatureAPI extends OrderedService {
/**
* called after the Policy Controller processes an event offer.
- *
+ *
* @return true if this feature intercepts and takes ownership
- * of the operation preventing the invocation of
+ * of the operation preventing the invocation of
* lower priority features. False, otherwise.
*/
public default boolean afterOffer(PolicyController controller,
CommInfrastructure protocol,
String topic,
- String event,
+ String event,
boolean success) {
return false;
}
/**
* intercept before the Policy Controller delivers (posts) an event.
- *
+ *
* @return true if this feature intercepts and takes ownership
- * of the operation preventing the invocation of
+ * of the operation preventing the invocation of
* lower priority features. False, otherwise.
*/
public default boolean beforeDeliver(PolicyController controller,
@@ -242,15 +242,15 @@ public interface PolicyControllerFeatureAPI extends OrderedService {
/**
* called after the Policy Controller delivers (posts) an event.
- *
+ *
* @return true if this feature intercepts and takes ownership
- * of the operation preventing the invocation of
+ * of the operation preventing the invocation of
* lower priority features. False, otherwise.
*/
public default boolean afterDeliver(PolicyController controller,
CommInfrastructure protocol,
String topic,
- Object event,
+ Object event,
boolean success) {
return false;
}
diff --git a/policy-management/src/main/java/org/onap/policy/drools/features/PolicyEngineFeatureAPI.java b/policy-management/src/main/java/org/onap/policy/drools/features/PolicyEngineFeatureAPI.java
index a8772117..9b099909 100644
--- a/policy-management/src/main/java/org/onap/policy/drools/features/PolicyEngineFeatureAPI.java
+++ b/policy-management/src/main/java/org/onap/policy/drools/features/PolicyEngineFeatureAPI.java
@@ -22,10 +22,10 @@ package org.onap.policy.drools.features;
import java.util.Properties;
import org.onap.policy.common.endpoints.event.comm.Topic.CommInfrastructure;
+import org.onap.policy.common.utils.services.OrderedService;
+import org.onap.policy.common.utils.services.OrderedServiceImpl;
import org.onap.policy.drools.protocol.configuration.PdpdConfiguration;
import org.onap.policy.drools.system.PolicyEngine;
-import org.onap.policy.drools.utils.OrderedService;
-import org.onap.policy.drools.utils.OrderedServiceImpl;
/**
* Policy Engine Feature API.
diff --git a/policy-utils/src/main/java/org/onap/policy/drools/utils/OrderedService.java b/policy-utils/src/main/java/org/onap/policy/drools/utils/OrderedService.java
deleted file mode 100644
index 45ad85a8..00000000
--- a/policy-utils/src/main/java/org/onap/policy/drools/utils/OrderedService.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * policy-utils
- * ================================================================================
- * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.drools.utils;
-
-/**
- * This is a base interface that is used to control the order of a list
- * of services (features) discovered via 'ServiceLoader'. See
- * 'OrderedServiceImpl' for more details.
- */
-@FunctionalInterface
-public interface OrderedService {
- /**
- * Get sequence number.
- *
- * @return an integer sequence number, which determines the order of a list
- * of objects implementing this interface
- */
- public int getSequenceNumber();
-
-
- /**
- * Get the name.
- *
- * @return the name of the ordered service
- */
- public default String getName() {
- return this.getClass().getName();
- }
-}
diff --git a/policy-utils/src/main/java/org/onap/policy/drools/utils/OrderedServiceImpl.java b/policy-utils/src/main/java/org/onap/policy/drools/utils/OrderedServiceImpl.java
deleted file mode 100644
index fa0a045c..00000000
--- a/policy-utils/src/main/java/org/onap/policy/drools/utils/OrderedServiceImpl.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * policy-utils
- * ================================================================================
- * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.drools.utils;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.ServiceLoader;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * This class is a template for building a sorted list of service instances,
- * which are discovered and created using 'ServiceLoader'.
- */
-public class OrderedServiceImpl<T extends OrderedService> {
- // logger
- private static Logger logger = LoggerFactory.getLogger(OrderedServiceImpl.class);
-
- // sorted list of instances implementing the service
- private List<T> implementers = null;
-
- // 'ServiceLoader' that is used to discover and create the services
- private ServiceLoader<T> serviceLoader = null;
-
- // use this to ensure that we only use one unique instance of each class
- @SuppressWarnings("rawtypes")
- private static HashMap<Class,OrderedService> classToSingleton = new HashMap<>();
-
- /**
- * Constructor - create the 'ServiceLoader' instance.
- *
- * @param clazz the class object associated with 'T' (I supposed it could
- * be a subclass, but I'm not sure this is useful)
- */
- public OrderedServiceImpl(Class<T> clazz) {
- // This constructor wouldn't be needed if 'T.class' was legal
- serviceLoader = ServiceLoader.load(clazz);
- }
-
- /**
- * Get List of implementers.
- *
- * @return the sorted list of services implementing interface 'T' discovered
- * by 'ServiceLoader'.
- */
- public synchronized List<T> getList() {
- if (implementers == null) {
- rebuildList();
- }
- return implementers;
- }
-
- /**
- * This method is called by 'getList', but could also be called directly if
- * we were running with a 'ClassLoader' that supported the dynamic addition
- * of JAR files. In this case, it could be invoked in order to discover any
- * new services implementing interface 'T'. This is probably a relatively
- * expensive operation in terms of CPU and elapsed time, so it is best if it
- * isn't invoked too frequently.
- *
- * @return the sorted list of services implementing interface 'T' discovered
- * by 'ServiceLoader'.
- */
- @SuppressWarnings("unchecked")
- public synchronized List<T> rebuildList() {
- // build a list of all of the current implementors
- List<T> tmp = new LinkedList<>();
- for (T service : serviceLoader) {
- tmp.add((T)getSingleton(service));
- }
-
- // Sort the list according to sequence number, and then alphabetically
- // according to full class name.
- Collections.sort(tmp, (o1, o2) -> {
- int s1 = o1.getSequenceNumber();
- int s2 = o2.getSequenceNumber();
- if (s1 < s2) {
- return -1;
- } else if (s1 > s2) {
- return 1;
- } else {
- return o1.getClass().getName().compareTo(o2.getClass().getName());
- }
- });
-
- // create an unmodifiable version of this list
- implementers = Collections.unmodifiableList(tmp);
- logger.info("***** OrderedServiceImpl implementers:\n {}", implementers);
- return implementers;
- }
-
- /**
- * If a service implements multiple APIs managed by 'ServiceLoader', a
- * separate instance is created for each API. This method ensures that
- * the first instance is used in all of the lists.
- *
- * @param service this is the object created by ServiceLoader
- * @return the object to use in place of 'service'. If 'service' is the first
- * object of this class created by ServiceLoader, it is returned. If not,
- * the object of this class that was initially created is returned
- * instead.
- */
- private static synchronized OrderedService getSingleton(OrderedService service) {
- // see if we already have an instance of this class
- OrderedService rval = classToSingleton.get(service.getClass());
- if (rval == null) {
- // No previous instance of this class exists -- use the supplied
- // instance, and place it in the table.
- rval = service;
- classToSingleton.put(service.getClass(), service);
- }
- return rval;
- }
-}