diff options
Diffstat (limited to 'controlloop/common/eventmanager/src/main')
4 files changed, 20 insertions, 27 deletions
diff --git a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ClEventManagerWithEvent.java b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ClEventManagerWithEvent.java index db7ec1d93..fef35e498 100644 --- a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ClEventManagerWithEvent.java +++ b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ClEventManagerWithEvent.java @@ -61,16 +61,17 @@ public abstract class ClEventManagerWithEvent<T extends Step> extends ClEventMan /** * Constructs the object. * + * @param services services the manager should use when processing the event * @param params control loop parameters * @param event event to be managed by this object * @param workMem working memory to update if this changes * @throws ControlLoopException if the event is invalid or if a YAML processor cannot * be created */ - public ClEventManagerWithEvent(ControlLoopParams params, VirtualControlLoopEvent event, WorkingMemory workMem) - throws ControlLoopException { + public ClEventManagerWithEvent(EventManagerServices services, ControlLoopParams params, + VirtualControlLoopEvent event, WorkingMemory workMem) throws ControlLoopException { - super(params, event.getRequestId(), workMem); + super(services, params, event.getRequestId(), workMem); checkEventSyntax(event); diff --git a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ClEventManagerWithOutcome.java b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ClEventManagerWithOutcome.java index a94598ef7..9d5d15808 100644 --- a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ClEventManagerWithOutcome.java +++ b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ClEventManagerWithOutcome.java @@ -70,16 +70,17 @@ public abstract class ClEventManagerWithOutcome<T extends Step> extends ClEventM /** * Constructs the object. * + * @param services services the manager should use when processing the event * @param params control loop parameters * @param requestId event request ID * @param workMem working memory to update if this changes * @throws ControlLoopException if the event is invalid or if a YAML processor cannot * be created */ - public ClEventManagerWithOutcome(ControlLoopParams params, UUID requestId, WorkingMemory workMem) - throws ControlLoopException { + public ClEventManagerWithOutcome(EventManagerServices services, ControlLoopParams params, UUID requestId, + WorkingMemory workMem) throws ControlLoopException { - super(params, requestId, workMem); + super(services, params, requestId, workMem); } @Override diff --git a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ClEventManagerWithSteps.java b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ClEventManagerWithSteps.java index 6f6cd0fda..0187db751 100644 --- a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ClEventManagerWithSteps.java +++ b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ClEventManagerWithSteps.java @@ -130,16 +130,17 @@ public abstract class ClEventManagerWithSteps<T extends Step> extends ControlLoo /** * Constructs the object. * + * @param services services the manager should use when processing the event * @param params control loop parameters * @param requestId event request ID * @param workMem working memory to update if this changes * @throws ControlLoopException if the event is invalid or if a YAML processor cannot * be created */ - public ClEventManagerWithSteps(ControlLoopParams params, UUID requestId, WorkingMemory workMem) - throws ControlLoopException { + public ClEventManagerWithSteps(EventManagerServices services, ControlLoopParams params, UUID requestId, + WorkingMemory workMem) throws ControlLoopException { - super(params, requestId); + super(services, params, requestId); if (requestId == null) { throw new ControlLoopException("No request ID"); diff --git a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager.java b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager.java index 2c7e133af..f23f559e4 100644 --- a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager.java +++ b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager.java @@ -69,7 +69,6 @@ public class ControlLoopEventManager implements StepContext, Serializable { private static final OperationHistoryDataManager STUB_DATA_MANAGER = new OperationHistoryDataManagerStub(); private static final String GUARD_DISABLED_PROPERTY = "guard.disabled"; - private static final String EVENT_MANAGER_SERVICE_CONFIG = "event-manager"; /** * Counts the number of these objects that have been created. This is used by junit @@ -84,6 +83,8 @@ public class ControlLoopEventManager implements StepContext, Serializable { */ private transient boolean createdByThisJvmInstance; + private final transient EventManagerServices services; + @Getter @ToString.Include public final String closedLoopControlName; @@ -128,16 +129,19 @@ public class ControlLoopEventManager implements StepContext, Serializable { /** * Constructs the object. * + * @param services services the manager should use when processing the event * @param params control loop parameters * @param requestId event request ID * @throws ControlLoopException if the event is invalid or if a YAML processor cannot * be created */ - public ControlLoopEventManager(ControlLoopParams params, UUID requestId) throws ControlLoopException { + public ControlLoopEventManager(EventManagerServices services, ControlLoopParams params, UUID requestId) + throws ControlLoopException { createCount.incrementAndGet(); this.createdByThisJvmInstance = true; + this.services = services; this.closedLoopControlName = params.getClosedLoopControlName(); this.requestId = requestId; this.policyName = params.getPolicyName(); @@ -316,20 +320,6 @@ public class ControlLoopEventManager implements StepContext, Serializable { properties.remove(name); } - /** - * Initializes various components, on demand. - */ - private static class LazyInitData { - private static final OperationHistoryDataManager DATA_MANAGER; - private static final ActorService ACTOR_SERVICE; - - static { - EventManagerServices services = new EventManagerServices(EVENT_MANAGER_SERVICE_CONFIG); - ACTOR_SERVICE = services.getActorService(); - DATA_MANAGER = services.getDataManager(); - } - } - // the following methods may be overridden by junit tests public Executor getExecutor() { @@ -345,12 +335,12 @@ public class ControlLoopEventManager implements StepContext, Serializable { } public ActorService getActorService() { - return LazyInitData.ACTOR_SERVICE; + return services.getActorService(); } public OperationHistoryDataManager getDataManager() { boolean guardDisabled = "true".equalsIgnoreCase(getEnvironmentProperty(GUARD_DISABLED_PROPERTY)); - return (guardDisabled ? STUB_DATA_MANAGER : LazyInitData.DATA_MANAGER); + return (guardDisabled ? STUB_DATA_MANAGER : services.getDataManager()); } protected String getEnvironmentProperty(String propName) { |