Apache CXF API

org.apache.cxf.transport.http
Class HTTPConduit

java.lang.Object
  extended by org.apache.cxf.transport.AbstractObservable
      extended by org.apache.cxf.transport.AbstractConduit
          extended by org.apache.cxf.transport.http.HTTPConduit
All Implemented Interfaces:
PropertyChangeListener, EventListener, Configurable, Assertor, Conduit, Observable

public class HTTPConduit
extends AbstractConduit
implements Configurable, Assertor, PropertyChangeListener

This Conduit handles the "http" and "https" transport protocols. An instance is governed by policies either explicitly set or by configuration.


Nested Class Summary
protected  class HTTPConduit.InterposedMessageObserver
          Used to set appropriate message properties, exchange etc.
protected  class HTTPConduit.WrappedOutputStream
          Wrapper output stream responsible for flushing headers and handling the incoming HTTP-level response (not necessarily the MEP response).
 
Field Summary
protected  HttpsURLConnectionFactory connectionFactory
          This field holds the connection factory, which primarily is used to factor out SSL specific code from this implementation.
static String KEY_HTTP_CONNECTION
          This constant is the Message(Map) key for the HttpURLConnection that is used to get the response.
 
Fields inherited from class org.apache.cxf.transport.AbstractConduit
target
 
Fields inherited from class org.apache.cxf.transport.AbstractObservable
incomingObserver
 
Constructor Summary
HTTPConduit(Bus b, EndpointInfo ei)
          Constructor
HTTPConduit(Bus b, EndpointInfo ei, EndpointReferenceType t)
          Constructor
 
Method Summary
 void assertMessage(Message message)
           
 boolean canAssert(QName type)
           
 void close()
          Close the conduit
 void close(Message msg)
          Close the connections associated with the message
protected  OutputStream createOutputStream(Message message, HttpURLConnection connection, boolean needToCacheRequest, boolean isChunking, int chunkThreshold)
           
protected  void finalizeConfig()
          This call gets called by the HTTPTransportFactory after it causes an injection of the Spring configuration properties of this Conduit.
protected  String getAddress()
           
 AuthorizationPolicy getAuthorization()
          This method gets the Authorization Policy that was configured or explicitly set for this HTTPConduit.
 HttpAuthSupplier getAuthSupplier()
          This method gets the Auth Supplier that was set/configured for this HTTPConduit.
 String getBeanName()
          This is part of the Configurable interface which retrieves the configuration from spring injection.
 HTTPClientPolicy getClient()
          This method retrieves the Client Side Policy set/configured for this HTTPConduit.
 HTTPClientPolicy getClient(Message message)
           
 String getConduitName()
          This method returns the name of the conduit, which is based on the endpoint name plus the SC_HTTP_CONDUIT_SUFFIX.
 Map<String,Cookie> getCookies()
          Allow access to the cookies that the conduit is maintaining
 AuthorizationPolicy getEffectiveAuthPolicy(Message message)
          Determines effective auth policy from message, conduit and empty default with priority from first to last
protected  Logger getLogger()
          This method returns the registered Logger for this conduit.
 ProxyAuthorizationPolicy getProxyAuthorization()
          This method retrieves the Proxy Authorization Policy for a proxy that is set/configured for this HTTPConduit.
 HttpAuthSupplier getProxyAuthSupplier()
           
 TLSClientParameters getTlsClientParameters()
          This method returns the TLS Client Parameters that is set/configured for this HTTPConduit.
 MessageTrustDecider getTrustDecider()
          This method gets the Trust Decider that was set/configured for this HTTPConduit.
protected  URL getURL()
           
protected  URL getURL(boolean createOnDemand)
           
