summaryrefslogtreecommitdiffstats
path: root/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-websocket
diff options
context:
space:
mode:
authorRam Krishna Verma <ram_krishna.verma@bell.ca>2020-02-24 14:39:34 +0000
committerGerrit Code Review <gerrit@onap.org>2020-02-24 14:39:34 +0000
commitaacc7442f046d44359934ea3d93f425a809e7616 (patch)
treea764f4168d0ef918e7af2b31b30dc7dc5c13f711 /plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-websocket
parent0c200b611ee7d56753915281f9a168f7f6e00e7e (diff)
parented3c65efa81f5eb1c9271ab05a340ea9f8ee34e7 (diff)
Merge "remove code duplication in plugins"
Diffstat (limited to 'plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-websocket')
-rw-r--r--plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-websocket/src/main/java/org/onap/policy/apex/plugins/event/carrier/websocket/ApexWebSocketConsumer.java56
1 files changed, 3 insertions, 53 deletions
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-websocket/src/main/java/org/onap/policy/apex/plugins/event/carrier/websocket/ApexWebSocketConsumer.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-websocket/src/main/java/org/onap/policy/apex/plugins/event/carrier/websocket/ApexWebSocketConsumer.java
index 3cf44806a..949cd53d7 100644
--- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-websocket/src/main/java/org/onap/policy/apex/plugins/event/carrier/websocket/ApexWebSocketConsumer.java
+++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-websocket/src/main/java/org/onap/policy/apex/plugins/event/carrier/websocket/ApexWebSocketConsumer.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * * Modifications Copyright (C) 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.
@@ -20,8 +21,6 @@
package org.onap.policy.apex.plugins.event.carrier.websocket;
-import java.util.EnumMap;
-import java.util.Map;
import java.util.Properties;
import org.onap.policy.apex.core.infrastructure.messaging.MessagingException;
@@ -29,14 +28,11 @@ import org.onap.policy.apex.core.infrastructure.messaging.stringmessaging.WsStri
import org.onap.policy.apex.core.infrastructure.messaging.stringmessaging.WsStringMessageListener;
import org.onap.policy.apex.core.infrastructure.messaging.stringmessaging.WsStringMessageServer;
import org.onap.policy.apex.core.infrastructure.messaging.stringmessaging.WsStringMessager;
-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.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;
@@ -45,7 +41,7 @@ import org.slf4j.LoggerFactory;
*
* @author Liam Fallon (liam.fallon@ericsson.com)
*/
-public class ApexWebSocketConsumer implements ApexEventConsumer, WsStringMessageListener, Runnable {
+public class ApexWebSocketConsumer extends ApexPluginsEventConsumer implements WsStringMessageListener {
private static final int WEB_SOCKET_WAIT_SLEEP_TIME = 100;
// Get a reference to the logger
@@ -57,16 +53,6 @@ public class ApexWebSocketConsumer implements ApexEventConsumer, WsStringMessage
// The event receiver that will receive events from this consumer
private ApexEventReceiver eventReceiver;
- // 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);
-
- // The consumer thread and stopping flag
- private Thread consumerThread;
- private boolean stopOrderedFlag = false;
-
// The number of events read to date
private int eventsRead = 0;
@@ -107,42 +93,6 @@ public class ApexWebSocketConsumer implements ApexEventConsumer, WsStringMessage
* {@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() {
while (consumerThread.isAlive() && !stopOrderedFlag) {
ThreadUtilities.sleep(WEB_SOCKET_WAIT_SLEEP_TIME);