From 4f0e4e0acb23479d705747cf6015d4d820659c78 Mon Sep 17 00:00:00 2001 From: Dinh Danh Le Date: Thu, 9 Aug 2018 10:51:44 +0100 Subject: Checkstyle the services-engine package Change-Id: I0d7fd6f867ba280953eb4fd0dc2a5ad1779fb045 Signed-off-by: Dinh Danh Le Issue-ID: POLICY-1034 --- .../engine/engdep/EngDepMessageListener.java | 4 +- .../apex/service/engine/event/ApexEvent.java | 72 +++++++++++++--------- .../service/engine/event/ApexEventException.java | 6 +- .../engine/event/ApexEventRuntimeException.java | 6 +- .../apex/service/engine/event/PeeredReference.java | 5 +- .../engine/event/SynchronousEventCache.java | 48 +++++++++------ .../eventrequestor/EventRequestorConsumer.java | 4 +- .../eventrequestor/EventRequestorProducer.java | 2 +- .../FILECarrierTechnologyParameters.java | 7 +-- .../Apex2JSONEventConverter.java | 20 +++--- .../JSONEventProtocolParameters.java | 2 +- .../engine/main/ApexActivatorException.java | 6 +- .../engine/main/ApexActivatorRuntimeException.java | 6 +- .../engine/main/ApexCommandLineArguments.java | 6 +- .../apex/service/engine/runtime/EngineService.java | 16 ++--- .../engine/runtime/impl/EngineServiceImpl.java | 4 +- .../service/engine/runtime/impl/EngineWorker.java | 2 +- .../service/parameters/ApexParameterException.java | 6 +- .../service/parameters/ApexParameterHandler.java | 9 ++- .../parameters/ApexParameterRuntimeException.java | 6 +- .../apex/service/parameters/ApexParameters.java | 10 +-- .../CarrierTechnologyParameters.java | 4 +- .../CarrierTechnologyParametersJSONAdapter.java | 1 + .../engineservice/EngineServiceParameters.java | 3 +- .../eventhandler/EventHandlerParameters.java | 8 +-- .../eventhandler/EventHandlerPeeredMode.java | 3 +- .../eventprotocol/EventProtocolParameters.java | 3 +- .../EventProtocolParametersJSONAdapter.java | 1 + .../EventProtocolTextCharDelimitedParameters.java | 3 +- .../EventProtocolTextTokenDelimitedParameters.java | 7 +-- 30 files changed, 154 insertions(+), 126 deletions(-) (limited to 'services/services-engine/src/main') diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/engdep/EngDepMessageListener.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/engdep/EngDepMessageListener.java index 5c757c6d9..1bc88a409 100644 --- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/engdep/EngDepMessageListener.java +++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/engdep/EngDepMessageListener.java @@ -57,8 +57,8 @@ import com.google.common.eventbus.Subscribe; * processing a engDepMessage event implements this interface, and the object created with that * class is registered with a component using the component's addEngDepMessageListener * method. When the engDepMessage event occurs, that object's appropriate method is invoked. - * - * This class uses a queue to buffer incoming messages. When the listener is called, it places the + * + *

