Class HttpConnector
- java.lang.Object
-
- org.springframework.extensions.webscripts.connector.AbstractConnector
-
- org.springframework.extensions.webscripts.connector.HttpConnector
-
- All Implemented Interfaces:
org.springframework.beans.factory.Aware,org.springframework.context.ApplicationContextAware,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
Constructors Constructor Description HttpConnector(RemoteConfigElement.ConnectorDescriptor descriptor, java.lang.String endpoint)Instantiates a new http connector.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidapplyRequestAuthentication(RemoteClient remoteClient, ConnectorContext context)Stamps Credentials values onto the remote clientprotected voidapplyRequestHeaders(RemoteClient remoteClient, ConnectorContext context)Stamps headers onto the remote clientResponsecall(java.lang.String uri, ConnectorContext context)Invokes a URI on a remote service.Responsecall(java.lang.String uri, ConnectorContext context, java.io.InputStream in)Invokes a URI on a remote service, passing the input as supplied via a POST/PUT.Responsecall(java.lang.String uri, ConnectorContext context, java.io.InputStream in, java.io.OutputStream out)Invokes a URI on a remote service.Responsecall(java.lang.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.protected RemoteClientinitRemoteClient(ConnectorContext context)Init the RemoteClient object based on the Connector Context.protected voidprocessResponse(RemoteClient remoteClient, Response response)Retrieves cookie headers from response and stores back onto the Connector Session-
Methods inherited from class org.springframework.extensions.webscripts.connector.AbstractConnector
buildRemoteClient, call, getConnectorSession, getCredentials, getEndpoint, setApplicationContext, setConnectorSession, setCredentials, setEndpoint, toString
-
-
-
-
Constructor Detail
-
HttpConnector
public HttpConnector(RemoteConfigElement.ConnectorDescriptor descriptor, java.lang.String endpoint)
Instantiates a new http connector.- Parameters:
descriptor- the descriptorendpoint- the endpoint
-
-
Method Detail
-
call
public Response call(java.lang.String uri, ConnectorContext context)
Description copied from interface:ConnectorInvokes 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 uricontext- the context of the invoke- Returns:
- the response
-
call
public Response call(java.lang.String uri, ConnectorContext context, java.io.InputStream in)
Description copied from interface:ConnectorInvokes 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 uricontext- the context of the invokein- the input stream- Returns:
- the response
-
call
public Response call(java.lang.String uri, ConnectorContext context, java.io.InputStream in, java.io.OutputStream out)
Description copied from interface:ConnectorInvokes 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 uricontext- the context of the invokein- the input streamout- the output stream- Returns:
- the response
-
call
public Response call(java.lang.String uri, ConnectorContext context, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
Description copied from interface:ConnectorInvokes 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 uricontext- the context of the invokereq- Request to proxy fromres- Response to proxy onto- Returns:
- the response
-
applyRequestHeaders
protected void applyRequestHeaders(RemoteClient remoteClient, ConnectorContext context)
Stamps headers onto the remote client- Parameters:
remoteClient- RemoteClientcontext- ConnectorContext
-
applyRequestAuthentication
protected void applyRequestAuthentication(RemoteClient remoteClient, ConnectorContext context)
Stamps Credentials values onto the remote client- Parameters:
remoteClient- RemoteClientcontext- ConnectorContext
-
processResponse
protected void processResponse(RemoteClient remoteClient, Response response)
Retrieves cookie headers from response and stores back onto the Connector Session- Parameters:
remoteClient- RemoteClientresponse- 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
-
-