summaryrefslogtreecommitdiffstats
path: root/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms
diff options
context:
space:
mode:
authorliamfallon <liam.fallon@ericsson.com>2018-09-13 15:25:32 +0100
committerliamfallon <liam.fallon@ericsson.com>2018-09-13 15:26:47 +0100
commit4cfa2e2d98f6877d54da304ef17f096284430908 (patch)
treec9452d2bf6bb96fae9c1e8e2d8ce8f8d01e69d22 /plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms
parent0e23f7634e1e1fb31454c516974613335fcea1a4 (diff)
Sonar/Checkstyle in service/plugins
Sonar and Checkstyle changes in plugins and services, and knock on changes Issue-ID: POLICY-1034 Change-Id: Iff7df74e54fce2c661dcc2fae75ae93d4cacfe5b Signed-off-by: liamfallon <liam.fallon@ericsson.com>
Diffstat (limited to 'plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms')
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJmsConsumer.java (renamed from plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJMSConsumer.java)12
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJmsProducer.java (renamed from plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJMSProducer.java)65
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/JmsCarrierTechnologyParameters.java (renamed from plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/JMSCarrierTechnologyParameters.java)34
3 files changed, 58 insertions, 53 deletions
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJMSConsumer.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJmsConsumer.java
index 93174b941..de324512b 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJMSConsumer.java
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJmsConsumer.java
@@ -49,12 +49,12 @@ import org.slf4j.LoggerFactory;
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-public class ApexJMSConsumer implements MessageListener, ApexEventConsumer, Runnable {
+public class ApexJmsConsumer implements MessageListener, ApexEventConsumer, Runnable {
// Get a reference to the logger
- private static final Logger LOGGER = LoggerFactory.getLogger(ApexJMSConsumer.class);
+ private static final Logger LOGGER = LoggerFactory.getLogger(ApexJmsConsumer.class);
// The Apex and JMS parameters read from the parameter service
- private JMSCarrierTechnologyParameters jmsConsumerProperties;
+ private JmsCarrierTechnologyParameters jmsConsumerProperties;
// The event receiver that will receive events from this consumer
private ApexEventReceiver eventReceiver;
@@ -83,14 +83,14 @@ public class ApexJMSConsumer implements MessageListener, ApexEventConsumer, Runn
this.name = consumerName;
// Check and get the JMS Properties
- if (!(consumerParameters.getCarrierTechnologyParameters() instanceof JMSCarrierTechnologyParameters)) {
+ if (!(consumerParameters.getCarrierTechnologyParameters() instanceof JmsCarrierTechnologyParameters)) {
final String errorMessage = "specified consumer properties of type \""
+ consumerParameters.getCarrierTechnologyParameters().getClass().getCanonicalName()
+ "\" are not applicable to a JMS consumer";
LOGGER.warn(errorMessage);
throw new ApexEventException(errorMessage);
}
- jmsConsumerProperties = (JMSCarrierTechnologyParameters) consumerParameters.getCarrierTechnologyParameters();
+ jmsConsumerProperties = (JmsCarrierTechnologyParameters) consumerParameters.getCarrierTechnologyParameters();
// Look up the JMS connection factory
InitialContext jmsContext = null;
@@ -212,7 +212,7 @@ public class ApexJMSConsumer implements MessageListener, ApexEventConsumer, Runn
}
/**
- * The helper function to create a message consumer from a given JMS session
+ * The helper function to create a message consumer from a given JMS session.
*
* @param jmsSession a JMS session
*/
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJMSProducer.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJmsProducer.java
index 86e9555f9..7277a7dc3 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJMSProducer.java
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/ApexJmsProducer.java
@@ -47,13 +47,17 @@ import org.slf4j.LoggerFactory;
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-public class ApexJMSProducer implements ApexEventProducer {
-
+public class ApexJmsProducer implements ApexEventProducer {
// Get a reference to the logger
- private static final Logger LOGGER = LoggerFactory.getLogger(ApexJMSProducer.class);
+ private static final Logger LOGGER = LoggerFactory.getLogger(ApexJmsProducer.class);
+
+ // Recurring string constants
+ private static final String COULD_NOT_SEND_PREFIX = "could not send event \"";
+ private static final String FOR_PRODUCER_TAG = "\" for producer (";
+ private static final String JMS_MESSAGE_PRODUCER_TAG = "\" on JMS message producer ";
// The JMS parameters read from the parameter service
- private JMSCarrierTechnologyParameters jmsProducerProperties;
+ private JmsCarrierTechnologyParameters jmsProducerProperties;
// The connection to the JMS server
private Connection connection;
@@ -78,16 +82,17 @@ public class ApexJMSProducer implements ApexEventProducer {
*/
@Override
public void init(final String producerName, final EventHandlerParameters producerParameters)
- throws ApexEventException {
+ throws ApexEventException {
this.name = producerName;
// Check and get the JMS Properties
- if (!(producerParameters.getCarrierTechnologyParameters() instanceof JMSCarrierTechnologyParameters)) {
- final String errorMessage = "specified producer properties are not applicable to a JMS producer (" + this.name + ")";
+ if (!(producerParameters.getCarrierTechnologyParameters() instanceof JmsCarrierTechnologyParameters)) {
+ final String errorMessage = "specified producer properties are not applicable to a JMS producer ("
+ + this.name + ")";
LOGGER.warn(errorMessage);
throw new ApexEventException(errorMessage);
}
- jmsProducerProperties = (JMSCarrierTechnologyParameters) producerParameters.getCarrierTechnologyParameters();
+ jmsProducerProperties = (JmsCarrierTechnologyParameters) producerParameters.getCarrierTechnologyParameters();
// Look up the JMS connection factory
InitialContext jmsContext = null;
@@ -99,12 +104,12 @@ public class ApexJMSProducer implements ApexEventProducer {
// Check if we actually got a connection factory
if (connectionFactory == null) {
throw new NullPointerException("JMS context lookup of \"" + jmsProducerProperties.getConnectionFactory()
- + "\" returned null for producer (" + this.name + ")");
+ + "\" returned null for producer (" + this.name + ")");
}
} catch (final Exception e) {
final String errorMessage = "lookup of JMS connection factory \""
- + jmsProducerProperties.getConnectionFactory() + "\" failed for JMS producer properties \""
- + jmsProducerProperties.getJmsConsumerProperties() + "\" for producer (" + this.name + ")";
+ + jmsProducerProperties.getConnectionFactory() + "\" failed for JMS producer properties \""
+ + jmsProducerProperties.getJmsConsumerProperties() + FOR_PRODUCER_TAG + this.name + ")";
LOGGER.warn(errorMessage, e);
throw new ApexEventException(errorMessage, e);
}
@@ -117,12 +122,12 @@ public class ApexJMSProducer implements ApexEventProducer {
// Check if we actually got a topic
if (jmsOutgoingTopic == null) {
throw new NullPointerException("JMS context lookup of \"" + jmsProducerProperties.getProducerTopic()
- + "\" returned null for producer (" + this.name + ")");
+ + "\" returned null for producer (" + this.name + ")");
}
} catch (final Exception e) {
final String errorMessage = "lookup of JMS topic \"" + jmsProducerProperties.getProducerTopic()
- + "\" failed for JMS producer properties \"" + jmsProducerProperties.getJmsProducerProperties()
- + "\" for producer (" + this.name + ")";
+ + "\" failed for JMS producer properties \""
+ + jmsProducerProperties.getJmsProducerProperties() + FOR_PRODUCER_TAG + this.name + ")";
LOGGER.warn(errorMessage, e);
throw new ApexEventException(errorMessage, e);
}
@@ -130,11 +135,11 @@ public class ApexJMSProducer implements ApexEventProducer {
// Create and start a connection to the JMS server
try {
connection = connectionFactory.createConnection(jmsProducerProperties.getSecurityPrincipal(),
- jmsProducerProperties.getSecurityCredentials());
+ jmsProducerProperties.getSecurityCredentials());
connection.start();
} catch (final Exception e) {
final String errorMessage = "connection to JMS server failed for JMS properties \""
- + jmsProducerProperties.getJmsConsumerProperties() + "\" for producer (" + this.name + ")";
+ + jmsProducerProperties.getJmsConsumerProperties() + FOR_PRODUCER_TAG + this.name + ")";
LOGGER.warn(errorMessage, e);
throw new ApexEventException(errorMessage, e);
}
@@ -144,7 +149,7 @@ public class ApexJMSProducer implements ApexEventProducer {
jmsSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
} catch (final Exception e) {
final String errorMessage = "creation of session to JMS server failed for JMS properties \""
- + jmsProducerProperties.getJmsConsumerProperties() + "\" for producer (" + this.name + ")";
+ + jmsProducerProperties.getJmsConsumerProperties() + FOR_PRODUCER_TAG + this.name + ")";
LOGGER.warn(errorMessage, e);
throw new ApexEventException(errorMessage, e);
}
@@ -153,8 +158,8 @@ public class ApexJMSProducer implements ApexEventProducer {
try {
messageProducer = jmsSession.createProducer(jmsOutgoingTopic);
} catch (final Exception e) {
- final String errorMessage =
- "creation of producer for sending events to JMS server failed for JMS properties \""
+ final String errorMessage = "creation of producer for sending events "
+ + "to JMS server failed for JMS properties \""
+ jmsProducerProperties.getJmsConsumerProperties() + "\"";
LOGGER.warn(errorMessage, e);
throw new ApexEventException(errorMessage, e);
@@ -202,17 +207,17 @@ public class ApexJMSProducer implements ApexEventProducer {
@Override
public void sendEvent(final long executionId, final String eventname, final Object eventObject) {
// Check if this is a synchronized event, if so we have received a reply
- final SynchronousEventCache synchronousEventCache =
- (SynchronousEventCache) peerReferenceMap.get(EventHandlerPeeredMode.SYNCHRONOUS);
+ final SynchronousEventCache synchronousEventCache = (SynchronousEventCache) peerReferenceMap
+ .get(EventHandlerPeeredMode.SYNCHRONOUS);
if (synchronousEventCache != null) {
synchronousEventCache.removeCachedEventToApexIfExists(executionId);
}
// Check if the object to be sent is serializable
if (!Serializable.class.isAssignableFrom(eventObject.getClass())) {
- final String errorMessage = "could not send event \"" + eventname + "\" on JMS message producer "
- + this.name + ", object of type \"" + eventObject.getClass().getCanonicalName()
- + "\" is not serializable";
+ final String errorMessage = COULD_NOT_SEND_PREFIX + eventname + JMS_MESSAGE_PRODUCER_TAG + this.name
+ + ", object of type \"" + eventObject.getClass().getCanonicalName()
+ + "\" is not serializable";
LOGGER.warn(errorMessage);
throw new ApexEventRuntimeException(errorMessage);
}
@@ -226,8 +231,8 @@ public class ApexJMSProducer implements ApexEventProducer {
try {
jmsMessage = jmsSession.createObjectMessage((Serializable) eventObject);
} catch (final Exception e) {
- final String errorMessage = "could not send event \"" + eventname + "\" on JMS message producer "
- + this.name + ", could not create JMS Object Message for object \"" + eventObject;
+ final String errorMessage = COULD_NOT_SEND_PREFIX + eventname + JMS_MESSAGE_PRODUCER_TAG
+ + this.name + ", could not create JMS Object Message for object \"" + eventObject;
LOGGER.warn(errorMessage);
throw new ApexEventRuntimeException(errorMessage);
}
@@ -236,8 +241,8 @@ public class ApexJMSProducer implements ApexEventProducer {
try {
jmsMessage = jmsSession.createTextMessage(eventObject.toString());
} catch (final Exception e) {
- final String errorMessage = "could not send event \"" + eventname + "\" on JMS message producer "
- + this.name + ", could not create JMS Text Message for object \"" + eventObject;
+ final String errorMessage = COULD_NOT_SEND_PREFIX + eventname + JMS_MESSAGE_PRODUCER_TAG
+ + this.name + ", could not create JMS Text Message for object \"" + eventObject;
LOGGER.warn(errorMessage);
throw new ApexEventRuntimeException(errorMessage);
}
@@ -246,8 +251,8 @@ public class ApexJMSProducer implements ApexEventProducer {
try {
messageProducer.send(jmsMessage);
} catch (final Exception e) {
- final String errorMessage = "could not send event \"" + eventname + "\" on JMS message producer "
- + this.name + ", send failed for object \"" + eventObject;
+ final String errorMessage = COULD_NOT_SEND_PREFIX + eventname + JMS_MESSAGE_PRODUCER_TAG + this.name
+ + ", send failed for object \"" + eventObject;
LOGGER.warn(errorMessage);
throw new ApexEventRuntimeException(errorMessage);
}
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/JMSCarrierTechnologyParameters.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/JmsCarrierTechnologyParameters.java
index 80977b5d8..8b120ca3a 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/JMSCarrierTechnologyParameters.java
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main/java/org/onap/policy/apex/plugins/event/carrier/jms/JmsCarrierTechnologyParameters.java
@@ -30,8 +30,8 @@ import org.onap.policy.common.parameters.ValidationStatus;
/**
* Apex parameters for JMS as an event carrier technology.
- * <p>
- * The parameters for this plugin are:
+ *
+ * <p>The parameters for this plugin are:
* <ol>
* <li>initialContextFactory: JMS uses a naming {@link Context} object to look up the locations of JMS servers and JMS
* topics. An Initial Context Factory is used to when creating a {@link Context} object that can be used for JMS
@@ -69,28 +69,28 @@ import org.onap.policy.common.parameters.ValidationStatus;
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-public class JMSCarrierTechnologyParameters extends CarrierTechnologyParameters {
+public class JmsCarrierTechnologyParameters extends CarrierTechnologyParameters {
/** The label of this carrier technology. */
public static final String JMS_CARRIER_TECHNOLOGY_LABEL = "JMS";
/** The producer plugin class for the JMS carrier technology. */
- public static final String JMS_EVENT_PRODUCER_PLUGIN_CLASS = ApexJMSProducer.class.getCanonicalName();
+ public static final String JMS_EVENT_PRODUCER_PLUGIN_CLASS = ApexJmsProducer.class.getCanonicalName();
/** The consumer plugin class for the JMS carrier technology. */
- public static final String JMS_EVENT_CONSUMER_PLUGIN_CLASS = ApexJMSConsumer.class.getCanonicalName();
+ public static final String JMS_EVENT_CONSUMER_PLUGIN_CLASS = ApexJmsConsumer.class.getCanonicalName();
// @formatter:off
// Default parameter values
- private static final String DEFAULT_CONNECTION_FACTORY = "jms/RemoteConnectionFactory";
- private static final String DEFAULT_INITIAL_CONTEXT_FACTORY = "org.jboss.naming.remote.client.InitialContextFactory";
- private static final String DEFAULT_PROVIDER_URL = "remote://localhost:4447";
- private static final String DEFAULT_SECURITY_PRINCIPAL = "userid";
- private static final String DEFAULT_SECURITY_CREDENTIALS = "password";
- private static final String DEFAULT_CONSUMER_TOPIC = "apex-in";
- private static final String DEFAULT_PRODUCER_TOPIC = "apex-out";
- private static final int DEFAULT_CONSUMER_WAIT_TIME = 100;
- private static final boolean DEFAULT_TO_OBJECT_MESSAGE_SENDING = true;
+ private static final String DEFAULT_CONNECTION_FACTORY = "jms/RemoteConnectionFactory";
+ private static final String DEFAULT_INITIAL_CTXT_FACTORY = "org.jboss.naming.remote.client.InitialContextFactory";
+ private static final String DEFAULT_PROVIDER_URL = "remote://localhost:4447";
+ private static final String DEFAULT_SECURITY_PRINCIPAL = "userid";
+ private static final String DEFAULT_SECURITY_CREDENTIALS = "password";
+ private static final String DEFAULT_CONSUMER_TOPIC = "apex-in";
+ private static final String DEFAULT_PRODUCER_TOPIC = "apex-out";
+ private static final int DEFAULT_CONSUMER_WAIT_TIME = 100;
+ private static final boolean DEFAULT_TO_OBJECT_MSG_SENDING = true;
// Parameter property map tokens
private static final String PROPERTY_INITIAL_CONTEXT_FACTORY = Context.INITIAL_CONTEXT_FACTORY;
@@ -100,21 +100,21 @@ public class JMSCarrierTechnologyParameters extends CarrierTechnologyParameters
// JMS carrier parameters
private String connectionFactory = DEFAULT_CONNECTION_FACTORY;
- private String initialContextFactory = DEFAULT_INITIAL_CONTEXT_FACTORY;
+ private String initialContextFactory = DEFAULT_INITIAL_CTXT_FACTORY;
private String providerUrl = DEFAULT_PROVIDER_URL;
private String securityPrincipal = DEFAULT_SECURITY_PRINCIPAL;
private String securityCredentials = DEFAULT_SECURITY_CREDENTIALS;
private String producerTopic = DEFAULT_PRODUCER_TOPIC;
private String consumerTopic = DEFAULT_CONSUMER_TOPIC;
private int consumerWaitTime = DEFAULT_CONSUMER_WAIT_TIME;
- private boolean objectMessageSending = DEFAULT_TO_OBJECT_MESSAGE_SENDING;
+ private boolean objectMessageSending = DEFAULT_TO_OBJECT_MSG_SENDING;
// @formatter:on
/**
* Constructor to create a jms carrier technology parameters instance and register the instance with the parameter
* service.
*/
- public JMSCarrierTechnologyParameters() {
+ public JmsCarrierTechnologyParameters() {
super();
// Set the carrier technology properties for the JMS carrier technology