Class AbstractAS4MessageBuilder<IMPLTYPE extends AbstractAS4MessageBuilder<IMPLTYPE>>

java.lang.Object
com.helger.phase4.sender.AbstractAS4MessageBuilder<IMPLTYPE>
Type Parameters:
IMPLTYPE - The implementation type
All Implemented Interfaces:
com.helger.commons.traits.IGenericImplTrait<IMPLTYPE>
Direct Known Subclasses:
AbstractAS4PullRequestBuilder, AbstractAS4UserMessageBuilder

@NotThreadSafe public abstract class AbstractAS4MessageBuilder<IMPLTYPE extends AbstractAS4MessageBuilder<IMPLTYPE>> extends Object implements com.helger.commons.traits.IGenericImplTrait<IMPLTYPE>
Abstract builder base class with the requirements for all message types.
Since:
0.10.0
Author:
Philip Helger
  • Field Details

  • Constructor Details

  • Method Details

    • customHttpPoster

      @Nullable public final IHttpPoster customHttpPoster()
      Returns:
      The currently set IHttpPoster. May be null.
      Since:
      1.3.10
    • customHttpPoster

      @Nonnull public final IMPLTYPE customHttpPoster(@Nullable IHttpPoster aCustomHttpPoster)
      Set the HTTP poster to be used. This is a very low level API and should only be used if you know what you are doing! It allows you to overwrite how the message is sent over the wire.
      Note: if this method is used with a non-null parameter, httpClientFactory() becomes useless
      Parameters:
      aCustomHttpPoster - The new HTTP poster to be used. May be null which means "use the default" poster.
      Returns:
      this for chaining
      Since:
      1.3.10
    • httpClientFactory

      @Nullable public final com.helger.httpclient.HttpClientFactory httpClientFactory()
      Returns:
      The currently set HttpClientFactory. May be null.
    • httpClientFactory

      @Nonnull public final IMPLTYPE httpClientFactory(@Nullable com.helger.httpclient.HttpClientSettings aHttpClientSettings)
      Set the HTTP client factory to be used. If the passed settings are non-null, a new HttpClientFactory is created with them, else a null-HttpClientFactory is set.
      Parameters:
      aHttpClientSettings - The new HTTP client settings to be used. May be null.
      Returns:
      this for chaining
    • httpClientFactory

      @Nonnull public final IMPLTYPE httpClientFactory(@Nullable com.helger.httpclient.HttpClientFactory aHttpClientFactory)
      Set the HTTP client factory to be used. By default a default instance of HttpClientFactory is used (set in the constructor) and there is no need to invoke this method.
      Parameters:
      aHttpClientFactory - The new HTTP client factory to be used. May be null.
      Returns:
      this for chaining
    • cryptoFactory

      @Nullable public final IAS4CryptoFactory cryptoFactory()
      Returns:
      The currently set IAS4CryptoFactory. May be null.
    • cryptoFactory

      @Nonnull public final IMPLTYPE cryptoFactory(@Nullable IAS4CryptoFactory aCryptoFactory)
      Set the crypto factory to be used. The default crypto factory is set in the constructor to AS4CryptoFactoryProperties.getDefaultInstance().
      Parameters:
      aCryptoFactory - The crypto factory to be used. May be null.
      Returns:
      this for chaining
    • messageID

      @Nonnull public final IMPLTYPE messageID(@Nullable String sMessageID)
      Set the optional AS4 message ID. If this field is not set, a random message ID is created.
      Parameters:
      sMessageID - The optional AS4 message ID to be used. May be null.
      Returns:
      this for chaining
    • refToMessageID

      @Nonnull public final IMPLTYPE refToMessageID(@Nullable String sRefToMessageID)
      Set the optional AS4 reference to a previous message ID. If this field is not set, it will not be emitted in the message.
      Parameters:
      sRefToMessageID - The optional AS4 reference to a previous message ID to be used. May be null.
      Returns:
      this for chaining
      Since:
      1.3.2
    • sendingDateTime

      @Nonnull public final IMPLTYPE sendingDateTime(@Nullable OffsetDateTime aSendingDateTime)
      Set the optional sending date time. If no time is specified, the current date time will be used.
      Parameters:
      aSendingDateTime - The sending date time to set. May be null.
      Returns:
      this for chaining
      Since:
      0.12.0
    • soapVersion

      @Nullable public final ESoapVersion soapVersion()
      Returns:
      The SOAP version to be used. May be null.
    • soapVersion

      @Nonnull public final IMPLTYPE soapVersion(@Nullable ESoapVersion eSoapVersion)
      Set the SOAP version to be used. The default is SOAP 1.2 and is set in the constructor. Usually you don't need to call that method.
      Parameters:
      eSoapVersion - The SOAP version to be used. May be null.
      Returns:
      this for chaining
    • httpRetrySettings

      @Nonnull public final IMPLTYPE httpRetrySettings(@Nullable HttpRetrySettings a)
      Set the HTTP retry settings to be used. If none are set, the default values are used.
      Parameters:
      a - The HTTP retry settings to be used. May be null.
      Returns:
      this for chaining
    • locale

      @Nonnull public final IMPLTYPE locale(@Nullable Locale a)
      Set the locale to use. The main purpose is to use the correct language for processing error message in response messages. This field must be set. The default value is DEFAULT_LOCALE.
      Parameters:
      a - The locale to use. May be null.
      Returns:
      this for chaining
    • pmodeResolver

      @Nullable public final IPModeResolver pmodeResolver()
      Returns:
      The currently set IPModeResolver. May be null.
    • pmodeResolver

      @Nonnull public final IMPLTYPE pmodeResolver(@Nullable IPModeResolver aPModeResolver)
      Set the PMode resolver to be used. This is only used to determine the PMode of an eventually received synchronous response message.
      Parameters:
      aPModeResolver - The PMode resolver to be used. May be null.
      Returns:
      this for chaining
    • incomingAttachmentFactory

      @Nullable public final IAS4IncomingAttachmentFactory incomingAttachmentFactory()
      Returns:
      The currently set IAS4IncomingAttachmentFactory. Never null.
    • incomingAttachmentFactory

      @Nonnull public final IMPLTYPE incomingAttachmentFactory(@Nonnull IAS4IncomingAttachmentFactory aIAF)
      Set the incoming attachment factory to be used. This is only used for an eventually received synchronous response message.
      Parameters:
      aIAF - The incoming attachment factory to be used. May not be null.
      Returns:
      this for chaining
    • incomingProfileSelector

      @Nonnull public final IAS4IncomingProfileSelector incomingProfileSelector()
      Returns:
      The profile selector for incoming AS4 messages. Never null.
      Since:
      0.13.0
    • incomingProfileSelector

      @Nonnull public final IMPLTYPE incomingProfileSelector(@Nonnull IAS4IncomingProfileSelector aIncomingProfileSelector)
      Set the selector for the AS4 profile of incoming messages. This is only used for an eventually received synchronous response message.
      Parameters:
      aIncomingProfileSelector - The profile selector to use. May not be null.
      Returns:
      this for chaining
      Since:
      0.13.0
    • senderInterrupt

      @Nullable public final IAS4SenderInterrupt senderInterrupt()
      Returns:
      The currently set IAS4SenderInterrupt. May be null.
      Since:
      0.13.0
    • senderInterrupt

      @Nonnull public final IMPLTYPE senderInterrupt(@Nullable IAS4SenderInterrupt aSenderInterrupt)
      Set the sender interrupt to be used. This is only needed in very specific cases, is null by default and should be handled with care.
      Parameters:
      aSenderInterrupt - The sender interrupt to be used. May be null.
      Returns:
      this for chaining
      Since:
      0.13.0
    • buildMessageCallback

      @Nonnull public final IMPLTYPE buildMessageCallback(@Nullable IAS4ClientBuildMessageCallback aBuildMessageCallback)
      Set a internal message callback. Usually this method is NOT needed. Use only when you know what you are doing.
      Parameters:
      aBuildMessageCallback - An internal to be used for the created message. May be null.
      Returns:
      this for chaining
    • outgoingDumper

      @Nonnull public final IMPLTYPE outgoingDumper(@Nullable IAS4OutgoingDumper aOutgoingDumper)
      Set a specific outgoing dumper for this builder.
      Parameters:
      aOutgoingDumper - An outgoing dumper to be used. Maybe null. If null the global outgoing dumper is used.
      Returns:
      this for chaining
    • incomingDumper

      @Nonnull public final IMPLTYPE incomingDumper(@Nullable IAS4IncomingDumper aIncomingDumper)
      Set a specific incoming dumper for this builder.
      Parameters:
      aIncomingDumper - An incoming dumper to be used. Maybe null. If null the global incoming dumper is used.
      Returns:
      this for chaining
    • retryCallback

      @Nonnull public final IMPLTYPE retryCallback(@Nullable IAS4RetryCallback aRetryCallback)
      Set an optional handler that is notified if an http sending will be retried. This method is optional and must not be called prior to sending.
      Parameters:
      aRetryCallback - The optional retry callback. May be null.
      Returns:
      this for chaining
    • rawResponseConsumer

      @Nonnull public final IMPLTYPE rawResponseConsumer(@Nullable IAS4RawResponseConsumer aResponseConsumer)
      Set an optional handler for the synchronous result message received from the other side. This method is optional and must not be called prior to sending.
      Parameters:
      aResponseConsumer - The optional response consumer. May be null.
      Returns:
      this for chaining
    • isEveryRequiredFieldSet

      @OverridingMethodsMustInvokeSuper public boolean isEveryRequiredFieldSet()
    • finishFields

      @OverrideOnDemand @OverridingMethodsMustInvokeSuper protected com.helger.commons.state.ESuccess finishFields() throws Phase4Exception
      Internal method that is invoked before the required field check is performed. Override to set additional dynamically created fields if necessary.
      Don't add message properties in here, because if the required fields check fails than this method would be called again.
      Returns:
      ESuccess - never null. Returning failure here stops sending the message.
      Throws:
      Phase4Exception - if something goes wrong
    • customizeBeforeSending

      protected void customizeBeforeSending() throws Phase4Exception
      Internal method that is invoked after the required fields are checked but before sending takes place. This is e.g. the perfect place to add custom message properties.
      Throws:
      Phase4Exception - if something goes wrong
    • mainSendMessage

      protected abstract void mainSendMessage() throws Phase4Exception
      Synchronously send the AS4 message. This method may only be called by sendMessage()
      Throws:
      Phase4Exception - In case of any error
    • sendMessage

      @Nonnull public final com.helger.commons.state.ESuccess sendMessage() throws Phase4Exception
      Synchronously send the AS4 message. First the internal "finishFields" method is called, to ensure all dynamic fields are filled - on failure this methods exits. Afterwards isEveryRequiredFieldSet() is called to check that all mandatory elements are set - on failure this methods exits. Afterwards "customizeBeforeSending" is called to make final adjustments to the message. As the very last step, the customizable sender interrupt is invoked which may prevent the main message sending. As the last step "mainSendMessage" is invoked and "SUCCESS" is returned.
      Note: since 0.13.0 this common implementation is in place.
      Returns:
      ESuccess.FAILURE if not all mandatory parameters are set or if sending failed, ESuccess.SUCCESS upon success. Never null. This result code does not reflect the semantics of a semantically correct message exchange or not. It just states, if the message was sent or nor. The rest needs to be determined separately.
      Throws:
      Phase4Exception - In case of any error
      See Also: