diff options
author | Ram Krishna Verma <ram_krishna.verma@bell.ca> | 2020-02-24 14:39:34 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2020-02-24 14:39:34 +0000 |
commit | aacc7442f046d44359934ea3d93f425a809e7616 (patch) | |
tree | a764f4168d0ef918e7af2b31b30dc7dc5c13f711 /plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src | |
parent | 0c200b611ee7d56753915281f9a168f7f6e00e7e (diff) | |
parent | ed3c65efa81f5eb1c9271ab05a340ea9f8ee34e7 (diff) |
Merge "remove code duplication in plugins"
Diffstat (limited to 'plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src')
2 files changed, 6 insertions, 55 deletions
diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/main/java/org/onap/policy/apex/plugins/event/carrier/restserver/ApexRestServerConsumer.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/main/java/org/onap/policy/apex/plugins/event/carrier/restserver/ApexRestServerConsumer.java index c8a07f234..95037160a 100644 --- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/main/java/org/onap/policy/apex/plugins/event/carrier/restserver/ApexRestServerConsumer.java +++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/main/java/org/onap/policy/apex/plugins/event/carrier/restserver/ApexRestServerConsumer.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,17 +21,13 @@ package org.onap.policy.apex.plugins.event.carrier.restserver; -import java.util.EnumMap; -import java.util.Map; import java.util.Properties; import java.util.concurrent.atomic.AtomicLong; import javax.ws.rs.core.Response; -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.engine.event.SynchronousEventCache; import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerParameters; import org.onap.policy.apex.service.parameters.eventhandler.EventHandlerPeeredMode; @@ -46,7 +42,7 @@ import org.slf4j.LoggerFactory; * * @author Liam Fallon (liam.fallon@ericsson.com) */ -public class ApexRestServerConsumer implements ApexEventConsumer, Runnable { +public class ApexRestServerConsumer extends ApexPluginsEventConsumer { // Get a reference to the logger private static final Logger LOGGER = LoggerFactory.getLogger(ApexRestServerConsumer.class); @@ -56,16 +52,6 @@ public class ApexRestServerConsumer implements ApexEventConsumer, Runnable { // 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 local HTTP server to use for REST call reception if we are running a local Grizzly server private HttpServletServer server; @@ -156,42 +142,6 @@ public class ApexRestServerConsumer implements ApexEventConsumer, Runnable { } /** - * {@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); - } - - /** * Receive an event for processing in Apex. * * @param event the event to receive diff --git a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/test/java/org/onap/policy/apex/plugins/event/carrier/restserver/ApexRestServerConsumerTest.java b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/test/java/org/onap/policy/apex/plugins/event/carrier/restserver/ApexRestServerConsumerTest.java index 07f705cc6..91d6a0f4e 100644 --- a/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/test/java/org/onap/policy/apex/plugins/event/carrier/restserver/ApexRestServerConsumerTest.java +++ b/plugins/plugins-event/plugins-event-carrier/plugins-event-carrier-restserver/src/test/java/org/onap/policy/apex/plugins/event/carrier/restserver/ApexRestServerConsumerTest.java @@ -1,7 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2019 Samsung. 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. @@ -32,6 +32,7 @@ import org.junit.Before; import org.junit.Test; 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.ApexPluginsEventConsumer; import org.onap.policy.apex.service.engine.event.PeeredReference; import org.onap.policy.apex.service.engine.event.SynchronousEventCache; import org.onap.policy.apex.service.parameters.carriertechnology.CarrierTechnologyParameters; @@ -156,7 +157,7 @@ public class ApexRestServerConsumerTest { Field field = ApexRestServerConsumer.class.getDeclaredField("eventReceiver"); field.setAccessible(true); field.set(apexRestServerConsumer, apexEventReceiver); - field = ApexRestServerConsumer.class.getDeclaredField("name"); + field = ApexPluginsEventConsumer.class.getDeclaredField("name"); field.setAccessible(true); field.set(apexRestServerConsumer, "TestApexRestServerConsumer"); |