From 9104eb39d56848952e68d660bdc3cc7500789501 Mon Sep 17 00:00:00 2001 From: liamfallon Date: Mon, 3 Dec 2018 14:35:21 +0000 Subject: Fix checkstyle/sonar issues Remove unused imports Add @FunctionalInterface annotation Reduce the complexity of some methods Change-Id: If519c31b113233361fbb935121fe6494263ac957 Issue-ID: POLICY-1074 Signed-off-by: liamfallon --- .../apex/service/engine/main/ApexActivator.java | 54 ++++++++++++---------- 1 file changed, 30 insertions(+), 24 deletions(-) (limited to 'services/services-engine/src') diff --git a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexActivator.java b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexActivator.java index c39be64fc..08c0e6910 100644 --- a/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexActivator.java +++ b/services/services-engine/src/main/java/org/onap/policy/apex/service/engine/main/ApexActivator.java @@ -127,30 +127,7 @@ public class ApexActivator { unmarshaller.init(engineServiceHandler); } - // Set up unmarshaler/marshaler pairing for synchronized event handling. We only need to - // traverse the unmarshalers because the - // unmarshalers and marshalers are paired one to one uniquely so if we find a - // synchronized unmarshaler we'll also find its - // paired marshaler - for (final Entry inputParameters : apexParameters.getEventInputParameters() - .entrySet()) { - final ApexEventUnmarshaller unmarshaller = unmarshallerMap.get(inputParameters.getKey()); - - // Pair up peered unmarshalers and marshalers - for (final EventHandlerPeeredMode peeredMode : EventHandlerPeeredMode.values()) { - // Check if the unmarshaler is synchronized with a marshaler - if (inputParameters.getValue().isPeeredMode(peeredMode)) { - // Find the unmarshaler and marshaler - final ApexEventMarshaller peeredMarshaler = - marshallerMap.get(inputParameters.getValue().getPeer(peeredMode)); - - // Connect the unmarshaler and marshaler - unmarshaller.connectMarshaler(peeredMode, peeredMarshaler); - } - } - // Now let's get events flowing - unmarshaller.start(); - } + setUpmarshalerPairings(); } catch (final Exception e) { LOGGER.debug("Apex engine failed to start as a service", e); throw new ApexActivatorException("Apex engine failed to start as a service", e); @@ -159,6 +136,35 @@ public class ApexActivator { LOGGER.debug("Apex engine started as a service"); } + /** + * Set up unmarshaler/marshaler pairing for synchronized event handling. We only need to + * traverse the unmarshalers because the + * unmarshalers and marshalers are paired one to one uniquely so if we find a + * synchronized unmarshaler we'll also find its + * paired marshaler + */ + private void setUpmarshalerPairings() { + for (final Entry inputParameters : apexParameters.getEventInputParameters() + .entrySet()) { + final ApexEventUnmarshaller unmarshaller = unmarshallerMap.get(inputParameters.getKey()); + + // Pair up peered unmarshalers and marshalers + for (final EventHandlerPeeredMode peeredMode : EventHandlerPeeredMode.values()) { + // Check if the unmarshaler is synchronized with a marshaler + if (inputParameters.getValue().isPeeredMode(peeredMode)) { + // Find the unmarshaler and marshaler + final ApexEventMarshaller peeredMarshaler = + marshallerMap.get(inputParameters.getValue().getPeer(peeredMode)); + + // Connect the unmarshaler and marshaler + unmarshaller.connectMarshaler(peeredMode, peeredMarshaler); + } + } + // Now let's get events flowing + unmarshaller.start(); + } + } + /** * Terminate the Apex engine. * -- cgit 1.2.3-korg