Skip to content

Commit

Permalink
Extracted logging consumer
Browse files Browse the repository at this point in the history
  • Loading branch information
phax committed Sep 24, 2024
1 parent 992e134 commit 5d81f5e
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 23 deletions.
Original file line number Diff line number Diff line change
@@ -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");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down

0 comments on commit 5d81f5e

Please sign in to comment.