protected  boolean isChunkingSupported(Message message, String httpMethod)
           
 void prepare(Message message)
          Prepare to send an outbound HTTP message over this http conduit to a particular endpoint.
 void propertyChange(PropertyChangeEvent evt)
           
 void setAuthorization(AuthorizationPolicy authorization)
          This method is used to set the Authorization Policy for this conduit.
 void setAuthSupplier(HttpAuthSupplier supplier)
           
 void setClient(HTTPClientPolicy client)
          This method sets the Client Side Policy for this HTTPConduit.
 void setProxyAuthorization(ProxyAuthorizationPolicy proxyAuthorization)
          This method sets the Proxy Authorization Policy for a specified proxy.
 void setProxyAuthSupplier(HttpAuthSupplier proxyAuthSupplier)
           
 void setTlsClientParameters(TLSClientParameters params)
          This method sets the TLS Client Parameters for this HTTPConduit.
 void setTrustDecider(MessageTrustDecider decider)
          This method sets the Trust Decider for this HTTP Conduit.
 
Methods inherited from class org.apache.cxf.transport.AbstractConduit
getTarget, toString
 
Methods inherited from class org.apache.cxf.transport.AbstractObservable
activate, deactivate, getMessageObserver, getTargetReference, getTargetReference, setMessageObserver
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.apache.cxf.transport.Observable
getMessageObserver, setMessageObserver
 

Field Detail

KEY_HTTP_CONNECTION

public static final String KEY_HTTP_CONNECTION
This constant is the Message(Map) key for the HttpURLConnection that is used to get the response.

See Also:
Constant Field Values

connectionFactory

protected HttpsURLConnectionFactory connectionFactory
This field holds the connection factory, which primarily is used to factor out SSL specific code from this implementation.

This field is "protected" to facilitate some contrived UnitTesting so that an extended class may alter its value with an EasyMock URLConnection Factory.

Constructor Detail

HTTPConduit

public HTTPConduit(Bus b,
                   EndpointInfo ei)
            throws IOException
Constructor

Parameters:
b - the associated Bus
ei - the endpoint info of the initiator
Throws:
IOException

HTTPConduit

public HTTPConduit(Bus b,
                   EndpointInfo ei,
                   EndpointReferenceType t)
            throws IOException
Constructor

Parameters:
b - the associated Bus.
endpoint - the endpoint info of the initiator.
t - the endpoint reference of the target.
Throws:
IOException
Method Detail

getLogger

protected Logger getLogger()
This method returns the registered Logger for this conduit.

Specified by:
getLogger in class AbstractObservable
Returns:
the logger to use

getConduitName

public final String getConduitName()
This method returns the name of the conduit, which is based on the endpoint name plus the SC_HTTP_CONDUIT_SUFFIX.

Returns:

finalizeConfig

protected void finalizeConfig()
This call gets called by the HTTPTransportFactory after it causes an injection of the Spring configuration properties of this Conduit.


getCookies

public Map<String,Cookie> getCookies()
Allow access to the cookies that the conduit is maintaining

Returns:
the sessionCookies map

prepare

public void prepare(Message message)
             throws IOException
Prepare to send an outbound HTTP message over this http conduit to a particular endpoint.

If the Message.PATH_INFO property is set it gets appended to the Conduit's endpoint URL. If the Message.QUERY_STRING property is set, it gets appended to the resultant URL following a "?".

If the Message.HTTP_REQUEST_METHOD property is NOT set, the Http request method defaults to "POST".

If the Message.PROTOCOL_HEADERS is not set on the message, it is initialized to an empty map.

This call creates the OutputStream for the content of the message. It also assigns the created Http(s)URLConnection to the Message Map.

Specified by:
prepare in interface Conduit
Parameters:
message - The message to be sent.
Throws:
IOException

isChunkingSupported

protected boolean isChunkingSupported(Message message,
                                      String httpMethod)

createOutputStream

protected OutputStream createOutputStream(Message message,
                                          HttpURLConnection connection,
                                          boolean needToCacheRequest,
                                          boolean isChunking,
                                          int chunkThreshold)

