From b5f4934afdc2601c925e83458d0e3d136c36cf1c Mon Sep 17 00:00:00 2001 From: ramverma Date: Tue, 5 Feb 2019 15:34:35 +0000 Subject: Change policy/distribution logging to slf4j 1) Changed logging from FlexLogger to SLF4J with logback 2) Fixed test cases of distribution REST endpoints having infinite while loop Change-Id: I1551873b3d348f9a7d2b4f8dfc3ae5dd6462bdb8 Issue-ID: POLICY-1346 Signed-off-by: ramverma --- .../reception/handling/AbstractReceptionHandler.java | 7 ++++--- .../reception/handling/PluginHandler.java | 7 ++++--- ...licyDecoderConfigurationParametersJsonAdapter.java | 8 ++++---- .../reception/parameters/PolicyDecoderParameters.java | 9 +++++---- ...tionHandlerConfigurationParametersJsonAdapter.java | 19 +++++++++++-------- .../parameters/ReceptionHandlerParameters.java | 13 ++++++------- 6 files changed, 34 insertions(+), 29 deletions(-) (limited to 'reception/src') diff --git a/reception/src/main/java/org/onap/policy/distribution/reception/handling/AbstractReceptionHandler.java b/reception/src/main/java/org/onap/policy/distribution/reception/handling/AbstractReceptionHandler.java index 7f3d80b5..5b2d1671 100644 --- a/reception/src/main/java/org/onap/policy/distribution/reception/handling/AbstractReceptionHandler.java +++ b/reception/src/main/java/org/onap/policy/distribution/reception/handling/AbstractReceptionHandler.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2018 Ericsson. All rights reserved. + * Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,8 +24,6 @@ package org.onap.policy.distribution.reception.handling; import java.util.ArrayList; import java.util.Collection; -import org.onap.policy.common.logging.flexlogger.FlexLogger; -import org.onap.policy.common.logging.flexlogger.Logger; import org.onap.policy.common.parameters.ParameterService; import org.onap.policy.distribution.forwarding.PolicyForwarder; import org.onap.policy.distribution.forwarding.PolicyForwardingException; @@ -34,6 +33,8 @@ import org.onap.policy.distribution.reception.decoding.PluginInitializationExcep import org.onap.policy.distribution.reception.decoding.PolicyDecoder; import org.onap.policy.distribution.reception.decoding.PolicyDecodingException; import org.onap.policy.distribution.reception.parameters.ReceptionHandlerParameters; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Base implementation of {@link ReceptionHandler}. All reception handlers should extend this base class by implementing @@ -42,7 +43,7 @@ import org.onap.policy.distribution.reception.parameters.ReceptionHandlerParamet */ public abstract class AbstractReceptionHandler implements ReceptionHandler { - private static final Logger LOGGER = FlexLogger.getLogger(AbstractReceptionHandler.class); + private static final Logger LOGGER = LoggerFactory.getLogger(AbstractReceptionHandler.class); private PluginHandler pluginHandler; diff --git a/reception/src/main/java/org/onap/policy/distribution/reception/handling/PluginHandler.java b/reception/src/main/java/org/onap/policy/distribution/reception/handling/PluginHandler.java index 74b8eb16..afa703ab 100644 --- a/reception/src/main/java/org/onap/policy/distribution/reception/handling/PluginHandler.java +++ b/reception/src/main/java/org/onap/policy/distribution/reception/handling/PluginHandler.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2018 Ericsson. All rights reserved. + * Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,8 +25,6 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Map; -import org.onap.policy.common.logging.flexlogger.FlexLogger; -import org.onap.policy.common.logging.flexlogger.Logger; import org.onap.policy.common.parameters.ParameterService; import org.onap.policy.distribution.forwarding.PolicyForwarder; import org.onap.policy.distribution.forwarding.parameters.PolicyForwarderParameters; @@ -35,13 +34,15 @@ import org.onap.policy.distribution.reception.decoding.PluginInitializationExcep import org.onap.policy.distribution.reception.decoding.PolicyDecoder; import org.onap.policy.distribution.reception.parameters.PluginHandlerParameters; import org.onap.policy.distribution.reception.parameters.PolicyDecoderParameters; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Handles the plugins to policy distribution. */ public class PluginHandler { - private static final Logger LOGGER = FlexLogger.getLogger(PluginHandler.class); + private static final Logger LOGGER = LoggerFactory.getLogger(PluginHandler.class); private Collection> policyDecoders; private Collection policyForwarders; diff --git a/reception/src/main/java/org/onap/policy/distribution/reception/parameters/PolicyDecoderConfigurationParametersJsonAdapter.java b/reception/src/main/java/org/onap/policy/distribution/reception/parameters/PolicyDecoderConfigurationParametersJsonAdapter.java index 64eb4ed7..c30d3d3d 100644 --- a/reception/src/main/java/org/onap/policy/distribution/reception/parameters/PolicyDecoderConfigurationParametersJsonAdapter.java +++ b/reception/src/main/java/org/onap/policy/distribution/reception/parameters/PolicyDecoderConfigurationParametersJsonAdapter.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2018 Ericsson. All rights reserved. + * Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,8 +29,8 @@ import com.google.gson.JsonPrimitive; import java.lang.reflect.Type; -import org.slf4j.ext.XLogger; -import org.slf4j.ext.XLoggerFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * This class deserialises policy decoder parameters from JSON. @@ -38,8 +39,7 @@ import org.slf4j.ext.XLoggerFactory; */ public class PolicyDecoderConfigurationParametersJsonAdapter implements JsonDeserializer { - private static final XLogger LOGGER = - XLoggerFactory.getXLogger(PolicyDecoderConfigurationParametersJsonAdapter.class); + private static final Logger LOGGER = LoggerFactory.getLogger(PolicyDecoderConfigurationParametersJsonAdapter.class); private static final String PARAMETER_CLASS_NAME = "parameterClassName"; private static final String POLICY_DECODER_PARAMETERS = "parameters"; diff --git a/reception/src/main/java/org/onap/policy/distribution/reception/parameters/PolicyDecoderParameters.java b/reception/src/main/java/org/onap/policy/distribution/reception/parameters/PolicyDecoderParameters.java index f56f8b64..f8ede1a9 100644 --- a/reception/src/main/java/org/onap/policy/distribution/reception/parameters/PolicyDecoderParameters.java +++ b/reception/src/main/java/org/onap/policy/distribution/reception/parameters/PolicyDecoderParameters.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2018 Ericsson. All rights reserved. + * Copyright (C) 2019 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,11 +21,11 @@ package org.onap.policy.distribution.reception.parameters; -import org.onap.policy.common.logging.flexlogger.FlexLogger; -import org.onap.policy.common.logging.flexlogger.Logger; import org.onap.policy.common.parameters.GroupValidationResult; import org.onap.policy.common.parameters.ParameterGroup; import org.onap.policy.common.parameters.ValidationStatus; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Class to hold all the policy decoder parameters. @@ -33,7 +34,7 @@ import org.onap.policy.common.parameters.ValidationStatus; */ public class PolicyDecoderParameters implements ParameterGroup { - private static final Logger LOGGER = FlexLogger.getLogger(PolicyDecoderParameters.class); + private static final Logger LOGGER = LoggerFactory.getLogger(PolicyDecoderParameters.class); private String decoderType; private String decoderClassName; @@ -85,7 +86,7 @@ public class PolicyDecoderParameters implements ParameterGroup { */ @Override public String getName() { - return decoderType; + return getDecoderType(); } /** diff --git a/reception/src/main/java/org/onap/policy/distribution/reception/parameters/ReceptionHandlerConfigurationParametersJsonAdapter.java b/reception/src/main/java/org/onap/policy/distribution/reception/parameters/ReceptionHandlerConfigurationParametersJsonAdapter.java index 0890a2ab..9b3a4d2b 100644 --- a/reception/src/main/java/org/onap/policy/distribution/reception/parameters/ReceptionHandlerConfigurationParametersJsonAdapter.java +++ b/reception/src/main/java/org/onap/policy/distribution/reception/parameters/ReceptionHandlerConfigurationParametersJsonAdapter.java @@ -1,19 +1,20 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2018 Ericsson. All rights reserved. + * Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * + * * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ @@ -25,17 +26,19 @@ import com.google.gson.JsonDeserializer; import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonPrimitive; + import java.lang.reflect.Type; -import org.slf4j.ext.XLogger; -import org.slf4j.ext.XLoggerFactory; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * This class deserialises reception handler parameters from JSON. */ public class ReceptionHandlerConfigurationParametersJsonAdapter implements JsonDeserializer { - private static final XLogger LOGGER = - XLoggerFactory.getXLogger(ReceptionHandlerConfigurationParametersJsonAdapter.class); + private static final Logger LOGGER = + LoggerFactory.getLogger(ReceptionHandlerConfigurationParametersJsonAdapter.class); private static final String PARAMETER_CLASS_NAME = "parameterClassName"; private static final String RECEPTION_HANDLER_PARAMETERS = "parameters"; @@ -46,7 +49,7 @@ public class ReceptionHandlerConfigurationParametersJsonAdapter final JsonObject jsonObject = json.getAsJsonObject(); final String receptionHandlerParameterClassName = getParameterGroupClassName(jsonObject); - Class receptionHandlerParameterClass = getParameterGroupClass(receptionHandlerParameterClassName); + final Class receptionHandlerParameterClass = getParameterGroupClass(receptionHandlerParameterClassName); return context.deserialize(jsonObject.get(RECEPTION_HANDLER_PARAMETERS), receptionHandlerParameterClass); } diff --git a/reception/src/main/java/org/onap/policy/distribution/reception/parameters/ReceptionHandlerParameters.java b/reception/src/main/java/org/onap/policy/distribution/reception/parameters/ReceptionHandlerParameters.java index 3839c449..ea6d8d86 100644 --- a/reception/src/main/java/org/onap/policy/distribution/reception/parameters/ReceptionHandlerParameters.java +++ b/reception/src/main/java/org/onap/policy/distribution/reception/parameters/ReceptionHandlerParameters.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2018 Ericsson. All rights reserved. + * Copyright (C) 2019 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,11 +21,11 @@ package org.onap.policy.distribution.reception.parameters; -import org.onap.policy.common.logging.flexlogger.FlexLogger; -import org.onap.policy.common.logging.flexlogger.Logger; import org.onap.policy.common.parameters.GroupValidationResult; import org.onap.policy.common.parameters.ParameterGroup; import org.onap.policy.common.parameters.ValidationStatus; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Class to hold all the reception handler parameters. @@ -33,7 +34,7 @@ import org.onap.policy.common.parameters.ValidationStatus; */ public class ReceptionHandlerParameters implements ParameterGroup { - private static final Logger LOGGER = FlexLogger.getLogger(ReceptionHandlerParameters.class); + private static final Logger LOGGER = LoggerFactory.getLogger(ReceptionHandlerParameters.class); private String name; private String receptionHandlerType; @@ -46,8 +47,7 @@ public class ReceptionHandlerParameters implements ParameterGroup { * * @param receptionHandlerType the reception handler type * @param receptionHandlerClassName the reception handler class name - * @param receptionHandlerConfigurationName the name of the configuration for the reception - * handler + * @param receptionHandlerConfigurationName the name of the configuration for the reception handler * @param pluginHandlerParameters the plugin handler parameters */ public ReceptionHandlerParameters(final String receptionHandlerType, final String receptionHandlerClassName, @@ -77,8 +77,7 @@ public class ReceptionHandlerParameters implements ParameterGroup { } /** - * Return the name of the reception handler configuration for this ReceptionHandlerParameters - * instance. + * Return the name of the reception handler configuration for this ReceptionHandlerParameters instance. * * @return the PssdConfigurationParametersGroup */ -- cgit 1.2.3-korg