org.springframework.extensions.webscripts.connector
Class HttpConnector

java.lang.Object
  extended by org.springframework.extensions.webscripts.connector.AbstractConnector
      extended by org.springframework.extensions.webscripts.connector.HttpConnector
All Implemented Interfaces:
Connector
Direct Known Subclasses:
AlfrescoConnector

public class HttpConnector
extends AbstractConnector

Basic Connector implementation that can be used to perform simple HTTP and HTTP communication with a remote endpoint. This connector supports basic HTTP authentication via the RemoteClient.

Author:
muzquiano, kevinr

Field Summary
 
Fields inherited from class org.springframework.extensions.webscripts.connector.AbstractConnector
connectorSession, descriptor, endpoint
 
Constructor Summary
HttpConnector(RemoteConfigElement.ConnectorDescriptor descriptor, String endpoint)
          Instantiates a new http connector.
 
Method Summary
protected  void applyRequestAuthentication(RemoteClient remoteClient, ConnectorContext context)
          Stamps Credentials values onto the remote client
 Response call(String uri, ConnectorContext context)
          Invokes a URI on a remote service.
 Response call(String uri, ConnectorContext context, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
          Invokes a URI on a remote service and streams back results to the provided response object.
 Response call(String uri, ConnectorContext context, InputStream in)
          Invokes a URI on a remote service, passing the input as supplied via a POST/PUT.
 Response call(String uri, ConnectorContext context, InputStream in, OutputStream out)
          Invokes a URI on a remote service.
protected  RemoteClient initRemoteClient(ConnectorContext context)
          Init the RemoteClient object based on the Connector Context.
protected  void processResponse(RemoteClient remoteClient, Response response)
          Retrieves headers from response and stores back onto Credentials
 
Methods inherited from class org.springframework.extensions.webscripts.connector.AbstractConnector
call, getConnectorSession, getCredentials, getEndpoint, setConnectorSession, setCredentials, setEndpoint, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

HttpConnector

public HttpConnector(RemoteConfigElement.ConnectorDescriptor descriptor,
                     String endpoint)
Instantiates a new http connector.

Parameters:
descriptor - the descriptor
endpoint - the endpoint
Method Detail

call

public Response call(String uri,
                     ConnectorContext context)
Description copied from interface: Connector
Invokes a URI on a remote service. If the context is null, then it will not be utilized. The response data is buffered into a data element on the returned object of type Response.

Parameters:
uri - the uri
context - the context of the invoke
Returns:
the response

call

public Response call(String uri,
                     ConnectorContext context,
                     InputStream in)
Description copied from interface: Connector
Invokes a URI on a remote service, passing the input as supplied via a POST/PUT. If the context is null, then it will not be utilized and POST will be assumed. The response data is buffered into a data element on the returned object of type Response.

Parameters:
uri - the uri
context - the context of the invoke
in - the input stream
Returns:
the response

call

public Response call(String uri,
                     ConnectorContext context,
                     InputStream in,
                     OutputStream out)
Description copied from interface: Connector
Invokes a URI on a remote service. Data is streamed back from the response into the provided output stream. Headers and response state is maintained on the Response object. If the context is null, then it will not be utilized. The response data is not buffered

Parameters:
uri - the uri
context - the context of the invoke
in - the input stream
out - the output stream
Returns:
the response

call

public Response call(String uri,
                     ConnectorContext context,
                     javax.servlet.http.HttpServletRequest req,
                     javax.servlet.http.HttpServletResponse res)
Description copied from interface: Connector
Invokes a URI on a remote service and streams back results to the provided response object. This method makes sure that the full response is propagated into the servlet response, including headers, exception states and more. If the context is null, then it will not be utilized. The response data is not buffered.

Parameters:
uri - the uri
context - the context of the invoke
req - Request to proxy from
res - Response to proxy onto
Returns:
the response

applyRequestAuthentication

protected void applyRequestAuthentication(RemoteClient remoteClient,
                                          ConnectorContext context)
Stamps Credentials values onto the remote client

Parameters:
remoteClient -

processResponse

protected void processResponse(RemoteClient remoteClient,
                               Response response)
Retrieves headers from response and stores back onto Credentials

Parameters:
response -

initRemoteClient

protected RemoteClient initRemoteClient(ConnectorContext context)
Init the RemoteClient object based on the Connector Context. Applies Request headers and authentication as required.

Returns:
RemoteClient


Copyright © 2009 SpringSource, Inc. All Rights Reserved.