diff options
author | Jim Hahn <jrh3@att.com> | 2020-02-20 09:40:14 -0500 |
---|---|---|
committer | Jim Hahn <jrh3@att.com> | 2020-02-20 16:29:08 -0500 |
commit | 467247c7970f9ae83464d78929ed970bbf03c593 (patch) | |
tree | 54b78e6505b664c3a61e532bf6f7c276307d6591 /models-interactions/model-actors/actor.aai/src/main | |
parent | f6da7772d9dc01ce4ddd21a55b0f1c5fb7ad814f (diff) |
More actor clean-up
Currently, Operator classes refer to Operation classes, and
vice versa, creating a dependency cycle. In addition, there is
a slight problem in that if an operator is reconfigured, any
running operation may get inconsistent configuration data.
Modified the code to create Config objects that are passed to
the operation, instead of passing the Operator to the operations.
This solved both issues.
Replaceed makeOperator() with constructors.
Added parameter type to HttpActors.
Modified guard to get "ONAP" properties from its configuration,
as a default.
Changed setUp() to setUpBasic(), so "throws Exception" could be
removed, thus resolving a sonar issue.
Issue-ID: POLICY-1625
Signed-off-by: Jim Hahn <jrh3@att.com>
Change-Id: I21eb8798acfbc636ff1bd8741b21c7278365b6e4
Diffstat (limited to 'models-interactions/model-actors/actor.aai/src/main')
3 files changed, 17 insertions, 17 deletions
diff --git a/models-interactions/model-actors/actor.aai/src/main/java/org/onap/policy/controlloop/actor/aai/AaiActorServiceProvider.java b/models-interactions/model-actors/actor.aai/src/main/java/org/onap/policy/controlloop/actor/aai/AaiActorServiceProvider.java index df427c32c..a65a000ed 100644 --- a/models-interactions/model-actors/actor.aai/src/main/java/org/onap/policy/controlloop/actor/aai/AaiActorServiceProvider.java +++ b/models-interactions/model-actors/actor.aai/src/main/java/org/onap/policy/controlloop/actor/aai/AaiActorServiceProvider.java @@ -23,25 +23,25 @@ package org.onap.policy.controlloop.actor.aai; import org.onap.policy.aai.AaiConstants; import org.onap.policy.controlloop.actorserviceprovider.impl.HttpActor; import org.onap.policy.controlloop.actorserviceprovider.impl.HttpOperator; +import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpActorParams; /** * A&AI Actor. */ -public class AaiActorServiceProvider extends HttpActor { +public class AaiActorServiceProvider extends HttpActor<HttpActorParams> { public static final String NAME = AaiConstants.ACTOR_NAME; /** * Constructs the object. */ public AaiActorServiceProvider() { - super(NAME); + super(NAME, HttpActorParams.class); - addOperator(HttpOperator.makeOperator(NAME, AaiCustomQueryOperation.NAME, - AaiCustomQueryOperation::new)); + addOperator(new HttpOperator(NAME, AaiCustomQueryOperation.NAME, AaiCustomQueryOperation::new)); // add all "get" operators for (String operation : AaiGetOperation.OPERATIONS) { - addOperator(HttpOperator.makeOperator(NAME, operation, AaiGetOperation::new)); + addOperator(new HttpOperator(NAME, operation, AaiGetOperation::new)); } } } diff --git a/models-interactions/model-actors/actor.aai/src/main/java/org/onap/policy/controlloop/actor/aai/AaiCustomQueryOperation.java b/models-interactions/model-actors/actor.aai/src/main/java/org/onap/policy/controlloop/actor/aai/AaiCustomQueryOperation.java index 427701505..6b0287101 100644 --- a/models-interactions/model-actors/actor.aai/src/main/java/org/onap/policy/controlloop/actor/aai/AaiCustomQueryOperation.java +++ b/models-interactions/model-actors/actor.aai/src/main/java/org/onap/policy/controlloop/actor/aai/AaiCustomQueryOperation.java @@ -32,8 +32,8 @@ import org.onap.policy.common.endpoints.utils.NetLoggerUtil.EventType; import org.onap.policy.common.utils.coder.StandardCoderObject; import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome; import org.onap.policy.controlloop.actorserviceprovider.impl.HttpOperation; -import org.onap.policy.controlloop.actorserviceprovider.impl.HttpOperator; import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams; +import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpConfig; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -56,10 +56,10 @@ public class AaiCustomQueryOperation extends HttpOperation<String> { * Constructs the object. * * @param params operation parameters - * @param operator operator that created this operation + * @param config configuration for this operation */ - public AaiCustomQueryOperation(ControlLoopOperationParams params, HttpOperator operator) { - super(params, operator, String.class); + public AaiCustomQueryOperation(ControlLoopOperationParams params, HttpConfig config) { + super(params, config, String.class); } /** @@ -91,7 +91,7 @@ public class AaiCustomQueryOperation extends HttpOperation<String> { // @formatter:off return handleResponse(outcome, url, - callback -> getOperator().getClient().put(callback, makePath(), entity, headers)); + callback -> getClient().put(callback, makePath(), entity, headers)); // @formatter:on } diff --git a/models-interactions/model-actors/actor.aai/src/main/java/org/onap/policy/controlloop/actor/aai/AaiGetOperation.java b/models-interactions/model-actors/actor.aai/src/main/java/org/onap/policy/controlloop/actor/aai/AaiGetOperation.java index dd3a4d6c0..408c1a0b1 100644 --- a/models-interactions/model-actors/actor.aai/src/main/java/org/onap/policy/controlloop/actor/aai/AaiGetOperation.java +++ b/models-interactions/model-actors/actor.aai/src/main/java/org/onap/policy/controlloop/actor/aai/AaiGetOperation.java @@ -31,8 +31,8 @@ import org.onap.policy.common.endpoints.utils.NetLoggerUtil.EventType; import org.onap.policy.common.utils.coder.StandardCoderObject; import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome; import org.onap.policy.controlloop.actorserviceprovider.impl.HttpOperation; -import org.onap.policy.controlloop.actorserviceprovider.impl.HttpOperator; import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams; +import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpConfig; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -68,11 +68,11 @@ public class AaiGetOperation extends HttpOperation<StandardCoderObject> { * Constructs the object. * * @param params operation parameters - * @param operator operator that created this operation + * @param config configuration for this operation */ - public AaiGetOperation(ControlLoopOperationParams params, HttpOperator operator) { - super(params, operator, StandardCoderObject.class); - this.propertyPrefix = operator.getFullName() + "."; + public AaiGetOperation(ControlLoopOperationParams params, HttpConfig config) { + super(params, config, StandardCoderObject.class); + this.propertyPrefix = getFullName() + "."; } /** @@ -98,7 +98,7 @@ public class AaiGetOperation extends HttpOperation<StandardCoderObject> { // @formatter:off return handleResponse(outcome, url, - callback -> getOperator().getClient().get(callback, makePath(), headers)); + callback -> getClient().get(callback, makePath(), headers)); // @formatter:on } @@ -109,7 +109,7 @@ public class AaiGetOperation extends HttpOperation<StandardCoderObject> { @Override public String makePath() { - return (getOperator().getPath() + "/" + params.getTargetEntity()); + return (getPath() + "/" + params.getTargetEntity()); } /** |