Updated thru core-protocols.
Issue-ID: POLICY-3391
Change-Id: I2226fee16b276eba5c7f3fd1921a6cef36654f07
Signed-off-by: Jim Hahn <jrh3@att.com>
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2021 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.
package org.onap.policy.apex.core.engine;
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
+
/**
* This class holds constants used when managing engine parameter groups in apex.
*/
-public abstract class EngineParameterConstants {
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+public final class EngineParameterConstants {
public static final String MAIN_GROUP_NAME = "ENGINE_PARAMETERS";
public static final String EXECUTOR_GROUP_NAME = "EXECUTOR_PARAMETERS";
-
- /**
- * Private default constructor to prevent subclassing.
- */
- private EngineParameterConstants() {
- // Prevents subclassing
- }
-
}
package org.onap.policy.apex.core.engine;
+import lombok.Getter;
+import lombok.Setter;
import org.onap.policy.common.parameters.ParameterGroupImpl;
/**
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
+@Getter
+@Setter
public class ExecutorParameters extends ParameterGroupImpl {
// Executor Plugin classes for executors
private String taskExecutorPluginClass;
super(EngineParameterConstants.EXECUTOR_GROUP_NAME);
}
- /**
- * Gets the task executor plugin class for the executor.
- *
- * @return the task executor plugin class for the executor
- */
- public String getTaskExecutorPluginClass() {
- return taskExecutorPluginClass;
- }
-
- /**
- * Sets the task executor plugin class for the executor.
- *
- * @param taskExecutorPluginClass the task executor plugin class for the executor
- */
- public void setTaskExecutorPluginClass(final String taskExecutorPluginClass) {
- this.taskExecutorPluginClass = taskExecutorPluginClass;
- }
-
- /**
- * Gets the task selection executor plugin class for the executor.
- *
- * @return the task selection executor plugin class for the executor
- */
- public String getTaskSelectionExecutorPluginClass() {
- return taskSelectionExecutorPluginClass;
- }
-
- /**
- * Sets the task selection executor plugin class for the executor.
- *
- * @param taskSelectionExecutorPluginClass the task selection executor plugin class for the
- * executor
- */
- public void setTaskSelectionExecutorPluginClass(final String taskSelectionExecutorPluginClass) {
- this.taskSelectionExecutorPluginClass = taskSelectionExecutorPluginClass;
- }
-
- /**
- * Gets the state finalizer executor plugin class for the executor.
- *
- * @return the state finalizer executor plugin class for the executor
- */
- public String getStateFinalizerExecutorPluginClass() {
- return stateFinalizerExecutorPluginClass;
- }
-
- /**
- * Sets the state finalizer executor plugin class for the executor.
- *
- * @param stateFinalizerExecutorPluginClass the state finalizer executor plugin class for the
- * executor
- */
- public void setStateFinalizerExecutorPluginClass(final String stateFinalizerExecutorPluginClass) {
- this.stateFinalizerExecutorPluginClass = stateFinalizerExecutorPluginClass;
- }
-
@Override
public String toString() {
return "ExecutorParameters [name=" + getName() + ", taskExecutorPluginClass=" + taskExecutorPluginClass
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2020 Nordix Foundation.
+ * Modifications Copyright (C) 2021 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.
package org.onap.policy.apex.core.engine;
import lombok.Getter;
+import lombok.NoArgsConstructor;
import lombok.Setter;
import org.onap.policy.common.parameters.BeanValidator;
import org.onap.policy.common.parameters.ValidationResult;
*/
@Getter
@Setter
+@NoArgsConstructor
public class TaskParameters {
- private String name;
+ private String name = "taskParameters";
// If taskId is not specified, then the taskParameter is added to all tasks in the engine.
private String taskId;
@NotBlank
private String value;
- public TaskParameters() {
- this.name = "taskParameters";
- }
-
/**
* Full constructor.
*
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 2021 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.
import java.util.NavigableMap;
import java.util.Set;
import java.util.TreeMap;
+import lombok.Getter;
import org.onap.policy.apex.context.ContextAlbum;
import org.onap.policy.apex.context.ContextException;
import org.onap.policy.apex.context.Distributor;
*/
public class ApexInternalContext implements AxConceptGetter<ContextAlbum> {
// The key of the currently running Apex model
+ @Getter
private AxArtifactKey key;
// The context albums being used in this engine
key = apexPolicyModel.getKey();
}
- /**
- * Get the key of the internal context, which is the same as the key of the engine.
- *
- * @return the key
- */
- public AxArtifactKey getKey() {
- return key;
- }
-
/**
* Get the context albums of the engine.
*
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2021 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.
- *
+ *
* SPDX-License-Identifier: Apache-2.0
* ============LICENSE_END=========================================================
*/
package org.onap.policy.apex.core.engine.engine.impl;
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
+
/**
* Constants for the Apex engine.
*
*/
-public abstract class ApexEngineConstants {
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+public final class ApexEngineConstants {
/**
* The amount of milliseconds to wait for the current Apex engine to timeout on engine stop
* requests. If the timeout is exceeded, the stop aborts.
/** The wait increment (or pause time) when waiting for the Apex engine to stop. */
public static final int APEX_ENGINE_STOP_EXECUTION_WAIT_INCREMENT = 100;
-
- /**
- * Private constructor to prevent subclassing.
- */
- private ApexEngineConstants() {
- // Constructor to avoid subclassing
- }
}
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2019-2020 Nordix Foundation.
* Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
+ * Modifications Copyright (C) 2021 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.
import java.util.Set;
import java.util.TreeMap;
import java.util.TreeSet;
+import lombok.Getter;
import org.onap.policy.apex.context.ContextAlbum;
import org.onap.policy.apex.context.ContextException;
import org.onap.policy.apex.core.engine.context.ApexInternalContext;
private static final String STOP = "stop()<-";
// The artifact key of this engine
+ @Getter
private final AxArtifactKey key;
// The state of this engine
+ @Getter
private AxEngineState state = AxEngineState.STOPPED;
private final Object stateLockObj = new Object();
private final Map<String, EnEventListener> eventListeners = new LinkedHashMap<>();
// The context of this engine
+ @Getter
private ApexInternalContext internalContext = null;
// The state machines
eventListeners.remove(listenerName);
}
- /**
- * {@inheritDoc}.
- */
- @Override
- public AxArtifactKey getKey() {
- return key;
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public final AxEngineState getState() {
- return state;
- }
-
/**
* {@inheritDoc}.
*/
return currentContext;
}
- /**
- * Get the internal context for the Apex engine.
- *
- * @return The Apex Internal Context
- */
- public ApexInternalContext getInternalContext() {
- return internalContext;
- }
-
/**
* Create an exception event from the incoming event including the exception information on the event.
*
import java.util.Properties;
import java.util.Random;
import java.util.Set;
+import lombok.AccessLevel;
+import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import org.onap.policy.apex.core.engine.monitoring.EventMonitor;
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
+@Getter
+@Setter
+@EqualsAndHashCode(callSuper = true, onlyExplicitlyIncluded = true)
public class EnEvent extends HashMap<String, Object> {
private static final long serialVersionUID = 6311863111866294637L;
// Repeasted string constants
private static final String NULL_KEYS_ILLEGAL = "null keys are illegal on method parameter \"key\"";
+ /*
+ * This is not used for encryption/security, thus disabling sonar.
+ */
+ private static Random rand = new Random(System.nanoTime()); // NOSONAR
+
// The definition of this event in the Apex model
+ @Setter(AccessLevel.NONE)
+ @EqualsAndHashCode.Include
private final AxEvent axEvent;
// The event monitor for this event
+ @Getter(AccessLevel.NONE)
private final transient EventMonitor eventMonitor = new EventMonitor();
// The stack of execution of this event, used for monitoring
- @Getter
- @Setter
private AxConcept[] userArtifactStack;
- /*
- * This is not used for encryption/security, thus disabling sonar.
- */
- private static Random rand = new Random(System.nanoTime()); // NOSONAR
-
// An identifier for the current event execution. The default value here will always be a random
- // number, and should
- // be reset
- @Getter
- @Setter
+ // number, and should be reset
private long executionId = rand.nextLong();
// Event related properties used during processing of this event
- @Getter
- @Setter
private Properties executionProperties = new Properties();
// A string holding a message that indicates why processing of this event threw an exception
- @Getter
- @Setter
private String exceptionMessage;
/**
this.axEvent = axEvent;
}
- /**
- * Gets the event definition of this event.
- *
- * @return the event definition
- */
- public AxEvent getAxEvent() {
- return axEvent;
- }
-
/**
* Get the name of the event.
*
return "EnEvent [axEvent=" + axEvent + ", userArtifactStack=" + Arrays.toString(userArtifactStack) + ", map="
+ super.toString() + "]";
}
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = super.hashCode();
- result = prime * result + axEvent.hashCode();
- return result;
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (!super.equals(obj)) {
- return false;
- }
- if (!(obj instanceof EnEvent)) {
- return false;
- }
- EnEvent other = (EnEvent) obj;
- if (axEvent == null) {
- if (other.axEvent != null) {
- return false;
- }
- } else if (!axEvent.equals(other.axEvent)) {
- return false;
- }
- return true;
- }
}
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2021 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.
package org.onap.policy.apex.core.engine.event;
import java.io.Serializable;
+import lombok.Getter;
import org.onap.policy.apex.context.ContextRuntimeException;
import org.onap.policy.apex.context.SchemaHelper;
import org.onap.policy.apex.context.impl.schema.SchemaHelperFactory;
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
+@Getter
public class EnField implements Serializable {
private static final long serialVersionUID = -5713525780081840333L;
}
}
- /**
- * Gets the field definition of this field.
- *
- * @return the field definition
- */
- public AxField getAxField() {
- return axField;
- }
-
- /**
- * Gets the schema helper of this field.
- *
- * @return the schema helper for this field
- */
- public SchemaHelper getSchemaHelper() {
- return schemaHelper;
- }
-
/**
* Get the name of the field.
*
return axField.getKey();
}
- /**
- * Get the value of the field.
- *
- * @return the value
- */
- public Object getValue() {
- return value;
- }
-
/**
* {@inheritDoc}.
*/
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2019-2020 Nordix Foundation.
* Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
+ * Modifications Copyright (C) 2021 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.
import java.util.Map.Entry;
import java.util.Properties;
import java.util.TreeMap;
+import lombok.Getter;
import org.onap.policy.apex.context.ContextException;
import org.onap.policy.apex.core.engine.ExecutorParameters;
import org.onap.policy.apex.core.engine.context.ApexInternalContext;
// Hold the state and context definitions for this state
private AxState axState = null;
+ @Getter
private Executor<?, ?, ?, ?> parent = null;
private ApexInternalContext context = null;
return axState.getKey();
}
- /**
- * {@inheritDoc}.
- */
- @Override
- public Executor<?, ?, ?, ?> getParent() {
- return parent;
- }
-
/**
* {@inheritDoc}.
*/
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 2021 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.
import java.util.Map;
import java.util.Properties;
+import lombok.AccessLevel;
+import lombok.Getter;
import lombok.NonNull;
import org.onap.policy.apex.context.ContextException;
import org.onap.policy.apex.core.engine.ExecutorParameters;
private static final String EXECUTE_POST_SFL = "execute-post: state finalizer logic \"";
// Hold the state and context definitions
+ @Getter
private Executor<?, ?, ?, ?> parent = null;
private AxState axState = null;
private AxStateFinalizerLogic finalizerLogic = null;
// The execution context; contains the facades for events and context to be used by tasks
// executed by this task
// executor
+ @Getter(AccessLevel.PROTECTED)
private StateFinalizerExecutionContext executionContext = null;
- /**
- * Gets the execution internalContext.
- *
- * @return the execution context
- */
- protected StateFinalizerExecutionContext getExecutionContext() {
- return executionContext;
- }
-
/**
* {@inheritDoc}.
*/
return finalizerLogic.getKey();
}
- /**
- * {@inheritDoc}.
- */
- @Override
- public Executor<?, ?, ?, ?> getParent() {
- return parent;
- }
-
/**
* {@inheritDoc}.
*/
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2019 Nordix Foundation.
* Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
+ * Modifications Copyright (C) 2021 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.
import java.util.Map;
import java.util.Properties;
import java.util.TreeMap;
+import lombok.Getter;
import org.onap.policy.apex.context.ContextException;
import org.onap.policy.apex.core.engine.ExecutorParameters;
import org.onap.policy.apex.core.engine.context.ApexInternalContext;
public class StateMachineExecutor implements Executor<EnEvent, Collection<EnEvent>, AxPolicy, ApexInternalContext> {
// The Apex Policy and context for this state machine
private AxPolicy axPolicy = null;
+ @Getter
private Executor<?, ?, ?, ?> parent = null;
private ApexInternalContext internalContext = null;
return axPolicy.getKey();
}
- /**
- * {@inheritDoc}.
- */
- @Override
- public final Executor<?, ?, ?, ?> getParent() {
- return parent;
- }
-
/**
* {@inheritDoc}.
*/
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2019-2020 Nordix Foundation.
* Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
+ * Modifications Copyright (C) 2021 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.
private static final XLogger LOGGER = XLoggerFactory.getXLogger(TaskExecutor.class);
// Hold the task and context definitions for this task
+ @Getter
private Executor<?, ?, ?, ?> parent = null;
private AxTask axTask = null;
private ApexInternalContext internalContext = null;
return axTask.getKey();
}
- /**
- * {@inheritDoc}.
- */
- @Override
- public Executor<?, ?, ?, ?> getParent() {
- return parent;
- }
-
/**
* {@inheritDoc}.
*/
import java.util.Properties;
import lombok.Getter;
+import lombok.RequiredArgsConstructor;
import lombok.Setter;
import org.onap.policy.apex.context.SchemaHelper;
import org.onap.policy.common.utils.coder.CoderException;
* policy, global, and external context.
*/
@Getter
+@RequiredArgsConstructor
public class AbstractExecutionContext {
/** A constant <code>boolean true</code> value available for reuse e.g., for the return value */
public static final Boolean IS_TRUE = true;
*/
public static final Boolean IS_FALSE = false;
- /** the execution ID for the current APEX policy execution instance. */
- public final Long executionId;
-
// Standard coder for JSON converts
private static final StandardCoder STANDARD_CODER = new StandardCoder();
+ /** the execution ID for the current APEX policy execution instance. */
+ public final Long executionId;
+
// A message specified in the logic
@Setter
private String message;
// Execution properties for a policy execution
private final Properties executionProperties;
- /**
- * Instantiates a new task execution context.
- *
- * @param executionId the execution ID for the current APEX policy execution instance
- * @param executionProperties the execution properties for task execution
- */
- public AbstractExecutionContext(final long executionId, final Properties executionProperties) {
-
- // Execution ID is the current policy execution instance
- this.executionId = executionId;
- this.executionProperties = executionProperties;
- }
-
/**
* Get a JSON representation of an object.
*
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2021 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.
import java.util.Collections;
import java.util.List;
import java.util.Set;
+import lombok.AllArgsConstructor;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
import org.onap.policy.apex.model.basicmodel.service.ModelService;
import org.onap.policy.apex.model.policymodel.concepts.AxState;
*
* @author Sven van der Meer (sven.van.der.meer@ericsson.com)
*/
+@AllArgsConstructor
public class AxStateFacade {
// CHECKSTYLE:OFF: checkstyle:visibilityModifier Logic has access to this field
// CHECKSTYLE:ON: checkstyle:visibilityModifier
- /**
- * Instantiates a new AxState facade.
- *
- * @param state the state for which a facade is being presented
- */
- public AxStateFacade(final AxState state) {
- this.state = state;
- }
-
/**
* Gets the default task key of the state.
*
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
+ * Modifications Copyright (C) 2021 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.
package org.onap.policy.apex.core.engine.executor.context;
+import lombok.AllArgsConstructor;
import org.onap.policy.apex.context.SchemaHelper;
import org.onap.policy.apex.context.impl.schema.SchemaHelperFactory;
import org.onap.policy.apex.core.engine.event.EnException;
*
* @author Sven van der Meer (sven.van.der.meer@ericsson.com)
*/
+@AllArgsConstructor
public class AxTaskFacade {
// Logger for this class
private static final XLogger LOGGER = XLoggerFactory.getXLogger(AxTaskFacade.class);
// CHECKSTYLE:ON: checkstyle:visibilityModifier
- /**
- * Instantiates a new AxTask facade.
- *
- * @param task the task for which a facade is being presented
- */
- public AxTaskFacade(final AxTask task) {
- this.task = task;
- }
-
/**
* Gets the name of the task.
*
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2020-2021 Nordix Foundation.
+ * Modifications Copyright (C) 2021 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.
import java.util.Set;
import java.util.TreeMap;
import lombok.Getter;
+import lombok.Setter;
import org.onap.policy.apex.context.ContextAlbum;
import org.onap.policy.apex.context.ContextRuntimeException;
import org.onap.policy.apex.core.engine.context.ApexInternalContext;
* The state output that the state finalizer logic has selected for a state. The state finalizer logic sets this
* field in its logic after executing and the Apex engine uses this state output for this state.
*/
+ @Getter
+ @Setter
private String selectedStateOutputName;
/**
+ "\" on state \"" + subject.getId() + "\"");
}
}
-
- /**
- * Return the state output name selected by the state finalizer logic.
- *
- * @return the state output name
- */
- public String getSelectedStateOutputName() {
- return selectedStateOutputName;
- }
-
- /**
- * Set the state output name selected by the state finalizer logic.
- *
- * @param selectedStateOutputName the state output name
- */
- public void setSelectedStateOutputName(final String selectedStateOutputName) {
- this.selectedStateOutputName = selectedStateOutputName;
- }
}
import java.util.TreeSet;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-public abstract class ClassUtils {
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
+public final class ClassUtils {
// Get a reference to the logger
private static final XLogger LOGGER = XLoggerFactory.getXLogger(ClassUtils.class);
// Token for library fragment in path
private static final String LIBRARAY_PATH_TOKEN = "/lib";
- /**
- * Private constructor used to prevent sub class instantiation.
- */
- private ClassUtils() {
- // Private constructor to block subclassing
- }
-
/**
* Get the class names of all classes on the class path. WARNING: This is a heavy call, use sparingly
*
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2021 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.
package org.onap.policy.apex.core.infrastructure.java.compile.singleclass;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
/**
* The Class SingleClassLoader is responsible for class loading the single Java class being held in memory.
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
+@Getter
+@AllArgsConstructor
public class SingleClassLoader extends ClassLoader {
// The byte code of the class held in memory as byte code in a ByteCodeFileObject
- private final SingleClassByteCodeFileObject byteCodeFileObject;
-
- /**
- * Instantiates a new single class loader to load the byte code of the class that is being held in memory.
- *
- * @param byteCodeFileObject the byte code of the class
- */
- public SingleClassLoader(final SingleClassByteCodeFileObject byteCodeFileObject) {
- this.byteCodeFileObject = byteCodeFileObject;
- }
+ private final SingleClassByteCodeFileObject fileObject;
/**
* {@inheritDoc}.
protected Class<?> findClass(final String className) throws ClassNotFoundException {
// Creates a java Class that can be instantiated from the class defined in the byte code in the
// ByteCodeFileObejct
- return defineClass(className, byteCodeFileObject.getByteCode(), 0, byteCodeFileObject.getByteCode().length);
- }
-
- /**
- * Gets the file object.
- *
- * @return the file object
- */
- SingleClassByteCodeFileObject getFileObject() {
- return byteCodeFileObject;
+ return defineClass(className, fileObject.getByteCode(), 0, fileObject.getByteCode().length);
}
}
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2021 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.
import java.net.InetAddress;
import java.util.ArrayList;
import java.util.List;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.ToString;
import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
* @author Sajeevan Achuthan (sajeevan.achuthan@ericsson.com)
* @param <M> the generic type of message being handled by a message holder instance
*/
+@Getter
+@ToString
+@EqualsAndHashCode
public class MessageHolder<M> implements Serializable {
- private static final int HASH_PRIME = 31;
- private static final int FOUR_BYTES = 32;
// Serial ID
private static final long serialVersionUID = 1235487535388793719L;
private final InetAddress senderHostAddress;
// Sequence of message in the message holder
+ @ToString.Exclude
private final List<M> messages;
/**
creationTime = System.currentTimeMillis();
}
- /**
- * Return the messages in this message holder.
- *
- * @return the messages
- */
- public List<M> getMessages() {
- return messages;
- }
-
/**
* Adds a message to this message holder.
*
LOGGER.warn("duplicate message {} added to message holder", message);
}
}
-
- /**
- * Gets the creation time.
- *
- * @return the creation time
- */
- public long getCreationTime() {
- return creationTime;
- }
-
- /**
- * Gets the sender host address.
- *
- * @return the sender host address
- */
- public InetAddress getSenderHostAddress() {
- return senderHostAddress;
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public String toString() {
- return "ApexCommandProtocol [creationTime=" + creationTime + ", senderHostAddress=" + senderHostAddress + "]";
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public int hashCode() {
- final int prime = HASH_PRIME;
- int result = 1;
- result = prime * result + ((senderHostAddress == null) ? 0 : senderHostAddress.hashCode());
- result = prime * result + ((messages == null) ? 0 : messages.hashCode());
- result = prime * result + (int) (creationTime ^ (creationTime >>> FOUR_BYTES));
- return result;
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public boolean equals(final Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- final MessageHolder<?> other = (MessageHolder<?>) obj;
- if (senderHostAddress == null) {
- if (other.senderHostAddress != null) {
- return false;
- }
- } else if (!senderHostAddress.equals(other.senderHostAddress)) {
- return false;
- }
- if (messages == null) {
- if (other.messages != null) {
- return false;
- }
- } else if (!messages.equals(other.messages)) {
- return false;
- }
- return creationTime == other.creationTime;
- }
}
if (messageHolder != null) {
final List<M> messages = messageHolder.getMessages();
if (messages != null) {
- messageBlockQueue.add(new MessageBlock<>(messages, incomingData.getConn()));
+ messageBlockQueue.add(new MessageBlock<>(messages, incomingData.getWebSocket()));
}
}
} catch (final IOException | ClassNotFoundException e) {
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2021 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.
package org.onap.policy.apex.core.infrastructure.messaging.impl.ws.messageblock;
import java.util.List;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
import org.java_websocket.WebSocket;
/**
* @author Sajeevan Achuthan (sajeevan.achuthan@ericsson.com)
* @param <M> the generic type of message being handled
*/
+@Getter
+@AllArgsConstructor
public final class MessageBlock<M> {
// List of Messages received on a web socket
// The web socket on which the messages are handled
private final WebSocket webSocket;
-
- /**
- * Instantiates a new message block.
- *
- * @param messages the messages in the message block
- * @param webSocket the web socket used to handle the message block
- */
- public MessageBlock(final List<M> messages, final WebSocket webSocket) {
- this.messages = messages;
- this.webSocket = webSocket;
- }
-
- /**
- * Gets the messages.
- *
- * @return the messages
- */
- public List<M> getMessages() {
- return messages;
- }
-
- /**
- * Gets the web socket.
- *
- * @return the web socket
- */
- public WebSocket getConnection() {
- return webSocket;
- }
-
}
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2021 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.
public void post(final RawMessageBlock rawMessageBlock) {
if (rawMessageBlock.getMessage() != null) {
if (LOGGER.isDebugEnabled()) {
- LOGGER.debug("new raw message recieved from {}", rawMessageBlock.getConn() == null ? "server"
- : rawMessageBlock.getConn().getRemoteSocketAddress().getHostName());
+ LOGGER.debug("new raw message recieved from {}", rawMessageBlock.getWebSocket() == null ? "server"
+ : rawMessageBlock.getWebSocket().getRemoteSocketAddress().getHostName());
}
eventBus.post(rawMessageBlock);
}
public void post(final MessageBlock<M> messageBlock) {
if (messageBlock.getMessages() != null) {
if (LOGGER.isDebugEnabled()) {
- LOGGER.debug("new data message recieved from {}", messageBlock.getConnection() == null ? "server"
- : messageBlock.getConnection().getRemoteSocketAddress().getHostName());
+ LOGGER.debug("new data message recieved from {}", messageBlock.getWebSocket() == null ? "server"
+ : messageBlock.getWebSocket().getRemoteSocketAddress().getHostName());
}
eventBus.post(messageBlock);
}
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2021 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.
package org.onap.policy.apex.core.infrastructure.messaging.impl.ws.messageblock;
import java.nio.ByteBuffer;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
import org.java_websocket.WebSocket;
/**
*
* @author Sajeevan Achuthan (sajeevan.achuthan@ericsson.com)
*/
+@Getter
+@AllArgsConstructor
public final class RawMessageBlock {
// The raw message
private final ByteBuffer message;
// The web socket on which the message is handled
private final WebSocket webSocket;
-
- /**
- * Constructor, instantiate the bean.
- *
- * @param message {@link ByteBuffer} message from the web socket
- * @param webSocket {@link WebSocket} the web socket on which the message is handled
- */
- public RawMessageBlock(final ByteBuffer message, final WebSocket webSocket) {
- this.message = message;
- this.webSocket = webSocket;
- }
-
- /**
- * A getter method for message.
- *
- * @return the message
- */
- public ByteBuffer getMessage() {
- return message;
- }
-
- /**
- * A getter method for the web socket.
- *
- * @return the web socket
- */
- public WebSocket getConn() {
- return webSocket;
- }
}
import java.net.Socket;
import java.net.UnknownHostException;
import java.util.Enumeration;
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
*
* @author Sajeevan Achuthan (sajeevan.achuthan@ericsson.com)
*/
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
public final class MessagingUtils {
// The port number of the lowest user port, ports 0-1023 are system ports
private static final int LOWEST_USER_PORT = 1024;
// Logger for this class
private static final XLogger LOGGER = XLoggerFactory.getXLogger(MessagingUtils.class);
- /**
- * Private constructor used to prevent sub class instantiation.
- */
- private MessagingUtils() {
- // Private constructor to block subclassing
- }
-
/**
* This method searches the availability of the port, if the requested port not available, this method will throw an
* exception.
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2021 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.
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.atomic.AtomicInteger;
+import lombok.Getter;
/**
* This class provides a thread factory for use by classes that require thread factories to handle concurrent operation.
private static final AtomicInteger NEXT_POOL_NUMBER = new AtomicInteger();
private final ThreadGroup group;
private final AtomicInteger nextThreadNumber = new AtomicInteger();
+
+ @Getter
private final String name;
+ @Getter
private final long stackSize;
+ @Getter
private final int threadPriority;
/**
}
- /**
- * Gets the name of the thread factory.
- *
- * @return the name
- */
- public String getName() {
- return name;
- }
-
- /**
- * Gets the stack size of the threads created by this thread factory.
- *
- * @return the stack size
- */
- public long getStackSize() {
- return stackSize;
- }
-
- /**
- * Gets the thread priority of the threads created by this thread factory.
- *
- * @return the thread priority
- */
- public int getThreadPriority() {
- return threadPriority;
- }
-
/**
* {@inheritDoc}.
*/
@Override
public String toString() {
- return "ApplicationThreadFactory [nextPollNumber=" + NEXT_POOL_NUMBER + ",nextThreadNumber=" + nextThreadNumber
+ return "ApplicationThreadFactory [nextPoolNumber=" + NEXT_POOL_NUMBER + ",nextThreadNumber=" + nextThreadNumber
+ ", name=" + name + ", stackSize=" + stackSize + ", threadPriority=" + threadPriority + "]";
}
}
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2021 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.
package org.onap.policy.apex.core.infrastructure.threading;
+import lombok.AccessLevel;
+import lombok.NoArgsConstructor;
+
/**
* This class is a helper class for carrying out common threading tasks.
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
public final class ThreadUtilities {
- /**
- * Private constructor to prevent sub-classing of this class.
- */
- private ThreadUtilities() {
- // Private constructor to prevent subclassing
- }
-
/**
* Sleeps for the specified number of milliseconds, hiding interrupt handling.
*
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Modifications Copyright (C) 2021 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.
if (data != null) {
if (logger.isDebugEnabled()) {
logger.debug("{} command recieved from machine {} ", data.getMessages().size(),
- data.getConnection().getRemoteSocketAddress().getHostString());
+ data.getWebSocket().getRemoteSocketAddress().getHostString());
}
onCommand(data);
}
package org.onap.policy.apex.core.protocols;
import java.io.Serializable;
+import lombok.AccessLevel;
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
/**
*
* @author Sajeevan Achuthan (sajeevan.achuthan@ericsson.com)
*/
+@Getter
+@ToString
+@EqualsAndHashCode
public abstract class Message implements Serializable {
- private static final int HASH_PRIME = 31;
// Serialization ID
private static final long serialVersionUID = 2271443377544488309L;
private Action action = null;
// The artifact key of the artifact to which this message is related
+ @Getter(AccessLevel.NONE)
private AxArtifactKey targetKey = null;
// The data of the message
+ @Setter
private String messageData = null;
// The timeout time for replies in milliseconds
+ @Setter
+ @ToString.Exclude
+ @EqualsAndHashCode.Exclude
private int replyTimeout = DEFAULT_REPLY_TIMEOUT;
/**
this.messageData = messageData;
}
- /**
- * Set the message timeout.
- *
- * @param replyTimeout the timeout on reply messages in milliseconds
- */
- public void setReplyTimeout(final int replyTimeout) {
- this.replyTimeout = replyTimeout;
- }
-
- /**
- * Sets the message data.
- *
- * @param messageData the new message data
- */
- public void setMessageData(final String messageData) {
- this.messageData = messageData;
- }
-
/**
* Append to the message data.
*
public final String getTargetName() {
return targetKey.getName();
}
-
- /**
- * Gets the action or message type of this message.
- *
- * @return the action
- */
- public final Action getAction() {
- return action;
- }
-
- /**
- * Gets the message data.
- *
- * @return the message data
- */
- public final String getMessageData() {
- return messageData;
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public boolean equals(final Object object) {
- if (this == object) {
- return true;
- }
- if (object == null || getClass() != object.getClass()) {
- return false;
- }
-
- final Message message = (Message) object;
-
- if (action != null ? !action.equals(message.action) : message.action != null) {
- return false;
- }
- if (targetKey != null ? !targetKey.equals(message.targetKey) : message.targetKey != null) {
- return false;
- }
- return !(messageData != null ? !messageData.equals(message.messageData) : message.messageData != null);
-
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public int hashCode() {
- int result = action != null ? action.hashCode() : 0;
- result = HASH_PRIME * result + (targetKey != null ? targetKey.hashCode() : 0);
- result = HASH_PRIME * result + (messageData != null ? messageData.hashCode() : 0);
- return result;
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public String toString() {
- return "Message [action=" + action + ", targetKey=" + targetKey + ", data=" + messageData + "]";
- }
-
- /**
- * Get the timeout to wait for a reply.
- *
- * @return the timeout in milliseconds
- */
- public int getReplyTimeout() {
- return replyTimeout;
- }
}
* ============LICENSE_START=======================================================
* Copyright (C) 2018 Ericsson. All rights reserved.
* Modifications Copyright (C) 2020 Nordix Foundation.
+ * Modifications Copyright (C) 2021 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.
DummyMessage dummyMessage = new DummyMessage(new DummyAction(null), new AxArtifactKey("Target:0.0.1"));
assertEquals(new DummyAction(null), dummyMessage.getAction());
- assertEquals("Message [action=org.onap.policy.apex.core.protocols.DummyAction@1f, "
- + "targetKey=AxArtifactKey:(name=Target,version=0.0.1), data=null]", dummyMessage.toString());
+ assertEquals("Message(action=org.onap.policy.apex.core.protocols.DummyAction@1f, "
+ + "targetKey=AxArtifactKey:(name=Target,version=0.0.1), messageData=null)", dummyMessage.toString());
dummyMessage.setMessageData("Message Data");
assertEquals("Message Data", dummyMessage.getMessageData());
dummyMessage.setMessageData(null);
assertNotEquals(0, dummyMessage.hashCode());
dummyMessage = new DummyMessage(null, null, null);
- assertEquals(0, dummyMessage.hashCode());
+ assertNotEquals(0, dummyMessage.hashCode());
// disabling sonar because this code tests the equals() method
assertEquals(dummyMessage, dummyMessage); // NOSONAR