summaryrefslogtreecommitdiffstats
path: root/plugins/plugins-executor/plugins-executor-java/src/main
diff options
context:
space:
mode:
authorliamfallon <liam.fallon@est.tech>2019-06-26 15:40:41 +0000
committerliamfallon <liam.fallon@est.tech>2019-06-26 15:40:41 +0000
commitce9d82d2c0e863597d84cc8909955e398405f45a (patch)
tree8ebb853119bdf673cf6f9516d428d4cc00080aeb /plugins/plugins-executor/plugins-executor-java/src/main
parent5f029543f1e673655af2d2974113069df0b6def0 (diff)
Add passthrough properties for APEX engine
APEX event receiver and sender plugins sometimes need to exchange information with tasks, especially in the case of REST communication. This change enables passthrough of Properties from the event carrier technology plugins to APEX task, task selection, and state finalizer logics. Apologies for the size of the review but this change involves passinng the properties through all the APEX components, hence the large number of small changes. Issue-ID: POLICY-1742 Change-Id: I219fd69550f06702ef64adbb165fe7baac422e96 Signed-off-by: liamfallon <liam.fallon@est.tech>
Diffstat (limited to 'plugins/plugins-executor/plugins-executor-java/src/main')
-rw-r--r--plugins/plugins-executor/plugins-executor-java/src/main/java/org/onap/policy/apex/plugins/executor/java/JavaStateFinalizerExecutor.java10
-rw-r--r--plugins/plugins-executor/plugins-executor-java/src/main/java/org/onap/policy/apex/plugins/executor/java/JavaTaskExecutor.java10
-rw-r--r--plugins/plugins-executor/plugins-executor-java/src/main/java/org/onap/policy/apex/plugins/executor/java/JavaTaskSelectExecutor.java30
3 files changed, 28 insertions, 22 deletions
diff --git a/plugins/plugins-executor/plugins-executor-java/src/main/java/org/onap/policy/apex/plugins/executor/java/JavaStateFinalizerExecutor.java b/plugins/plugins-executor/plugins-executor-java/src/main/java/org/onap/policy/apex/plugins/executor/java/JavaStateFinalizerExecutor.java
index ef0a8d178..ce242bafb 100644
--- a/plugins/plugins-executor/plugins-executor-java/src/main/java/org/onap/policy/apex/plugins/executor/java/JavaStateFinalizerExecutor.java
+++ b/plugins/plugins-executor/plugins-executor-java/src/main/java/org/onap/policy/apex/plugins/executor/java/JavaStateFinalizerExecutor.java
@@ -22,6 +22,7 @@ package org.onap.policy.apex.plugins.executor.java;
import java.lang.reflect.Method;
import java.util.Map;
+import java.util.Properties;
import org.onap.policy.apex.context.ContextException;
import org.onap.policy.apex.core.engine.executor.StateFinalizerExecutor;
@@ -66,16 +67,17 @@ public class JavaStateFinalizerExecutor extends StateFinalizerExecutor {
* Executes the executor for the state finalizer logic in a sequential manner.
*
* @param executionId the execution ID for the current APEX policy execution
+ * @param executionProperties properties for the current APEX policy execution
* @param incomingFields the incoming fields for finalisation
* @return The state output for the state
* @throws StateMachineException on an execution error
* @throws ContextException on context errors
*/
@Override
- public String execute(final long executionId, final Map<String, Object> incomingFields)
- throws StateMachineException, ContextException {
+ public String execute(final long executionId, final Properties executionProperties,
+ final Map<String, Object> incomingFields) throws StateMachineException, ContextException {
// Do execution pre work
- executePre(executionId, incomingFields);
+ executePre(executionId, executionProperties, incomingFields);
// Check and execute the Java logic
boolean returnValue = false;
@@ -84,7 +86,7 @@ public class JavaStateFinalizerExecutor extends StateFinalizerExecutor {
// StateFinalizerExecutionContext executor) throws ApexException"
// to invoke the
// task logic in the Java class
- final Method method = stateFinalizerLogicObject.getClass().getDeclaredMethod("getStateOutput", (Class[])
+ final Method method = stateFinalizerLogicObject.getClass().getDeclaredMethod("getStateOutput",
new Class[] { StateFinalizerExecutionContext.class });
returnValue = (boolean) method.invoke(stateFinalizerLogicObject, getExecutionContext());
} catch (final Exception e) {
diff --git a/plugins/plugins-executor/plugins-executor-java/src/main/java/org/onap/policy/apex/plugins/executor/java/JavaTaskExecutor.java b/plugins/plugins-executor/plugins-executor-java/src/main/java/org/onap/policy/apex/plugins/executor/java/JavaTaskExecutor.java
index e9bf45305..1ceeba3b1 100644
--- a/plugins/plugins-executor/plugins-executor-java/src/main/java/org/onap/policy/apex/plugins/executor/java/JavaTaskExecutor.java
+++ b/plugins/plugins-executor/plugins-executor-java/src/main/java/org/onap/policy/apex/plugins/executor/java/JavaTaskExecutor.java
@@ -22,6 +22,7 @@ package org.onap.policy.apex.plugins.executor.java;
import java.lang.reflect.Method;
import java.util.Map;
+import java.util.Properties;
import org.onap.policy.apex.context.ContextException;
import org.onap.policy.apex.core.engine.executor.TaskExecutor;
@@ -67,16 +68,17 @@ public class JavaTaskExecutor extends TaskExecutor {
* Executes the executor for the task in a sequential manner.
*
* @param executionId the execution ID for the current APEX policy execution
+ * @param executionProperties properties for the current APEX policy execution
* @param incomingFields the incoming fields
* @return The outgoing fields
* @throws StateMachineException on an execution error
* @throws ContextException on context errors
*/
@Override
- public Map<String, Object> execute(final long executionId, final Map<String, Object> incomingFields)
- throws StateMachineException, ContextException {
+ public Map<String, Object> execute(final long executionId, final Properties executionProperties,
+ final Map<String, Object> incomingFields) throws StateMachineException, ContextException {
// Do execution pre work
- executePre(executionId, incomingFields);
+ executePre(executionId, executionProperties, incomingFields);
// Check and execute the Java logic
boolean returnValue = false;
@@ -84,7 +86,7 @@ public class JavaTaskExecutor extends TaskExecutor {
// Find and call the method with the signature "public boolean getEvent(final TaskExecutionContext executor)
// throws ApexException" to invoke the
// task logic in the Java class
- final Method method = taskLogicObject.getClass().getDeclaredMethod("getEvent", (Class[])
+ final Method method = taskLogicObject.getClass().getDeclaredMethod("getEvent",
new Class[] { TaskExecutionContext.class });
returnValue = (boolean) method.invoke(taskLogicObject, getExecutionContext());
} catch (final Exception e) {
diff --git a/plugins/plugins-executor/plugins-executor-java/src/main/java/org/onap/policy/apex/plugins/executor/java/JavaTaskSelectExecutor.java b/plugins/plugins-executor/plugins-executor-java/src/main/java/org/onap/policy/apex/plugins/executor/java/JavaTaskSelectExecutor.java
index 02794cdf6..17758b19e 100644
--- a/plugins/plugins-executor/plugins-executor-java/src/main/java/org/onap/policy/apex/plugins/executor/java/JavaTaskSelectExecutor.java
+++ b/plugins/plugins-executor/plugins-executor-java/src/main/java/org/onap/policy/apex/plugins/executor/java/JavaTaskSelectExecutor.java
@@ -21,6 +21,7 @@
package org.onap.policy.apex.plugins.executor.java;
import java.lang.reflect.Method;
+import java.util.Properties;
import org.onap.policy.apex.context.ContextException;
import org.onap.policy.apex.core.engine.event.EnEvent;
@@ -58,10 +59,10 @@ public class JavaTaskSelectExecutor extends TaskSelectExecutor {
// Create the task logic object from the byte code of the class
taskSelectionLogicObject = Class.forName(getSubject().getTaskSelectionLogic().getLogic()).newInstance();
} catch (final Exception e) {
- LOGGER.error("instantiation error on Java class \"" + getSubject().getTaskSelectionLogic().getLogic()
- + "\"", e);
- throw new StateMachineException("instantiation error on Java class \""
- + getSubject().getTaskSelectionLogic().getLogic() + "\"", e);
+ LOGGER.error(
+ "instantiation error on Java class \"" + getSubject().getTaskSelectionLogic().getLogic() + "\"", e);
+ throw new StateMachineException(
+ "instantiation error on Java class \"" + getSubject().getTaskSelectionLogic().getLogic() + "\"", e);
}
}
@@ -69,16 +70,17 @@ public class JavaTaskSelectExecutor extends TaskSelectExecutor {
* Executes the executor for the task in a sequential manner.
*
* @param executionId the execution ID for the current APEX policy execution
+ * @param executionProperties properties for the current APEX policy execution
* @param incomingEvent the incoming event
* @return The outgoing event
* @throws StateMachineException on an execution error
* @throws ContextException on context errors
*/
@Override
- public AxArtifactKey execute(final long executionId, final EnEvent incomingEvent)
- throws StateMachineException, ContextException {
+ public AxArtifactKey execute(final long executionId, final Properties executionProperties,
+ final EnEvent incomingEvent) throws StateMachineException, ContextException {
// Do execution pre work
- executePre(executionId, incomingEvent);
+ executePre(executionId, executionProperties, incomingEvent);
// Check and execute the Java logic
boolean returnValue = false;
@@ -87,14 +89,14 @@ public class JavaTaskSelectExecutor extends TaskSelectExecutor {
// executor)" to invoke the task selection
// logic in the Java class
final Method method = taskSelectionLogicObject.getClass().getDeclaredMethod("getTask",
- (Class[]) new Class[] { TaskSelectionExecutionContext.class });
+ new Class[] { TaskSelectionExecutionContext.class });
returnValue = (boolean) method.invoke(taskSelectionLogicObject, getExecutionContext());
} catch (final Exception e) {
- LOGGER.error("execute: task selection logic failed to run for state \"" + getSubject().getKey().getId()
- + "\"", e);
+ LOGGER.error(
+ "execute: task selection logic failed to run for state \"" + getSubject().getKey().getId() + "\"",
+ e);
throw new StateMachineException(
- "task selection logic failed to run for state \"" + getSubject().getKey().getId() + "\"",
- e);
+ "task selection logic failed to run for state \"" + getSubject().getKey().getId() + "\"", e);
}
// Do the execution post work
@@ -112,7 +114,7 @@ public class JavaTaskSelectExecutor extends TaskSelectExecutor {
@Override
public void cleanUp() throws StateMachineException {
LOGGER.debug("cleanUp:" + getSubject().getKey().getId() + ","
- + getSubject().getTaskSelectionLogic().getLogicFlavour() + ","
- + getSubject().getTaskSelectionLogic().getLogic());
+ + getSubject().getTaskSelectionLogic().getLogicFlavour() + ","
+ + getSubject().getTaskSelectionLogic().getLogic());
}
}