summaryrefslogtreecommitdiffstats
path: root/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main
diff options
context:
space:
mode:
authorshaoqiu <tim.huang@est.tech>2020-02-20 12:28:25 +0800
committershaoqiu <tim.huang@est.tech>2020-02-21 09:21:53 +0800
commited3c65efa81f5eb1c9271ab05a340ea9f8ee34e7 (patch)
treeeed3ee7c5c24afe8490d62cc2a9d4fc3c0765981 /plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main
parent8d22852d50a9b76dd05f68fef2717bb37f3b5bc6 (diff)
remove code duplication in plugins
Remove consumer code duplication in plugins-event-carrier Issue-ID: POLICY-1884 Signed-off-by: shaoqiu <tim.huang@est.tech> Change-Id: I2d222436a97224e54a03c2501f4dc14d3f5f6ac0
Diffstat (limited to 'plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-jms/src/main')
-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.java57
1 files changed, 3 insertions, 54 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 cbabab3b8..ff300423f 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
@@ -1,7 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
- * Modifications Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 2019-2020 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,8 +21,6 @@
package org.onap.policy.apex.plugins.event.carrier.jms;
-import java.util.EnumMap;
-import java.util.Map;
import java.util.Properties;
import javax.jms.Connection;
@@ -34,15 +32,12 @@ import javax.jms.Session;
import javax.jms.Topic;
import javax.naming.InitialContext;
-import org.onap.policy.apex.core.infrastructure.threading.ApplicationThreadFactory;
import org.onap.policy.apex.core.infrastructure.threading.ThreadUtilities;
-import org.onap.policy.apex.service.engine.event.ApexEventConsumer;
import org.onap.policy.apex.service.engine.event.ApexEventException;
import org.onap.policy.apex.service.engine.event.ApexEventReceiver;
import org.onap.policy.apex.service.engine.event.ApexEventRuntimeException;
-import org.onap.policy.apex.service.engine.event.PeeredReference;
+import org.onap.policy.apex.service.engine.event.ApexPluginsEventConsumer;
import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters;
-import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerPeeredMode;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -51,7 +46,7 @@ import org.slf4j.LoggerFactory;
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-public class ApexJmsConsumer implements MessageListener, ApexEventConsumer, Runnable {
+public class ApexJmsConsumer extends ApexPluginsEventConsumer implements MessageListener {
// Get a reference to the logger
private static final Logger LOGGER = LoggerFactory.getLogger(ApexJmsConsumer.class);
@@ -61,22 +56,12 @@ public class ApexJmsConsumer implements MessageListener, ApexEventConsumer, Runn
// The event receiver that will receive events from this consumer
private ApexEventReceiver eventReceiver;
- // The consumer thread and stopping flag
- private Thread consumerThread;
- private boolean stopOrderedFlag = false;
-
// The connection to the JMS server
private Connection connection;
// The topic on which we receive events from JMS
private Topic jmsIncomingTopic;
- // The name for this consumer
- private String name = null;
-
- // The peer references for this event handler
- private Map<EventHandlerPeeredMode, PeeredReference> peerReferenceMap = new EnumMap<>(EventHandlerPeeredMode.class);
-
@Override
public void init(final String consumerName, final EventHandlerParameters consumerParameters,
final ApexEventReceiver incomingEventReceiver) throws ApexEventException {
@@ -148,42 +133,6 @@ public class ApexJmsConsumer implements MessageListener, ApexEventConsumer, Runn
* {@inheritDoc}.
*/
@Override
- public void start() {
- // Configure and start the event reception thread
- final String threadName = this.getClass().getName() + ":" + this.name;
- consumerThread = new ApplicationThreadFactory(threadName).newThread(this);
- consumerThread.setDaemon(true);
- consumerThread.start();
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public String getName() {
- return name;
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public PeeredReference getPeeredReference(final EventHandlerPeeredMode peeredMode) {
- return peerReferenceMap.get(peeredMode);
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
- public void setPeeredReference(final EventHandlerPeeredMode peeredMode, final PeeredReference peeredReference) {
- peerReferenceMap.put(peeredMode, peeredReference);
- }
-
- /**
- * {@inheritDoc}.
- */
- @Override
public void run() {
// JMS session and message consumer for receiving messages
try (final Session jmsSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE)) {