From 5d81f5e0959784bc5f26ce3355401cc34c99b79d Mon Sep 17 00:00:00 2001 From: Philip Helger Date: Tue, 24 Sep 2024 12:29:01 +0200 Subject: [PATCH] Extracted logging consumer --- ...gingAS4SignalMsgConsumerResultHandler.java | 47 +++++++++++++++++++ .../ValidatingAS4SignalMsgConsumer.java | 24 +--------- 2 files changed, 48 insertions(+), 23 deletions(-) create mode 100644 phase4-lib/src/main/java/com/helger/phase4/sender/LoggingAS4SignalMsgConsumerResultHandler.java diff --git a/phase4-lib/src/main/java/com/helger/phase4/sender/LoggingAS4SignalMsgConsumerResultHandler.java b/phase4-lib/src/main/java/com/helger/phase4/sender/LoggingAS4SignalMsgConsumerResultHandler.java new file mode 100644 index 00000000..b289b19d --- /dev/null +++ b/phase4-lib/src/main/java/com/helger/phase4/sender/LoggingAS4SignalMsgConsumerResultHandler.java @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2015-2024 Philip Helger (www.helger.com) + * philip[at]helger[dot]com + * + * 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. + */ +package com.helger.phase4.sender; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * A logging implementation of + * {@link IValidatingAS4SignalMsgConsumerResultHandler}. + * + * @author Philip Helger + */ +public class LoggingAS4SignalMsgConsumerResultHandler implements IValidatingAS4SignalMsgConsumerResultHandler +{ + private static final Logger LOGGER = LoggerFactory.getLogger (LoggingAS4SignalMsgConsumerResultHandler.class); + + public void onSuccess () + { + LOGGER.info ("All sent DSig references were contained in the AS4 Receipt message - good."); + } + + public void onError (final String sErrorMsg) + { + LOGGER.error (sErrorMsg); + } + + public void onNotApplicable () + { + if (LOGGER.isDebugEnabled ()) + LOGGER.debug ("The DSig references were not compared, because either the sent and/or the received message did no contain the necessary data elements"); + } +} diff --git a/phase4-lib/src/main/java/com/helger/phase4/sender/ValidatingAS4SignalMsgConsumer.java b/phase4-lib/src/main/java/com/helger/phase4/sender/ValidatingAS4SignalMsgConsumer.java index 360f5b5f..c1f8e321 100644 --- a/phase4-lib/src/main/java/com/helger/phase4/sender/ValidatingAS4SignalMsgConsumer.java +++ b/phase4-lib/src/main/java/com/helger/phase4/sender/ValidatingAS4SignalMsgConsumer.java @@ -21,9 +21,6 @@ import javax.annotation.Nonnull; import javax.annotation.Nullable; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import com.helger.commons.ValueEnforcer; import com.helger.commons.collection.impl.ICommonsList; import com.helger.phase4.client.AS4ClientSentMessage; @@ -44,27 +41,8 @@ */ public final class ValidatingAS4SignalMsgConsumer implements IAS4SignalMessageConsumer { - private static final Logger LOGGER = LoggerFactory.getLogger (ValidatingAS4SignalMsgConsumer.class); - // The default instance doing some logging only - private static final IValidatingAS4SignalMsgConsumerResultHandler DEFAULT_RES_HDL = new IValidatingAS4SignalMsgConsumerResultHandler () - { - public void onSuccess () - { - LOGGER.info ("All sent DSig references were contained in the AS4 Receipt message - good."); - } - - public void onError (final String sErrorMsg) - { - LOGGER.error (sErrorMsg); - } - - public void onNotApplicable () - { - if (LOGGER.isDebugEnabled ()) - LOGGER.debug ("The DSig references were not compared, because either the sent and/or the received message did no contain the necessary data elements"); - } - }; + private static final IValidatingAS4SignalMsgConsumerResultHandler DEFAULT_RES_HDL = new LoggingAS4SignalMsgConsumerResultHandler (); private final AS4ClientSentMessage m_aClientSetMsg; private final IAS4SignalMessageConsumer m_aOriginalConsumer;