Package com.helger.phase4.dump
Class AbstractAS4OutgoingDumperWithHeaders<IMPLTYPE extends AbstractAS4OutgoingDumperWithHeaders<IMPLTYPE>>
java.lang.Object
com.helger.phase4.dump.AbstractAS4OutgoingDumperWithHeaders<IMPLTYPE>
- Type Parameters:
IMPLTYPE- Implementation type (since v3.0.0)
- All Implemented Interfaces:
com.helger.commons.traits.IGenericImplTrait<IMPLTYPE>,IAS4OutgoingDumper
- Direct Known Subclasses:
AS4OutgoingDumperFileBased,AS4OutgoingDumperSingleUse
public abstract class AbstractAS4OutgoingDumperWithHeaders<IMPLTYPE extends AbstractAS4OutgoingDumperWithHeaders<IMPLTYPE>>
extends Object
implements IAS4OutgoingDumper, com.helger.commons.traits.IGenericImplTrait<IMPLTYPE>
Abstract implementation of
IAS4OutgoingDumper that always adds the
custom headers- Since:
- 0.9.7
- Author:
- Philip Helger
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanonBeginRequest(EAS4MessageMode eMsgMode, IAS4IncomingMessageMetadata aIncomingMessageMetadata, IAS4IncomingMessageState aIncomingState, String sMessageID, com.helger.commons.http.HttpHeaderMap aCustomHeaders, int nTry) Called for new requests.voidonEndRequest(EAS4MessageMode eMsgMode, IAS4IncomingMessageMetadata aIncomingMessageMetadata, IAS4IncomingMessageState aIncomingState, String sMessageID, Exception aCaughtException) Called after the AS4 request is handled internally.protected abstract OutputStreamopenOutputStream(EAS4MessageMode eMsgMode, IAS4IncomingMessageMetadata aIncomingMessageMetadata, IAS4IncomingMessageState aIncomingState, String sMessageID, com.helger.commons.http.HttpHeaderMap aCustomHeaders, int nTry) Create the output stream to which the data should be dumped.final IMPLTYPEsetIncludeHeaders(boolean b) Include or exclude the headers from the dump.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.helger.commons.traits.IGenericImplTrait
thisAsT
-
Field Details
-
DEFAULT_INCLUDE_HEADERS
public static final boolean DEFAULT_INCLUDE_HEADERS- See Also:
-
-
Constructor Details
-
AbstractAS4OutgoingDumperWithHeaders
public AbstractAS4OutgoingDumperWithHeaders()
-
-
Method Details
-
isIncludeHeaders
public final boolean isIncludeHeaders()- Returns:
trueto include the headers in the dump,falseif not. The default isDEFAULT_INCLUDE_HEADERS.- Since:
- 2.5.2
-
setIncludeHeaders
Include or exclude the headers from the dump.- Parameters:
b-trueto include the headers in the dump,falseif not.- Returns:
- this for chaining (since v3)
- Since:
- 2.5.2
-
openOutputStream
@Nullable protected abstract OutputStream openOutputStream(@Nonnull EAS4MessageMode eMsgMode, @Nullable IAS4IncomingMessageMetadata aIncomingMessageMetadata, @Nullable IAS4IncomingMessageState aIncomingState, @Nonnull @Nonempty String sMessageID, @Nullable com.helger.commons.http.HttpHeaderMap aCustomHeaders, @Nonnegative int nTry) throws IOException Create the output stream to which the data should be dumped.- Parameters:
eMsgMode- Are we dumping a request or a response? Nevernull. Added in v1.2.0.aIncomingMessageMetadata- The incoming message metadata. This is alwaysnullfor requests. This is always non-nullfor responses. Added in v1.2.0.aIncomingState- The incoming message processing state. This is alwaysnullfor requests. This is always non-nullfor responses. Added in v1.2.0.sMessageID- The AS4 message ID of the outgoing message. Neithernullnor empty.aCustomHeaders- The HTTP headers of the outgoing message. Nevernull.nTry- The index of the try. The first try has always index 0, the first retry has index 1, the second retry has index 2 etc. Always ≥ 0.- Returns:
- The output stream to dump to or
nullif no dumping should be performed. - Throws:
IOException- On IO error
-
onBeginRequest
@Nullable public OutputStream onBeginRequest(@Nonnull EAS4MessageMode eMsgMode, @Nullable IAS4IncomingMessageMetadata aIncomingMessageMetadata, @Nullable IAS4IncomingMessageState aIncomingState, @Nonnull @Nonempty String sMessageID, @Nullable com.helger.commons.http.HttpHeaderMap aCustomHeaders, @Nonnegative int nTry) throws IOException Description copied from interface:IAS4OutgoingDumperCalled for new requests. It's the responsibility of the caller to close the created output stream.- Specified by:
onBeginRequestin interfaceIAS4OutgoingDumper- Parameters:
eMsgMode- Are we dumping a request or a response? Nevernull. Added in v1.2.0.aIncomingMessageMetadata- The incoming message metadata. This is alwaysnullfor requests (outgoing messages) and always non-nullfor responses (incoming messages) - see eMsgMode parameter for differentiation. Added in v1.2.0.aIncomingState- The incoming message processing state. This is alwaysnullfor requests and always non-nullfor responses - see eMsgMode parameter for differentiation. Added in v1.2.0.sMessageID- The AS4 message ID of the outgoing message. Neithernullnor empty.aCustomHeaders- Custom headers to be added to the HTTP entity. May benull.nTry- The index of the try. The first try has always index 0, the first retry has index 1, the second retry has index 2 etc. Always ≥ 0.- Returns:
- If
nullis returned, nothing is dumped, else each byte written to the target stream is also written to that output stream. - Throws:
IOException- in case of an error
-
onEndRequest
public void onEndRequest(@Nonnull EAS4MessageMode eMsgMode, @Nullable IAS4IncomingMessageMetadata aIncomingMessageMetadata, @Nullable IAS4IncomingMessageState aIncomingState, @Nonnull @Nonempty String sMessageID, @Nullable Exception aCaughtException) Description copied from interface:IAS4OutgoingDumperCalled after the AS4 request is handled internally. Can e.g. be used to cleanup resources belonging to the message. This method may not throw an exception. This method is only called if the onBeginRequest method delivered a non-nullOutputStream.- Specified by:
onEndRequestin interfaceIAS4OutgoingDumper- Parameters:
eMsgMode- Are we dumping a request or a response? Nevernull. Added in v1.2.0.aIncomingMessageMetadata- The incoming message metadata. This is alwaysnullfor requests. This is always non-nullfor responses. Added in v1.2.0.aIncomingState- The incoming message processing state. This is alwaysnullfor requests. This is always non-nullfor responses. Added in v1.2.0.sMessageID- The AS4 message ID of the outgoing message. Neithernullnor empty.aCaughtException- An optional exception caught during processing. May benull. Added in v3.0.0.
-