|
The Spring Framework | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.remoting.support.RemoteExporter org.springframework.remoting.support.RemoteInvocationBasedExporter org.springframework.remoting.httpinvoker.HttpInvokerServiceExporter
public class HttpInvokerServiceExporter
HTTP request handler that exports the specified service bean as HTTP invoker service endpoint, accessible via an HTTP invoker proxy.
Deserializes remote invocation objects and serializes remote invocation result objects. Uses Java serialization just like RMI, but provides the same ease of setup as Caucho's HTTP-based Hessian and Burlap protocols.
HTTP invoker is the recommended protocol for Java-to-Java remoting. It is more powerful and more extensible than Hessian and Burlap, at the expense of being tied to Java. Nevertheless, it is as easy to set up as Hessian and Burlap, which is its main advantage compared to RMI.
HttpInvokerClientInterceptor
,
HttpInvokerProxyFactoryBean
,
RmiServiceExporter
,
HessianServiceExporter
,
BurlapServiceExporter
Field Summary | |
---|---|
static String |
CONTENT_TYPE_SERIALIZED_OBJECT
Default content type: "application/x-java-serialized-object" |
Fields inherited from class org.springframework.remoting.support.RemoteExporter |
---|
logger |
Constructor Summary | |
---|---|
HttpInvokerServiceExporter()
|
Method Summary | |
---|---|
void |
afterPropertiesSet()
Invoked by a BeanFactory after it has set all bean properties supplied (and satisfied BeanFactoryAware and ApplicationContextAware). |
protected ObjectInputStream |
createObjectInputStream(InputStream is)
Create an ObjectInputStream for the given InputStream. |
protected ObjectOutputStream |
createObjectOutputStream(OutputStream os)
Create an ObjectOutputStream for the given OutputStream. |
protected InputStream |
decorateInputStream(HttpServletRequest request,
InputStream is)
Return the InputStream to use for reading remote invocations, potentially decorating the given original InputStream. |
protected OutputStream |
decorateOutputStream(HttpServletRequest request,
HttpServletResponse response,
OutputStream os)
Return the OutputStream to use for writing remote invocation results, potentially decorating the given original OutputStream. |
protected RemoteInvocation |
doReadRemoteInvocation(ObjectInputStream ois)
Perform the actual reading of an invocation result object from the given ObjectInputStream. |
protected void |
doWriteRemoteInvocationResult(RemoteInvocationResult result,
ObjectOutputStream oos)
Perform the actual writing of the given invocation result object to the given ObjectOutputStream. |
String |
getContentType()
Return the content type to use for sending HTTP invoker responses. |
void |
handleRequest(HttpServletRequest request,
HttpServletResponse response)
Reads a remote invocation from the request, executes it, and writes the remote invocation result to the response. |
void |
prepare()
Initialize this service exporter. |
protected RemoteInvocation |
readRemoteInvocation(HttpServletRequest request)
Read a RemoteInvocation from the given HTTP request. |
protected RemoteInvocation |
readRemoteInvocation(HttpServletRequest request,
InputStream is)
Deserialize a RemoteInvocation object from the given InputStream. |
void |
setContentType(String contentType)
Specify the content type to use for sending HTTP invoker responses. |
protected void |
writeRemoteInvocationResult(HttpServletRequest request,
HttpServletResponse response,
RemoteInvocationResult result)
Write the given RemoteInvocationResult to the given HTTP response. |
protected void |
writeRemoteInvocationResult(HttpServletRequest request,
HttpServletResponse response,
RemoteInvocationResult result,
OutputStream os)
Serialize the given RemoteInvocation to the given OutputStream. |
Methods inherited from class org.springframework.remoting.support.RemoteInvocationBasedExporter |
---|
getRemoteInvocationExecutor, invoke, invokeAndCreateResult, setRemoteInvocationExecutor |
Methods inherited from class org.springframework.remoting.support.RemoteExporter |
---|
checkService, checkServiceInterface, getExporterName, getProxyForService, getService, getServiceInterface, isRegisterTraceInterceptor, setBeanClassLoader, setRegisterTraceInterceptor, setService, setServiceInterface |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String CONTENT_TYPE_SERIALIZED_OBJECT
Constructor Detail |
---|
public HttpInvokerServiceExporter()
Method Detail |
---|
public void setContentType(String contentType)
Default is "application/x-java-serialized-object".
public String getContentType()
public void afterPropertiesSet()
InitializingBean
This method allows the bean instance to perform initialization only possible when all bean properties have been set and to throw an exception in the event of misconfiguration.
afterPropertiesSet
in interface InitializingBean
public void prepare()
public void handleRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
handleRequest
in interface HttpRequestHandler
request
- current HTTP requestresponse
- current HTTP response
ServletException
- in case of general errors
IOException
- in case of I/O errorsreadRemoteInvocation(HttpServletRequest)
,
RemoteInvocationBasedExporter.invokeAndCreateResult(org.springframework.remoting.support.RemoteInvocation, Object)
,
writeRemoteInvocationResult(HttpServletRequest, HttpServletResponse, RemoteInvocationResult)
protected RemoteInvocation readRemoteInvocation(HttpServletRequest request) throws IOException, ClassNotFoundException
Delegates to
readRemoteInvocation(javax.servlet.http.HttpServletRequest, java.io.InputStream)
with the
servlet request's input stream
.
request
- current HTTP request
IOException
- in case of I/O failure
ClassNotFoundException
- if thrown by deserializationprotected RemoteInvocation readRemoteInvocation(HttpServletRequest request, InputStream is) throws IOException, ClassNotFoundException
Gives decorateInputStream(javax.servlet.http.HttpServletRequest, java.io.InputStream)
a chance to decorate the stream
first (for example, for custom encryption or compression). Creates a
CodebaseAwareObjectInputStream
and calls doReadRemoteInvocation(java.io.ObjectInputStream)
to actually read the object.
Can be overridden for custom serialization of the invocation.
request
- current HTTP requestis
- the InputStream to read from
IOException
- in case of I/O failure
ClassNotFoundException
- if thrown during deserializationprotected InputStream decorateInputStream(HttpServletRequest request, InputStream is) throws IOException
The default implementation returns the given stream as-is. Can be overridden, for example, for custom encryption or compression.
request
- current HTTP requestis
- the original InputStream
IOException
- in case of I/O failureprotected ObjectInputStream createObjectInputStream(InputStream is) throws IOException
The default implementation creates a Spring
CodebaseAwareObjectInputStream
.
Spring's CodebaseAwareObjectInputStream is used to explicitly resolve primitive class names. This is done by the standard ObjectInputStream on JDK 1.4+, but needs to be done explicitly on JDK 1.3.
is
- the InputStream to read from
IOException
- if creation of the ObjectInputStream failedprotected RemoteInvocation doReadRemoteInvocation(ObjectInputStream ois) throws IOException, ClassNotFoundException
The default implementation simply calls
ObjectInputStream.readObject()
.
Can be overridden for deserialization of a custom wrapper object rather
than the plain invocation, for example an encryption-aware holder.
ois
- the ObjectInputStream to read from
IOException
- in case of I/O failure
ClassNotFoundException
- if case of a transferred class not
being found in the local ClassLoaderprotected void writeRemoteInvocationResult(HttpServletRequest request, HttpServletResponse response, RemoteInvocationResult result) throws IOException
request
- current HTTP requestresponse
- current HTTP responseresult
- the RemoteInvocationResult object
IOException
- in case of I/O failureprotected void writeRemoteInvocationResult(HttpServletRequest request, HttpServletResponse response, RemoteInvocationResult result, OutputStream os) throws IOException
The default implementation gives decorateOutputStream(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, java.io.OutputStream)
a chance
to decorate the stream first (for example, for custom encryption or compression).
Creates an ObjectOutputStream
for the final stream and calls
doWriteRemoteInvocationResult(org.springframework.remoting.support.RemoteInvocationResult, java.io.ObjectOutputStream)
to actually write the object.
Can be overridden for custom serialization of the invocation.
request
- current HTTP requestresponse
- current HTTP responseresult
- the RemoteInvocationResult objectos
- the OutputStream to write to
IOException
- in case of I/O failuredecorateOutputStream(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, java.io.OutputStream)
,
doWriteRemoteInvocationResult(org.springframework.remoting.support.RemoteInvocationResult, java.io.ObjectOutputStream)
protected OutputStream decorateOutputStream(HttpServletRequest request, HttpServletResponse response, OutputStream os) throws IOException
The default implementation returns the given stream as-is. Can be overridden, for example, for custom encryption or compression.
request
- current HTTP requestresponse
- current HTTP responseos
- the original OutputStream
IOException
- in case of I/O failureprotected ObjectOutputStream createObjectOutputStream(OutputStream os) throws IOException
The default implementation creates a plain
ObjectOutputStream
.
os
- the OutputStream to write to
IOException
- if creation of the ObjectOutputStream failedprotected void doWriteRemoteInvocationResult(RemoteInvocationResult result, ObjectOutputStream oos) throws IOException
The default implementation simply calls
ObjectOutputStream.writeObject(java.lang.Object)
.
Can be overridden for serialization of a custom wrapper object rather
than the plain invocation, for example an encryption-aware holder.
result
- the RemoteInvocationResult objectoos
- the ObjectOutputStream to write to
IOException
- if thrown by I/O methods
|
The Spring Framework | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |