Search in sources :

Example 11 with RemoteInvocationResult

use of org.springframework.remoting.support.RemoteInvocationResult in project spring-framework by spring-projects.

the class HttpInvokerClientInterceptor method invoke.

@Override
public Object invoke(MethodInvocation methodInvocation) throws Throwable {
    if (AopUtils.isToStringMethod(methodInvocation.getMethod())) {
        return "HTTP invoker proxy for service URL [" + getServiceUrl() + "]";
    }
    RemoteInvocation invocation = createRemoteInvocation(methodInvocation);
    RemoteInvocationResult result;
    try {
        result = executeRequest(invocation, methodInvocation);
    } catch (Throwable ex) {
        RemoteAccessException rae = convertHttpInvokerAccessException(ex);
        throw (rae != null ? rae : ex);
    }
    try {
        return recreateRemoteInvocationResult(result);
    } catch (Throwable ex) {
        if (result.hasInvocationTargetException()) {
            throw ex;
        } else {
            throw new RemoteInvocationFailureException("Invocation of method [" + methodInvocation.getMethod() + "] failed in HTTP invoker remote service at [" + getServiceUrl() + "]", ex);
        }
    }
}
Also used : RemoteInvocation(org.springframework.remoting.support.RemoteInvocation) RemoteInvocationResult(org.springframework.remoting.support.RemoteInvocationResult) RemoteAccessException(org.springframework.remoting.RemoteAccessException) RemoteInvocationFailureException(org.springframework.remoting.RemoteInvocationFailureException)

Example 12 with RemoteInvocationResult

use of org.springframework.remoting.support.RemoteInvocationResult in project spring-framework by spring-projects.

the class SimpleHttpInvokerServiceExporter method handle.

/**
	 * Reads a remote invocation from the request, executes it,
	 * and writes the remote invocation result to the response.
	 * @see #readRemoteInvocation(com.sun.net.httpserver.HttpExchange)
	 * @see #invokeAndCreateResult(org.springframework.remoting.support.RemoteInvocation, Object)
	 * @see #writeRemoteInvocationResult(com.sun.net.httpserver.HttpExchange, org.springframework.remoting.support.RemoteInvocationResult)
	 */
@Override
public void handle(HttpExchange exchange) throws IOException {
    try {
        RemoteInvocation invocation = readRemoteInvocation(exchange);
        RemoteInvocationResult result = invokeAndCreateResult(invocation, getProxy());
        writeRemoteInvocationResult(exchange, result);
        exchange.close();
    } catch (ClassNotFoundException ex) {
        exchange.sendResponseHeaders(500, -1);
        logger.error("Class not found during deserialization", ex);
    }
}
Also used : RemoteInvocation(org.springframework.remoting.support.RemoteInvocation) RemoteInvocationResult(org.springframework.remoting.support.RemoteInvocationResult)

Example 13 with RemoteInvocationResult

use of org.springframework.remoting.support.RemoteInvocationResult in project spring-framework by spring-projects.

the class JmsInvokerServiceExporter method onMessage.

@Override
public void onMessage(Message requestMessage, Session session) throws JMSException {
    RemoteInvocation invocation = readRemoteInvocation(requestMessage);
    if (invocation != null) {
        RemoteInvocationResult result = invokeAndCreateResult(invocation, this.proxy);
        writeRemoteInvocationResult(requestMessage, session, result);
    }
}
Also used : RemoteInvocation(org.springframework.remoting.support.RemoteInvocation) RemoteInvocationResult(org.springframework.remoting.support.RemoteInvocationResult)

Aggregations

RemoteInvocationResult (org.springframework.remoting.support.RemoteInvocationResult)13 RemoteInvocation (org.springframework.remoting.support.RemoteInvocation)11 IOException (java.io.IOException)7 RemoteAccessException (org.springframework.remoting.RemoteAccessException)7 ITestBean (org.springframework.tests.sample.beans.ITestBean)7 Test (org.junit.Test)6 TestBean (org.springframework.tests.sample.beans.TestBean)6 ByteArrayInputStream (java.io.ByteArrayInputStream)5 ByteArrayOutputStream (java.io.ByteArrayOutputStream)5 ServletException (javax.servlet.ServletException)5 MockHttpServletRequest (org.springframework.mock.web.test.MockHttpServletRequest)5 MockHttpServletResponse (org.springframework.mock.web.test.MockHttpServletResponse)5 InvocationTargetException (java.lang.reflect.InvocationTargetException)4 ObjectInputStream (java.io.ObjectInputStream)2 ObjectOutputStream (java.io.ObjectOutputStream)2 MethodInvocation (org.aopalliance.intercept.MethodInvocation)2 RemoteInvocationFailureException (org.springframework.remoting.RemoteInvocationFailureException)2 DefaultRemoteInvocationExecutor (org.springframework.remoting.support.DefaultRemoteInvocationExecutor)2 RemoteInvocationFactory (org.springframework.remoting.support.RemoteInvocationFactory)2 NestedServletException (org.springframework.web.util.NestedServletException)2