Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for customizing AS2SenderModule used by AS2Client #21

Merged
merged 1 commit into from
May 4, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions as2-lib/src/main/java/com/helger/as2lib/client/AS2Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@
import com.helger.as2lib.processor.sender.IProcessorSenderModule;
import com.helger.as2lib.session.AS2Session;
import com.helger.as2lib.util.StringMap;
import com.helger.commons.ValueEnforcer;
import com.helger.commons.annotation.OverrideOnDemand;
import com.helger.commons.factory.FactoryNewInstance;
import com.helger.commons.factory.IFactory;

/**
* A simple client that allows for sending AS2 Messages and retrieving of
Expand All @@ -71,12 +74,26 @@
public class AS2Client
{
private static final Logger s_aLogger = LoggerFactory.getLogger (AS2Client.class);

private IFactory <AS2SenderModule> m_aAS2SenderModuleFactory = FactoryNewInstance.create (AS2SenderModule.class, true);
private Proxy m_aHttpProxy;

public AS2Client ()
{}

/**
* Set the factory to create {@link AS2SenderModule} objects internally.
* By default a new instance of AS2SenderModule is created so you don't need
* to call this method.
*
* @param aAS2SenderModuleFactory
* The factory to be used. May not be <code>null</code>.
*/
@Nonnull
public void setAS2SenderModuleFactory (@Nonnull final IFactory <AS2SenderModule> aAS2SenderModuleFactory)
{
m_aAS2SenderModuleFactory = ValueEnforcer.notNull (aAS2SenderModuleFactory, "AS2SenderModuleFactory");
}

/**
* @return The current HTTP proxy used. Defaults to <code>null</code>.
*/
Expand Down Expand Up @@ -311,7 +328,7 @@ public AS2ClientResponse sendSynchronous (@Nonnull final AS2ClientSettings aSett
// And create a sender module that directly sends the message
// The message processor registration is required for the resending
// feature
final AS2SenderModule aSender = new AS2SenderModule ();
final AS2SenderModule aSender = m_aAS2SenderModuleFactory.create();
aSender.initDynamicComponent (aSession, null);
aSession.getMessageProcessor ().addModule (aSender);

Expand Down