Package com.helger.as2lib.client
Class AS2Client
- java.lang.Object
-
- com.helger.as2lib.client.AS2Client
-
public class AS2Client extends Object
A simple client that allows for sending AS2 Messages and retrieving of synchronous MDNs.- Author:
- Philip Helger
-
-
Constructor Summary
Constructors Constructor Description AS2Client()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
beforeSend(AS2ClientSettings aSettings, AS2Session aSession, IMessage aMsg)
Callback method that is invoked before the main sending.protected Partnership
buildPartnership(AS2ClientSettings aSettings)
Create a newPartnership
object that is later used for message creation.protected AS2Message
createAS2MessageObj()
protected CertificateFactory
createCertificateFactory()
protected AS2Message
createMessage(Partnership aPartnership, AS2ClientRequest aRequest)
protected AS2ClientResponse
createResponse()
Create an empty response object that is to be filled.protected AS2Session
createSession()
Create the AS2 session to be used.Proxy
getHttpProxy()
protected void
initCertificateFactory(AS2ClientSettings aSettings, AS2Session aSession)
protected void
initMessageProcessor(AS2Session aSession)
protected void
initPartnershipFactory(AS2Session aSession)
AS2ClientResponse
sendSynchronous(AS2ClientSettings aSettings, AS2ClientRequest aRequest)
Send the AS2 message synchronouslyAS2Client
setAS2SenderModuleFactory(com.helger.commons.functional.ISupplier<AS2SenderModule> aAS2SenderModuleFactory)
Set the factory to createAS2SenderModule
objects internally.AS2Client
setHttpProxy(Proxy aHttpProxy)
Set the proxy server for transmission.
-
-
-
Method Detail
-
setAS2SenderModuleFactory
@Nonnull public AS2Client setAS2SenderModuleFactory(@Nonnull com.helger.commons.functional.ISupplier<AS2SenderModule> aAS2SenderModuleFactory)
Set the factory to createAS2SenderModule
objects internally. By default a new instance ofAS2SenderModule
is created so you don't need to call this method.- Parameters:
aAS2SenderModuleFactory
- The factory to be used. May not benull
.- Returns:
- this for chaining
-
getHttpProxy
@Nullable public Proxy getHttpProxy()
- Returns:
- The current HTTP proxy used. Defaults to
null
.
-
setHttpProxy
@Nonnull public AS2Client setHttpProxy(@Nullable Proxy aHttpProxy)
Set the proxy server for transmission.- Parameters:
aHttpProxy
- The proxy to use. May benull
to indicate no proxy.- Returns:
- this for chaining
-
buildPartnership
@Nonnull @OverrideOnDemand @OverridingMethodsMustInvokeSuper protected Partnership buildPartnership(@Nonnull AS2ClientSettings aSettings)
Create a newPartnership
object that is later used for message creation. If you override this method, please ensure to call this class' version of the method first.- Parameters:
aSettings
- The current client settings. Nevernull
.- Returns:
- Non-
null
Partnership.
-
createAS2MessageObj
@Nonnull @OverrideOnDemand protected AS2Message createAS2MessageObj()
-
createMessage
@Nonnull @OverrideOnDemand @OverridingMethodsMustInvokeSuper protected AS2Message createMessage(@Nonnull Partnership aPartnership, @Nonnull AS2ClientRequest aRequest) throws javax.mail.MessagingException
- Throws:
javax.mail.MessagingException
-
createCertificateFactory
@Nonnull @OverrideOnDemand protected CertificateFactory createCertificateFactory()
- Returns:
- The certificate factory instance to be used. May not be
null
.
-
initCertificateFactory
@OverrideOnDemand protected void initCertificateFactory(@Nonnull AS2ClientSettings aSettings, @Nonnull AS2Session aSession) throws AS2Exception
- Throws:
AS2Exception
-
initPartnershipFactory
@OverrideOnDemand protected void initPartnershipFactory(@Nonnull AS2Session aSession) throws AS2Exception
- Throws:
AS2Exception
-
initMessageProcessor
@OverrideOnDemand protected void initMessageProcessor(@Nonnull AS2Session aSession) throws AS2Exception
- Throws:
AS2Exception
-
createResponse
@Nonnull @OverrideOnDemand protected AS2ClientResponse createResponse()
Create an empty response object that is to be filled.- Returns:
- The empty response object and never
null
.
-
createSession
@Nonnull @OverrideOnDemand protected AS2Session createSession()
Create the AS2 session to be used. This method must ensure an eventually needed proxy is set.- Returns:
- The new AS2 session and never
null
.
-
beforeSend
@OverrideOnDemand protected void beforeSend(@Nonnull AS2ClientSettings aSettings, @Nonnull AS2Session aSession, @Nonnull IMessage aMsg)
Callback method that is invoked before the main sending. This may be used to customize the message.- Parameters:
aSettings
- Client settings. Nevernull
.aSession
- Current session. Nevernull
.aMsg
- Current message. Nevernull
.
-
sendSynchronous
@Nonnull public AS2ClientResponse sendSynchronous(@Nonnull AS2ClientSettings aSettings, @Nonnull AS2ClientRequest aRequest)
Send the AS2 message synchronously- Parameters:
aSettings
- The settings to be used. May not benull
.aRequest
- The request data to be send. May not benull
.- Returns:
- The response object. Never
null
.
-
-