HttpClientFactory

Note: See HttpRouter.

 

The HttpClientFactory creates HttpClient instances via it's "createHttpClient" method.  This method takes a java.util.Properties instance.  These properties are used to configure the HttpClient instance.

 

The following is an example of this property set.

    # Configurators
    configurators=HttpProtocol,AuthBASIC

    # HttpProtocol config...
    protocol-socket-factory=org.apache.commons.httpclient.contrib.ssl.EasySSLProtocolSocketFactory
    keystore=/packages/jakarta-tomcat-5.0.28/conf/chap8.keystore
    keystore-passw=xxxxxx

    # AuthBASIC config...
    auth-username=tomcat
    auth-password=tomcat
    authscope-host=localhost
    authscope-port=18443
    authscope-realm=ActiveBPEL security realm

 

Configurators

The only property that the HttpClientFactory actually looks at is the "configurators" property.  This property contains a comma separated list of "Configurators" (implementations of org.jboss.soa.esb.http.Configurator) that are use to configure different aspects of the HttpClient instance.  The other properties in the set are specific to the actual "Configurators" themselves.  To create a Configurator to handle some other aspect of HttpClient configuration, simply extend the org.jboss.soa.esb.http.Configurator class.

 

If the Configurator implementation resides in the "org.jboss.soa.esb.http.configurators" package, there's no need to prefix the class name with the package name.  This can be seen in the above example.

 

"HttpProtocol" Configurator

This Configurator supports protocol configuration.  It supports 3 properties:

  1. protocol-socket-factory

  2. keystore

  3. keystore-passw

 

 

"AuthBASIC" Configurator

Adds support for configuring a HttpClient instance for BASIC authentication.  It supports 5 properties:

  1. auth-username

  2. auth-password

  3. authscope-host

  4. authscope-port

  5. authscope-realm

 

Adding your Configurator Implementations

As stated above, to create a Configurator to handle some other aspect of HttpClient configuration, simply extend the org.jboss.soa.esb.http.Configurator class and implement its "configure" method.  Once your implementation is created, you can then use it with the HttpClientFactory by specifying your Configurator implementation in the "configurators" config property e.g.

 

    # Configurators
    configurators=HttpProtocol,com.acme.http.configurators.XXXConfigurator

    # HttpProtocol config...
    protocol-socket-factory=org.apache.commons.httpclient.contrib.ssl.EasySSLProtocolSocketFactory
    keystore=/packages/jakarta-tomcat-5.0.28/conf/chap8.keystore
    keystore-passw=xxxxxx

    # XXXConfigurator config...
    prop1=a
    prop2=b
    etc...

 

The properties for the Configurator implementation are made available through the java.util.Properties instance supplied in the call to the "configure" method.

 

See AuthBASIC.java and HttpProtocol.java as real example implementations.