close

public void close(Message msg)
           throws IOException
Description copied from interface: Conduit
Close the connections associated with the message

Specified by:
close in interface Conduit
Overrides:
close in class AbstractConduit
Throws:
IOException

close

public void close()
Close the conduit

Specified by:
close in interface Conduit
Overrides:
close in class AbstractConduit

getAddress

protected String getAddress()
Returns:
the default target address

getURL

protected URL getURL()
              throws MalformedURLException
Returns:
the default target URL
Throws:
MalformedURLException

getURL

protected URL getURL(boolean createOnDemand)
              throws MalformedURLException
Parameters:
createOnDemand - create URL on-demand if null
Returns:
the default target URL
Throws:
MalformedURLException

getBeanName

public String getBeanName()
This is part of the Configurable interface which retrieves the configuration from spring injection.

Specified by:
getBeanName in interface Configurable
Returns:
the bean name

getEffectiveAuthPolicy

public AuthorizationPolicy getEffectiveAuthPolicy(Message message)
Determines effective auth policy from message, conduit and empty default with priority from first to last

Parameters:
message -
Returns:
effective AthorizationPolicy

getAuthorization

public AuthorizationPolicy getAuthorization()
This method gets the Authorization Policy that was configured or explicitly set for this HTTPConduit.


setAuthorization

public void setAuthorization(AuthorizationPolicy authorization)
This method is used to set the Authorization Policy for this conduit. Using this method will override any Authorization Policy set in configuration.


getClient

public HTTPClientPolicy getClient(Message message)

getClient

public HTTPClientPolicy getClient()
This method retrieves the Client Side Policy set/configured for this HTTPConduit.


setClient

public void setClient(HTTPClientPolicy client)
This method sets the Client Side Policy for this HTTPConduit. Using this method will override any HTTPClientPolicy set in configuration.


getProxyAuthorization

public ProxyAuthorizationPolicy getProxyAuthorization()
This method retrieves the Proxy Authorization Policy for a proxy that is set/configured for this HTTPConduit.


setProxyAuthorization

public void setProxyAuthorization(ProxyAuthorizationPolicy proxyAuthorization)
This method sets the Proxy Authorization Policy for a specified proxy. Using this method overrides any Authorization Policy for the proxy that is set in the configuration.


getTlsClientParameters

public TLSClientParameters getTlsClientParameters()
This method returns the TLS Client Parameters that is set/configured for this HTTPConduit.


setTlsClientParameters

public void setTlsClientParameters(TLSClientParameters params)
This method sets the TLS Client Parameters for this HTTPConduit. Using this method overrides any TLS Client Parameters that is configured for this HTTPConduit.


getTrustDecider

public MessageTrustDecider getTrustDecider()
This method gets the Trust Decider that was set/configured for this HTTPConduit.

Returns:
The Message Trust Decider or null.

setTrustDecider

public void setTrustDecider(MessageTrustDecider decider)
This method sets the Trust Decider for this HTTP Conduit. Using this method overrides any trust decider configured for this HTTPConduit.


getAuthSupplier

public HttpAuthSupplier getAuthSupplier()
This method gets the Auth Supplier that was set/configured for this HTTPConduit.

Returns:
The Auth Supplier or null.

setAuthSupplier

public void setAuthSupplier(HttpAuthSupplier supplier)

getProxyAuthSupplier

public HttpAuthSupplier getProxyAuthSupplier()

setProxyAuthSupplier

public void setProxyAuthSupplier(HttpAuthSupplier proxyAuthSupplier)

assertMessage

public void assertMessage(Message message)
Specified by:
assertMessage in interface Assertor

canAssert

public boolean canAssert(QName type)
Specified by:
canAssert in interface Assertor

propertyChange

public void propertyChange(PropertyChangeEvent evt)
Specified by:
propertyChange in interface PropertyChangeListener

Apache CXF API

Apache CXF