This class uses a queue to buffer incoming messages. When the listener is called, it places the * incoming message on the queue. A thread runs which removes the messages from the queue and * forwards them to the Apex engine. * diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/ApexEvent.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/ApexEvent.java index 99728c02e..38762ea97 100644 --- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/ApexEvent.java +++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/ApexEvent.java @@ -30,8 +30,9 @@ import org.slf4j.ext.XLogger; import org.slf4j.ext.XLoggerFactory; /** - * The Class ApexEvent is an event class that external systems use to send events to and receive events from Apex engines. The event itself is a hash map of - * string keys and object values, used to pass data. + * The Class ApexEvent is an event class that external systems use to send events to and receive + * events from Apex engines. The event itself is a hash map of string keys and object values, used + * to pass data. * * @author Liam Fallon (liam.fallon@ericsson.com) */ @@ -43,35 +44,44 @@ public class ApexEvent extends HashMap implements Serializable { // Holds the next identifier for event execution. private static AtomicLong nextExecutionID = new AtomicLong(0L); - /** The name of the Apex event, a mandatory field. All Apex events must have a name so that the event can be looked up in the Apex policy model. */ + /** + * The name of the Apex event, a mandatory field. All Apex events must have a name so that the + * event can be looked up in the Apex policy model. + */ public static final String NAME_HEADER_FIELD = "name"; /** - * The version of the Apex event, an optional field. If a version is specified on an Apex event, the definition of that version of the event is taken from - * the Apex policy model. If no version is specified, the latest version of the event is used. + * The version of the Apex event, an optional field. If a version is specified on an Apex event, + * the definition of that version of the event is taken from the Apex policy model. If no + * version is specified, the latest version of the event is used. */ public static final String VERSION_HEADER_FIELD = "version"; /** - * The name space of the Apex event, an optional field. If a name space is specified on an Apex event it must match the name space on the event definition - * taken from the Apex policy model. If no name space is specified, the name space from the event definition in the Apex policy model is used. + * The name space of the Apex event, an optional field. If a name space is specified on an Apex + * event it must match the name space on the event definition taken from the Apex policy model. + * If no name space is specified, the name space from the event definition in the Apex policy + * model is used. */ public static final String NAMESPACE_HEADER_FIELD = "nameSpace"; /** - * The source of the Apex event, an optional field. It specifies where the Apex event has come from and its use is reserved for now. If no source is - * specified, the source from the event definition in the Apex policy model is used. + * The source of the Apex event, an optional field. It specifies where the Apex event has come + * from and its use is reserved for now. If no source is specified, the source from the event + * definition in the Apex policy model is used. */ public static final String SOURCE_HEADER_FIELD = "source"; /** - * The target of the Apex event, an optional field. It specifies where the Apex event is going to and its use is reserved for now. If no target is - * specified, the target from the event definition in the Apex policy model is used. + * The target of the Apex event, an optional field. It specifies where the Apex event is going + * to and its use is reserved for now. If no target is specified, the target from the event + * definition in the Apex policy model is used. */ public static final String TARGET_HEADER_FIELD = "target"; /** - * The exception message field of an Apex event is an exception message indicating that an event failed. + * The exception message field of an Apex event is an exception message indicating that an event + * failed. */ public static final String EXCEPTION_MESSAGE_HEADER_FIELD = "exceptionMessage"; @@ -99,14 +109,16 @@ public class ApexEvent extends HashMap implements Serializable { private final String target; // @formatter:on - // An identifier for the current event execution. The default value here will always be unique in a single JVM + // An identifier for the current event execution. The default value here will always be unique + // in a single JVM private long executionID = ApexEvent.getNextExecutionID(); // A string holding a message that indicates why processing of this event threw an exception private String exceptionMessage; /** - * Private utility to get the next candidate value for a Execution ID. This value will always be unique in a single JVM + * Private utility to get the next candidate value for a Execution ID. This value will always be + * unique in a single JVM * * @return the next candidate value for a Execution ID */ @@ -124,7 +136,8 @@ public class ApexEvent extends HashMap implements Serializable { * @param target the target of the event * @throws ApexEventException thrown on validation errors on event names and versions */ - public ApexEvent(final String name, final String version, final String nameSpace, final String source, final String target) throws ApexEventException { + public ApexEvent(final String name, final String version, final String nameSpace, final String source, + final String target) throws ApexEventException { // @formatter:off this.name = validateField("name", name, NAME_REGEXP); this.version = validateField("version", version, VERSION_REGEXP); @@ -143,13 +156,15 @@ public class ApexEvent extends HashMap implements Serializable { * @return the validated field value * @throws ApexEventException thrown if the field is invalid */ - private String validateField(final String fieldName, final String fieldValue, final String fieldRegexp) throws ApexEventException { + private String validateField(final String fieldName, final String fieldValue, final String fieldRegexp) + throws ApexEventException { if (fieldValue.matches(fieldRegexp)) { return fieldValue; - } - else { - LOGGER.warn("event \"" + name + ": field \"" + fieldName + "=" + fieldValue + "\" is illegal. It doesn't match regex '" + fieldRegexp + "'"); - throw new ApexEventException("event \"" + name + ": field \"" + fieldName + "=" + fieldValue + "\" is illegal"); + } else { + LOGGER.warn("event \"" + name + ": field \"" + fieldName + "=" + fieldValue + + "\" is illegal. It doesn't match regex '" + fieldRegexp + "'"); + throw new ApexEventException( + "event \"" + name + ": field \"" + fieldName + "=" + fieldValue + "\" is illegal"); } } @@ -163,8 +178,7 @@ public class ApexEvent extends HashMap implements Serializable { private String validKey(final String key) throws ApexEventException { if (key.matches(AxReferenceKey.LOCAL_NAME_REGEXP)) { return key; - } - else { + } else { LOGGER.warn("event \"" + name + ": key \"" + key + "\" is illegal"); throw new ApexEventException("event \"" + name + ": key \"" + key + "\" is illegal"); } @@ -225,8 +239,9 @@ public class ApexEvent extends HashMap implements Serializable { } /** - * Sets the pass-thru executionID for this event. The default value for executionID will be be unique in the current JVM. For some applications/deployments - * this executionID may need to globally unique + * Sets the pass-thru executionID for this event. The default value for executionID will be be + * unique in the current JVM. For some applications/deployments this executionID may need to + * globally unique * * @param executionID the executionID */ @@ -266,8 +281,7 @@ public class ApexEvent extends HashMap implements Serializable { // Check if the key is valid try { return super.put(validKey(key), value); - } - catch (final ApexEventException e) { + } catch (final ApexEventException e) { return null; } } @@ -284,8 +298,7 @@ public class ApexEvent extends HashMap implements Serializable { for (final String key : incomingMap.keySet()) { validKey(key); } - } - catch (final ApexEventException e) { + } catch (final ApexEventException e) { // One of the keys is invalid return; } @@ -327,8 +340,7 @@ public class ApexEvent extends HashMap implements Serializable { for (final Map.Entry dataEntry : this.entrySet()) { if (firstData) { firstData = false; - } - else { + } else { builder.append(','); } diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/ApexEventException.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/ApexEventException.java index 24f57d741..35e1508cc 100644 --- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/ApexEventException.java +++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/ApexEventException.java @@ -43,9 +43,9 @@ public class ApexEventException extends ApexException { * Instantiates a new apex event exception. * * @param message the message - * @param e the e + * @param ex the exception that caused this exception to be thrown */ - public ApexEventException(final String message, final Exception e) { - super(message, e); + public ApexEventException(final String message, final Exception ex) { + super(message, ex); } } diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/ApexEventRuntimeException.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/ApexEventRuntimeException.java index 1a624face..758a5fbf5 100644 --- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/ApexEventRuntimeException.java +++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/ApexEventRuntimeException.java @@ -43,9 +43,9 @@ public class ApexEventRuntimeException extends ApexRuntimeException { * Instantiates a new apex runtime event exception with a message and a caused by exception. * * @param message the message - * @param e the exception that caused this exception to be thrown + * @param ex the exception that caused this exception to be thrown */ - public ApexEventRuntimeException(final String message, final Exception e) { - super(message, e); + public ApexEventRuntimeException(final String message, final Exception ex) { + super(message, ex); } } diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/PeeredReference.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/PeeredReference.java index 9560a834c..14ca3f0fa 100644 --- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/PeeredReference.java +++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/PeeredReference.java @@ -35,13 +35,14 @@ public class PeeredReference { private final ApexEventProducer peeredProducer; /** - * Create a peered consumer/producer reference + * Create a peered consumer/producer reference. * * @param peeredMode the peered mode for which to return the reference * @param consumer the consumer that is receiving event * @param producer the producer that is sending events */ - public PeeredReference(final EventHandlerPeeredMode peeredMode, final ApexEventConsumer consumer, final ApexEventProducer producer) { + public PeeredReference(final EventHandlerPeeredMode peeredMode, final ApexEventConsumer consumer, + final ApexEventProducer producer) { this.peeredConsumer = consumer; this.peeredProducer = producer; diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/SynchronousEventCache.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/SynchronousEventCache.java index 25f92d843..1830fc0e5 100644 --- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/SynchronousEventCache.java +++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/SynchronousEventCache.java @@ -33,8 +33,9 @@ import org.slf4j.ext.XLogger; import org.slf4j.ext.XLoggerFactory; /** - * This class holds a cache of the synchronous events sent into Apex and that have not yet been replied to. It runs a thread to time out events that have not - * been replied to in the specified timeout. + * This class holds a cache of the synchronous events sent into Apex and that have not yet been + * replied to. It runs a thread to time out events that have not been replied to in the specified + * timeout. * * @author Liam Fallon (liam.fallon@ericsson.com) */ @@ -45,7 +46,8 @@ public class SynchronousEventCache extends PeeredReference implements Runnable { // The default amount of time to wait for a synchronous event to be replied to is 1 second private static final long DEFAULT_SYNCHRONOUS_EVENT_TIMEOUT = 1000; - // The timeout to wait between event polls in milliseconds and the time to wait for the thread to stop + // The timeout to wait between event polls in milliseconds and the time to wait for the thread + // to stop private static final long OUTSTANDING_EVENT_POLL_TIMEOUT = 50; private static final long CACHE_STOP_WAIT_INTERVAL = 10; @@ -56,7 +58,8 @@ public class SynchronousEventCache extends PeeredReference implements Runnable { private final Map> toApexEventMap = new HashMap>(); // Map holding reply events - private final Map> fromApexEventMap = new HashMap>(); + private final Map> fromApexEventMap = + new HashMap>(); // The message listener thread and stopping flag private final Thread synchronousEventCacheThread; @@ -68,15 +71,16 @@ public class SynchronousEventCache extends PeeredReference implements Runnable { * @param peeredMode the peered mode for which to return the reference * @param consumer the consumer that is populating the cache * @param producer the producer that is emptying the cache - * @param synchronousEventTimeout the time in milliseconds to wait for the reply to a sent synchronous event + * @param synchronousEventTimeout the time in milliseconds to wait for the reply to a sent + * synchronous event */ - public SynchronousEventCache(final EventHandlerPeeredMode peeredMode, final ApexEventConsumer consumer, final ApexEventProducer producer, final long synchronousEventTimeout) { - super(peeredMode, consumer, producer); + public SynchronousEventCache(final EventHandlerPeeredMode peeredMode, final ApexEventConsumer consumer, + final ApexEventProducer producer, final long synchronousEventTimeout) { + super(peeredMode, consumer, producer); if (synchronousEventTimeout != 0) { this.synchronousEventTimeout = synchronousEventTimeout; - } - else { + } else { this.synchronousEventTimeout = DEFAULT_SYNCHRONOUS_EVENT_TIMEOUT; } @@ -216,18 +220,21 @@ public class SynchronousEventCache extends PeeredReference implements Runnable { /** * Cache a synchronized event sent in an event cache. + * * @param eventCacheMap the map to cache the event on * @param executionId the execution ID of the event * @param event the event to cache */ - private void cacheSynchronizedEvent(final Map> eventCacheMap, final long executionId, final Object event) { + private void cacheSynchronizedEvent(final Map> eventCacheMap, + final long executionId, final Object event) { LOGGER.entry("Adding event with execution ID: " + executionId); // Check if the event is already in the cache if (eventCacheMap.containsKey(executionId)) { - // If there was no sent event then the event timed out or some unexpected event was received + // If there was no sent event then the event timed out or some unexpected event was + // received final String errorMessage = "an event with ID " + executionId - + " already exists in the synchronous event cache, execution IDs must be unique in the system"; + + " already exists in the synchronous event cache, execution IDs must be unique in the system"; LOGGER.warn(errorMessage); throw new ApexEventRuntimeException(errorMessage); } @@ -249,7 +256,8 @@ public class SynchronousEventCache extends PeeredReference implements Runnable { * @param executionId the execution ID of the event * @return The removed event */ - private Object removeCachedEventIfExists(final Map> eventCacheMap, final long executionId) { + private Object removeCachedEventIfExists(final Map> eventCacheMap, + final long executionId) { LOGGER.entry("Removing: " + executionId); final SimpleEntry removedEventEntry = eventCacheMap.remove(executionId); @@ -257,15 +265,17 @@ public class SynchronousEventCache extends PeeredReference implements Runnable { if (removedEventEntry != null) { LOGGER.exit("Removed: " + executionId); return removedEventEntry.getValue(); - } - else { - // The event may not be one of the events in our cache, so we just ignore removal failures + } else { + // The event may not be one of the events in our cache, so we just ignore removal + // failures return null; } } /** - * Time out events on an event cache map. Events that have a timeout longer than the configured timeout are timed out. + * Time out events on an event cache map. Events that have a timeout longer than the configured + * timeout are timed out. + * * @param eventCacheMap the event cache to operate on */ private void timeoutEventsOnCache(final Map> eventCacheMap) { @@ -287,8 +297,8 @@ public class SynchronousEventCache extends PeeredReference implements Runnable { // Remove the map entry and issue a warning final SimpleEntry timedOutEventEntry = eventCacheMap.remove(timedoutEventExecutionID); - LOGGER.warn("synchronous event timed out, reply not received in " + synchronousEventTimeout + " milliseconds on event " - + timedOutEventEntry.getValue()); + LOGGER.warn("synchronous event timed out, reply not received in " + synchronousEventTimeout + + " milliseconds on event " + timedOutEventEntry.getValue()); } } } diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/eventrequestor/EventRequestorConsumer.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/eventrequestor/EventRequestorConsumer.java index b472cc9c7..8c135f19a 100644 --- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/eventrequestor/EventRequestorConsumer.java +++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/eventrequestor/EventRequestorConsumer.java @@ -98,7 +98,7 @@ public class EventRequestorConsumer implements ApexEventConsumer, Runnable { } /** - * Receive an incoming event send request from the peered event Requestor producer and queue it + * Receive an incoming event send request from the peered event Requestor producer and queue it. * * @param eventObject the incoming event to process * @throws ApexEventRuntimeException on queueing errors @@ -140,7 +140,7 @@ public class EventRequestorConsumer implements ApexEventConsumer, Runnable { } /** - * Get the number of events received to date + * Get the number of events received to date. * * @return the number of events received */ diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/eventrequestor/EventRequestorProducer.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/eventrequestor/EventRequestorProducer.java index 4a972f2ce..fda48e7ca 100644 --- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/eventrequestor/EventRequestorProducer.java +++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/eventrequestor/EventRequestorProducer.java @@ -94,7 +94,7 @@ public class EventRequestorProducer implements ApexEventProducer { } /** - * Get the number of events sent to date + * Get the number of events sent to date. * * @return the number of events received */ diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/filecarrierplugin/FILECarrierTechnologyParameters.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/filecarrierplugin/FILECarrierTechnologyParameters.java index 0081312fe..76f9b4bb3 100644 --- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/filecarrierplugin/FILECarrierTechnologyParameters.java +++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/filecarrierplugin/FILECarrierTechnologyParameters.java @@ -29,8 +29,7 @@ import org.onap.policy.common.utils.resources.ResourceUtils; * This class holds the parameters that allows transport of events into and out of Apex using files * and standard input and output. * - *

- * The following parameters are defined: + *

The following parameters are defined: *

    *
  1. fileName: The full path to the file from which to read events or to which to write events. *
  2. standardIO: If this flag is set to true, then standard input is used to read events in or @@ -149,7 +148,7 @@ public class FILECarrierTechnologyParameters extends CarrierTechnologyParameters } /** - * Gets the delay in milliseconds before the plugin starts processing + * Gets the delay in milliseconds before the plugin starts processing. * * @return the delay */ @@ -158,7 +157,7 @@ public class FILECarrierTechnologyParameters extends CarrierTechnologyParameters } /** - * Sets the delay in milliseconds before the plugin starts processing + * Sets the delay in milliseconds before the plugin starts processing. * * @param startDelay the delay */ diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/jsonprotocolplugin/Apex2JSONEventConverter.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/jsonprotocolplugin/Apex2JSONEventConverter.java index edaf5d5bb..21e4cd122 100644 --- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/jsonprotocolplugin/Apex2JSONEventConverter.java +++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/jsonprotocolplugin/Apex2JSONEventConverter.java @@ -276,11 +276,16 @@ public class Apex2JSONEventConverter implements ApexEventProtocolConverter { throws ApexEventException { // Get the event header fields // @formatter:off - String name = getJSONStringField(jsonObject, ApexEvent.NAME_HEADER_FIELD, jsonPars.getNameAlias(), ApexEvent.NAME_REGEXP, false); - String version = getJSONStringField(jsonObject, ApexEvent.VERSION_HEADER_FIELD, jsonPars.getVersionAlias(), ApexEvent.VERSION_REGEXP, false); - String namespace = getJSONStringField(jsonObject, ApexEvent.NAMESPACE_HEADER_FIELD, jsonPars.getNameSpaceAlias(), ApexEvent.NAMESPACE_REGEXP, false); - String source = getJSONStringField(jsonObject, ApexEvent.SOURCE_HEADER_FIELD, jsonPars.getSourceAlias(), ApexEvent.SOURCE_REGEXP, false); - String target = getJSONStringField(jsonObject, ApexEvent.TARGET_HEADER_FIELD, jsonPars.getTargetAlias(), ApexEvent.TARGET_REGEXP, false); + String name = getJSONStringField(jsonObject, ApexEvent.NAME_HEADER_FIELD, + jsonPars.getNameAlias(), ApexEvent.NAME_REGEXP, false); + String version = getJSONStringField(jsonObject, ApexEvent.VERSION_HEADER_FIELD, + jsonPars.getVersionAlias(), ApexEvent.VERSION_REGEXP, false); + String namespace = getJSONStringField(jsonObject, ApexEvent.NAMESPACE_HEADER_FIELD, + jsonPars.getNameSpaceAlias(), ApexEvent.NAMESPACE_REGEXP, false); + String source = getJSONStringField(jsonObject, ApexEvent.SOURCE_HEADER_FIELD, + jsonPars.getSourceAlias(), ApexEvent.SOURCE_REGEXP, false); + String target = getJSONStringField(jsonObject, ApexEvent.TARGET_HEADER_FIELD, + jsonPars.getTargetAlias(), ApexEvent.TARGET_REGEXP, false); // @formatter:on // Check that an event name has been specified @@ -292,9 +297,8 @@ public class Apex2JSONEventConverter implements ApexEventProtocolConverter { // Check if an event name was specified on the event parameters if (eventName != null) { if (name != null && !eventName.equals(name)) { - LOGGER.warn( - "The incoming event name \"{}\" does not match the configured event name \"{}\", using configured event name", - name, eventName); + LOGGER.warn("The incoming event name \"{}\" does not match the configured event name \"{}\"," + + " using configured event name", name, eventName); } name = eventName; } diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/jsonprotocolplugin/JSONEventProtocolParameters.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/jsonprotocolplugin/JSONEventProtocolParameters.java index 5f2b74204..56eaa4a1e 100644 --- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/jsonprotocolplugin/JSONEventProtocolParameters.java +++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/event/impl/jsonprotocolplugin/JSONEventProtocolParameters.java @@ -25,7 +25,7 @@ import org.onap.policy.apex.service.parameters.eventprotocol.EventProtocolTextCh /** * Event protocol parameters for JSON as an event protocol. * - * The parameters for this plugin are: + *

    The parameters for this plugin are: *

      *
    1. nameAlias: The field in a JSON event to use as an alias for the event name. This parameter is * optional. diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexActivatorException.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexActivatorException.java index 371a3a882..d3387427e 100644 --- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexActivatorException.java +++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexActivatorException.java @@ -43,9 +43,9 @@ public class ApexActivatorException extends ApexException { * Instantiates a new apex activator exception with a message and a caused by exception. * * @param message the message - * @param e the exception that caused this exception to be thrown + * @param ex the exception that caused this exception to be thrown */ - public ApexActivatorException(final String message, final Exception e) { - super(message, e); + public ApexActivatorException(final String message, final Exception ex) { + super(message, ex); } } diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexActivatorRuntimeException.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexActivatorRuntimeException.java index cf1842dbe..083536ffc 100644 --- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexActivatorRuntimeException.java +++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexActivatorRuntimeException.java @@ -44,9 +44,9 @@ public class ApexActivatorRuntimeException extends ApexRuntimeException { * Instantiates a new apex activator exception with a message and a caused by exception. * * @param message the message - * @param e the exception that caused this exception to be thrown + * @param ex the exception that caused this exception to be thrown */ - public ApexActivatorRuntimeException(final String message, final Exception e) { - super(message, e); + public ApexActivatorRuntimeException(final String message, final Exception ex) { + super(message, ex); } } diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexCommandLineArguments.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexCommandLineArguments.java index 374b38482..d6d278ebf 100644 --- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexCommandLineArguments.java +++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexCommandLineArguments.java @@ -71,14 +71,16 @@ public class ApexCommandLineArguments { .build()); options.addOption(Option.builder("c") .longOpt("config-file") - .desc("the full path to the configuration file to use, the configuration file must be a Json file containing the Apex configuration parameters") + .desc("the full path to the configuration file to use, the configuration file must be a Json file " + + "containing the Apex configuration parameters") .hasArg() .argName("CONFIG_FILE") .required(false) .type(String.class) .build()); options.addOption(Option.builder("m").longOpt("model-file") - .desc("the full path to the model file to use, if set it overrides the model file set in the configuration file").hasArg().argName("MODEL_FILE") + .desc("the full path to the model file to use, if set it overrides the model file set in the " + + "configuration file").hasArg().argName("MODEL_FILE") .required(false) .type(String.class).build()); //@formatter:on diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/runtime/EngineService.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/runtime/EngineService.java index e6fc332f2..d64313527 100644 --- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/runtime/EngineService.java +++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/runtime/EngineService.java @@ -139,8 +139,8 @@ public interface EngineService { /** * This method checks if all Apex engines in the engine service are started. - *

      - * Note: an engine can be both not stopped and not started, for example, when it is starting or + * + *

      Note: an engine can be both not stopped and not started, for example, when it is starting or * stopping * * @return true if all Apex engines in the engine service are started. @@ -149,8 +149,8 @@ public interface EngineService { /** * This method checks if an Apex engine in the engine service is started. - *

      - * Note: an engine can be both not stopped and not started, for example, when it is starting or + * + *

      Note: an engine can be both not stopped and not started, for example, when it is starting or * stopping * * @param engineKey The key of the Apex engine to check @@ -160,8 +160,8 @@ public interface EngineService { /** * This method checks if all Apex engines in the engine service are stopped. - *

      - * Note: an engine can be both not stopped and not started, for example, when it is starting or + * + *

      Note: an engine can be both not stopped and not started, for example, when it is starting or * stopping * * @return true if all Apex engines in the engine service are stopped. @@ -170,8 +170,8 @@ public interface EngineService { /** * This method checks if an Apex engine in the engine service is stopped. - *

      - * Note: an engine can be both not stopped and not started, for example, when it is starting or + * + *

      Note: an engine can be both not stopped and not started, for example, when it is starting or * stopping * * @param engineKey The key of the Apex engine to check diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/runtime/impl/EngineServiceImpl.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/runtime/impl/EngineServiceImpl.java index 24d8263f4..2124b3118 100644 --- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/runtime/impl/EngineServiceImpl.java +++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/runtime/impl/EngineServiceImpl.java @@ -79,7 +79,7 @@ public final class EngineServiceImpl implements EngineService, EngineServiceEven private final BlockingQueue queue = new LinkedBlockingQueue<>(); // Thread factory for thread management - private final ApplicationThreadFactory tFactory = new ApplicationThreadFactory("apex-engine-service", 512); + private final ApplicationThreadFactory atFactory = new ApplicationThreadFactory("apex-engine-service", 512); // Periodic event generator and its period in milliseconds private ApexPeriodicEventGenerator periodicEventGenerator = null; @@ -111,7 +111,7 @@ public final class EngineServiceImpl implements EngineService, EngineServiceEven for (int engineCounter = 0; engineCounter < threadCount; engineCounter++) { final AxArtifactKey engineWorkerKey = new AxArtifactKey(engineServiceKey.getName() + '-' + engineCounter, engineServiceKey.getVersion()); - engineWorkerMap.put(engineWorkerKey, new EngineWorker(engineWorkerKey, queue, tFactory)); + engineWorkerMap.put(engineWorkerKey, new EngineWorker(engineWorkerKey, queue, atFactory)); LOGGER.info("Created apex engine {} .", engineWorkerKey.getID()); } diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/runtime/impl/EngineWorker.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/runtime/impl/EngineWorker.java index cd657d8fb..f82aae69b 100644 --- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/runtime/impl/EngineWorker.java +++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/runtime/impl/EngineWorker.java @@ -66,7 +66,7 @@ import com.google.gson.JsonParser; * is triggered by an Apex event, and when the policy is triggered it runs through to completion in * the ApexEngine. * - * This class acts as a container for an {@link ApexEngine}, running it in a thread, sending it + *

      This class acts as a container for an {@link ApexEngine}, running it in a thread, sending it * events, and receiving events from it. * * @author Liam Fallon (liam.fallon@ericsson.com) diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/ApexParameterException.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/ApexParameterException.java index 229250bcf..2bc064593 100644 --- a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/ApexParameterException.java +++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/ApexParameterException.java @@ -44,9 +44,9 @@ public class ApexParameterException extends ApexException { * exception. * * @param message the message - * @param e the exception that caused this exception to be thrown + * @param ex the exception that caused this exception to be thrown */ - public ApexParameterException(final String message, final Exception e) { - super(message, e); + public ApexParameterException(final String message, final Exception ex) { + super(message, ex); } } diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/ApexParameterHandler.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/ApexParameterHandler.java index 79f10bdea..31209bf08 100644 --- a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/ApexParameterHandler.java +++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/ApexParameterHandler.java @@ -58,9 +58,12 @@ public class ApexParameterHandler { // Register the adapters for our carrier technologies and event protocols with GSON // @formatter:off final Gson gson = new GsonBuilder() - .registerTypeAdapter(EngineParameters .class, new EngineServiceParametersJSONAdapter()) - .registerTypeAdapter(CarrierTechnologyParameters.class, new CarrierTechnologyParametersJSONAdapter()) - .registerTypeAdapter(EventProtocolParameters .class, new EventProtocolParametersJSONAdapter()) + .registerTypeAdapter(EngineParameters .class, + new EngineServiceParametersJSONAdapter()) + .registerTypeAdapter(CarrierTechnologyParameters.class, + new CarrierTechnologyParametersJSONAdapter()) + .registerTypeAdapter(EventProtocolParameters .class, + new EventProtocolParametersJSONAdapter()) .create(); // @formatter:on parameters = gson.fromJson(new FileReader(arguments.getFullConfigurationFilePath()), ApexParameters.class); diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/ApexParameterRuntimeException.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/ApexParameterRuntimeException.java index 2334a7e60..a4917f1b6 100644 --- a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/ApexParameterRuntimeException.java +++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/ApexParameterRuntimeException.java @@ -44,9 +44,9 @@ public class ApexParameterRuntimeException extends ApexRuntimeException { * exception. * * @param message the message - * @param e the exception that caused this exception to be thrown + * @param ex the exception that caused this exception to be thrown */ - public ApexParameterRuntimeException(final String message, final Exception e) { - super(message, e); + public ApexParameterRuntimeException(final String message, final Exception ex) { + super(message, ex); } } diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/ApexParameters.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/ApexParameters.java index 52c6f4960..9c65c0b32 100644 --- a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/ApexParameters.java +++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/ApexParameters.java @@ -36,8 +36,8 @@ import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerPeeredMo /** * The main container parameter class for an Apex service. - *

      - * The following parameters are defined: + * + *

      The following parameters are defined: *

        *
      1. engineServiceParameters: The parameters for the Apex engine service itself, such as the * number of engine threads to run and the deployment port number to use. @@ -215,7 +215,7 @@ public class ApexParameters extends AbstractParameters implements ApexParameterV } /** - * Validate parameter values for event handlers in a peered mode + * Validate parameter values for event handlers in a peered mode. * * @param eventHandlerType The event handler type we are checking * @param errorMessageBuilder The builder to which to append any error messages @@ -251,7 +251,7 @@ public class ApexParameters extends AbstractParameters implements ApexParameterV } /** - * This method validates that the settings are valid for the given peered mode + * This method validates that the settings are valid for the given peered mode. * * @param errorMessageBuilder The builder to which to append any error messages * @param peeredMode The peered mode to check @@ -281,7 +281,7 @@ public class ApexParameters extends AbstractParameters implements ApexParameterV } /** - * This method validates that the settings are valid for the event handlers on one + * This method validates that the settings are valid for the event handlers on one. * * @param messagePreamble the preamble for messages indicating the peered mode side * @param errorMessageBuilder The builder to which to append any error messages diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/carriertechnology/CarrierTechnologyParameters.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/carriertechnology/CarrierTechnologyParameters.java index ba0327de1..025183328 100644 --- a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/carriertechnology/CarrierTechnologyParameters.java +++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/carriertechnology/CarrierTechnologyParameters.java @@ -26,8 +26,8 @@ import org.onap.policy.apex.service.parameters.ApexParameterValidator; /** * The default carrier technology parameter class that may be specialized by carrier technology * plugins that require plugin specific parameters. - *

        - * The following parameters are defined: + * + *

        The following parameters are defined: *

          *
        1. label: The label of the carrier technology. *
        2. eventProducerPluginClass: The name of the plugin class that will be used by Apex to produce diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/carriertechnology/CarrierTechnologyParametersJSONAdapter.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/carriertechnology/CarrierTechnologyParametersJSONAdapter.java index e72a283cd..38abd3c6c 100644 --- a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/carriertechnology/CarrierTechnologyParametersJSONAdapter.java +++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/carriertechnology/CarrierTechnologyParametersJSONAdapter.java @@ -55,6 +55,7 @@ public class CarrierTechnologyParametersJSONAdapter // Built in technology parameters private static final Map BUILT_IN_CARRIER_TECHNOLOGY_PARMETER_CLASS_MAP = new HashMap<>(); + static { BUILT_IN_CARRIER_TECHNOLOGY_PARMETER_CLASS_MAP.put("FILE", FILECarrierTechnologyParameters.class.getCanonicalName()); diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/engineservice/EngineServiceParameters.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/engineservice/EngineServiceParameters.java index 1db7aeb2d..3a53b59cb 100644 --- a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/engineservice/EngineServiceParameters.java +++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/engineservice/EngineServiceParameters.java @@ -35,8 +35,7 @@ import org.onap.policy.apex.core.engine.EngineParameters; * This class holds the parameters for an Apex Engine Service with multiple engine threads running * multiple engines. * - *

          - * The following parameters are defined: + *

          The following parameters are defined: *

            *
          1. name: The name of the Apex engine service, which can be set to any value that matches the * regular expression {@link org.onap.policy.apex.model.basicmodel.concepts.AxKey#NAME_REGEXP}. diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/eventhandler/EventHandlerParameters.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/eventhandler/EventHandlerParameters.java index 34589f31b..164544b4e 100644 --- a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/eventhandler/EventHandlerParameters.java +++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/eventhandler/EventHandlerParameters.java @@ -30,12 +30,12 @@ import org.onap.policy.apex.service.parameters.eventprotocol.EventProtocolParame /** * The parameters for a single event producer, event consumer or synchronous event handler. - *

            - * Event producers, consumers, and synchronous event handlers all use a carrier technology and an + * + *

            Event producers, consumers, and synchronous event handlers all use a carrier technology and an * event protocol so the actual parameters for each one are the same. Therefore, we use the same * class for the parameters of each one. - *

            - * The following parameters are defined: + * + *

            The following parameters are defined: *

              *
            1. carrierTechnologyParameters: The carrier technology is the type of messaging infrastructure * used to carry events. Examples are File, Kafka or REST. diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/eventhandler/EventHandlerPeeredMode.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/eventhandler/EventHandlerPeeredMode.java index b7ee667f3..39732f53d 100644 --- a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/eventhandler/EventHandlerPeeredMode.java +++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/eventhandler/EventHandlerPeeredMode.java @@ -23,8 +23,7 @@ package org.onap.policy.apex.service.parameters.eventhandler; /** * This enum specifies the peered mode that an event handler may be in. * - *

              - * The following values are defined: + *

              The following values are defined: *

                *
              1. SYNCHRONOUS: The event handler is tied to another event handler for event handling in APEX, * used for request-response calls where APEX is the receiver. diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/eventprotocol/EventProtocolParameters.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/eventprotocol/EventProtocolParameters.java index 6e66a18e9..66b5c0aae 100644 --- a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/eventprotocol/EventProtocolParameters.java +++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/eventprotocol/EventProtocolParameters.java @@ -27,8 +27,7 @@ import org.onap.policy.apex.service.parameters.ApexParameterValidator; * A default event protocol parameter class that may be specialized by event protocol plugins that * require plugin specific parameters. * - *

                - * The following parameters are defined: + *

                The following parameters are defined: *

                  *
                1. label: The label of the event protocol technology. *
                2. eventProducerPluginClass: The name of the plugin class that will be used by Apex to produce diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/eventprotocol/EventProtocolParametersJSONAdapter.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/eventprotocol/EventProtocolParametersJSONAdapter.java index 1f33db6b8..9d087bf31 100644 --- a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/eventprotocol/EventProtocolParametersJSONAdapter.java +++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/eventprotocol/EventProtocolParametersJSONAdapter.java @@ -56,6 +56,7 @@ public class EventProtocolParametersJSONAdapter // Built in event protocol parameters private static final Map BUILT_IN_EVENT_RPOTOCOL_PARMETER_CLASS_MAP = new HashMap<>(); + static { BUILT_IN_EVENT_RPOTOCOL_PARMETER_CLASS_MAP.put("JSON", JSONEventProtocolParameters.class.getCanonicalName()); BUILT_IN_EVENT_RPOTOCOL_PARMETER_CLASS_MAP.put("APEX", ApexEventProtocolParameters.class.getCanonicalName()); diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/eventprotocol/EventProtocolTextCharDelimitedParameters.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/eventprotocol/EventProtocolTextCharDelimitedParameters.java index f8873ada4..7094a3d3f 100644 --- a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/eventprotocol/EventProtocolTextCharDelimitedParameters.java +++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/eventprotocol/EventProtocolTextCharDelimitedParameters.java @@ -26,8 +26,7 @@ import org.onap.policy.apex.service.parameters.ApexParameterValidator; * An event protocol parameter class for character delimited textual event protocols that may be * specialized by event protocol plugins that require plugin specific parameters. * - *

                  - * The following parameters are defined: + *

                  The following parameters are defined: *

                    *
                  1. startChar: starting character delimiter for text blocks containing an event. *
                  2. endChar: ending character delimiter for text blocks containing an event. diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/eventprotocol/EventProtocolTextTokenDelimitedParameters.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/eventprotocol/EventProtocolTextTokenDelimitedParameters.java index 91a6403df..f71ebc6d8 100644 --- a/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/eventprotocol/EventProtocolTextTokenDelimitedParameters.java +++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/parameters/eventprotocol/EventProtocolTextTokenDelimitedParameters.java @@ -26,8 +26,7 @@ import org.onap.policy.apex.service.parameters.ApexParameterValidator; * An event protocol parameter class for token delimited textual event protocols that may be specialized by event * protocol plugins that require plugin specific parameters. * - *

                    - * The following parameters are defined: + *

                    The following parameters are defined: *

                      *
                    1. startDelimiterToken: the token string that delimits the start of text blocks that contain events. *
                    2. endDelimiterToken: the token string that delimits the end of text blocks that contain events, this parameter is @@ -95,7 +94,7 @@ public abstract class EventProtocolTextTokenDelimitedParameters extends EventPro } /** - * Does there have to be a delimiter at the start of the first text block? + * Check if there must be a delimiter at the start of the first text block. * * @return true if there must be a delimiter at the start of the text block */ @@ -104,7 +103,7 @@ public abstract class EventProtocolTextTokenDelimitedParameters extends EventPro } /** - * Sets if there has to be a delimiter at the start of the first text block? + * Sets if there has to be a delimiter at the start of the first text block. * * @param delimiterAtStart * true if there must be a delimiter at the start of the text block -- cgit 1.2.3-korg