本文整理汇总了Java中org.springframework.remoting.support.RemoteInvocationResult类的典型用法代码示例。如果您正苦于以下问题:Java RemoteInvocationResult类的具体用法?Java RemoteInvocationResult怎么用?Java RemoteInvocationResult使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RemoteInvocationResult类属于org.springframework.remoting.support包,在下文中一共展示了RemoteInvocationResult类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: execute
import org.springframework.remoting.support.RemoteInvocationResult; //导入依赖的package包/类
@Override
public void execute(RemoteInvocationRequest request, StreamObserver<RemoteInvocationResponse> responseObserver) {
try {
ByteArrayInputStream in = new ByteArrayInputStream(request.getData().toByteArray());
ObjectInputStream is = new ObjectInputStream(in);
RemoteInvocation remoteInvocation = (RemoteInvocation) is.readObject();
RemoteInvocationResult remoteInvocationResult = exporter.invokeForInvocation(remoteInvocation);
ByteArrayOutputStream out = new ByteArrayOutputStream();
ObjectOutputStream os = new ObjectOutputStream(out);
os.writeObject(remoteInvocationResult);
responseObserver.onNext(RemoteInvocationResponse.newBuilder().setData(ByteString.copyFrom(out.toByteArray())).build());
responseObserver.onCompleted();
} catch (Exception e) {
responseObserver.onError(e);
}
}
示例2: doExecuteRequest
import org.springframework.remoting.support.RemoteInvocationResult; //导入依赖的package包/类
/**
* Execute the given request through the HttpClient.
* <p>This method implements the basic processing workflow:
* The actual work happens in this class's template methods.
* @see #createHttpPost
* @see #setRequestBody
* @see #executeHttpPost
* @see #validateResponse
* @see #getResponseBody
*/
@Override
protected RemoteInvocationResult doExecuteRequest(
HttpInvokerClientConfiguration config, ByteArrayOutputStream baos)
throws IOException, ClassNotFoundException {
HttpPost postMethod = createHttpPost(config);
setRequestBody(config, postMethod, baos);
try {
HttpResponse response = executeHttpPost(config, getHttpClient(), postMethod);
validateResponse(config, response);
InputStream responseBody = getResponseBody(config, response);
return readRemoteInvocationResult(responseBody, config.getCodebaseUrl());
}
finally {
postMethod.releaseConnection();
}
}
示例3: doExecuteRequest
import org.springframework.remoting.support.RemoteInvocationResult; //导入依赖的package包/类
@Override
protected RemoteInvocationResult doExecuteRequest(
HttpInvokerClientConfiguration config, ByteArrayOutputStream baos)
throws IOException, ClassNotFoundException {
PostMethod postMethod = createPostMethod(config);
try {
postMethod.setRequestBody(new ByteArrayInputStream(baos.toByteArray()));
executePostMethod(config, this.httpClient, postMethod);
return readRemoteInvocationResult(postMethod.getResponseBodyAsStream(), config.getCodebaseUrl());
}
finally {
// need to explicitly release because it might be pooled
postMethod.releaseConnection();
}
}
示例4: executeRequest
import org.springframework.remoting.support.RemoteInvocationResult; //导入依赖的package包/类
/**
* Execute the given remote invocation, sending an invoker request message
* to this accessor's target queue and waiting for a corresponding response.
* @param invocation the RemoteInvocation to execute
* @return the RemoteInvocationResult object
* @throws JMSException in case of JMS failure
* @see #doExecuteRequest
*/
protected RemoteInvocationResult executeRequest(RemoteInvocation invocation) throws JMSException {
Connection con = createConnection();
Session session = null;
try {
session = createSession(con);
Queue queueToUse = resolveQueue(session);
Message requestMessage = createRequestMessage(session, invocation);
con.start();
Message responseMessage = doExecuteRequest(session, queueToUse, requestMessage);
if (responseMessage != null) {
return extractInvocationResult(responseMessage);
}
else {
return onReceiveTimeout(invocation);
}
}
finally {
JmsUtils.closeSession(session);
ConnectionFactoryUtils.releaseConnection(con, getConnectionFactory(), true);
}
}
示例5: doExecuteRequest
import org.springframework.remoting.support.RemoteInvocationResult; //导入依赖的package包/类
@Override
protected RemoteInvocationResult doExecuteRequest(
HttpInvokerClientConfiguration config, ByteArrayOutputStream baos)
throws Exception {
if (this.connectTimeout >= 0) {
httpClient.setConnectTimeout(this.connectTimeout);
}
if (this.readTimeout >= 0) {
httpClient.setIdleTimeout(this.readTimeout);
}
ContentResponse response = httpClient.newRequest(config.getServiceUrl())
.method(HttpMethod.POST)
.content(new BytesContentProvider(baos.toByteArray()))
.send();
if (response.getStatus() >= 300) {
throw new IOException(
"Did not receive successful HTTP response: status code = " + response.getStatus() +
", status message = [" + response.getReason() + "]");
}
return readRemoteInvocationResult(new ByteArrayInputStream(response.getContent()), config.getCodebaseUrl());
}
示例6: recreateRemoteInvocationResult
import org.springframework.remoting.support.RemoteInvocationResult; //导入依赖的package包/类
@Override
protected Object recreateRemoteInvocationResult(RemoteInvocationResult result) throws Throwable {
Throwable throwable = result.getException();
if (throwable != null) {
if (throwable instanceof InvocationTargetException)
throwable = ((InvocationTargetException) throwable).getTargetException();
if (throwable instanceof RemoteException) {
Exception exception = ((RemoteException) throwable).getFirstCauseException();
// This is a checked exception declared in a service method
// or runtime exception supported by client
if (exception != null) {
RemoteInvocationUtils.fillInClientStackTraceIfPossible(exception);
throw exception;
}
}
}
return super.recreateRemoteInvocationResult(result);
}
示例7: doExecuteRequest
import org.springframework.remoting.support.RemoteInvocationResult; //导入依赖的package包/类
/**
* Execute the given request through Commons HttpClient.
* <p>This method implements the basic processing workflow:
* The actual work happens in this class's template methods.
* @see #createPostMethod
* @see #setRequestBody
* @see #executePostMethod
* @see #validateResponse
* @see #getResponseBody
*/
@Override
protected RemoteInvocationResult doExecuteRequest(
HttpInvokerClientConfiguration config, ByteArrayOutputStream baos)
throws IOException, ClassNotFoundException {
PostMethod postMethod = createPostMethod(config);
try {
setRequestBody(config, postMethod, baos);
executePostMethod(config, getHttpClient(), postMethod);
validateResponse(config, postMethod);
InputStream responseBody = getResponseBody(config, postMethod);
return readRemoteInvocationResult(responseBody, config.getCodebaseUrl());
}
finally {
// Need to explicitly release because it might be pooled.
postMethod.releaseConnection();
}
}
示例8: doExecuteRequest
import org.springframework.remoting.support.RemoteInvocationResult; //导入依赖的package包/类
/**
* Execute the given request through Commons HttpClient.
* <p>This method implements the basic processing workflow:
* The actual work happens in this class's template methods.
* @see #createPostMethod
* @see #setRequestBody
* @see #executePostMethod
* @see #validateResponse
* @see #getResponseBody
*/
@Override
protected RemoteInvocationResult doExecuteRequest(
HttpInvokerClientConfiguration config, ByteArrayOutputStream baos)
throws IOException, ClassNotFoundException {
PostMethod postMethod = createPostMethod(config);
try {
setRequestBody(config, postMethod, baos);
executePostMethod(config, getHttpClient(), postMethod);
validateResponse(config, postMethod);
InputStream responseBody = getResponseBody(config, postMethod);
return readRemoteInvocationResult(responseBody, config.getCodebaseUrl());
}
finally {
// Need to explicitly release because it might be pooled.
postMethod.releaseConnection();
}
}
示例9: executeRequest
import org.springframework.remoting.support.RemoteInvocationResult; //导入依赖的package包/类
/**
* Execute the given remote invocation, sending an invoker request message
* to this accessor's target queue and waiting for a corresponding response.
* @param invocation the RemoteInvocation to execute
* @return the RemoteInvocationResult object
* @throws JMSException in case of JMS failure
* @see #doExecuteRequest
*/
protected RemoteInvocationResult executeRequest(RemoteInvocation invocation) throws JMSException {
Connection con = createConnection();
Session session = null;
try {
session = createSession(con);
Queue queueToUse = resolveQueue(session);
Message requestMessage = createRequestMessage(session, invocation);
con.start();
Message responseMessage = doExecuteRequest(session, queueToUse, requestMessage);
return extractInvocationResult(responseMessage);
}
finally {
JmsUtils.closeSession(session);
ConnectionFactoryUtils.releaseConnection(con, getConnectionFactory(), true);
}
}
示例10: doExecuteRequest
import org.springframework.remoting.support.RemoteInvocationResult; //导入依赖的package包/类
@Override
protected RemoteInvocationResult doExecuteRequest(HttpInvokerClientConfiguration config, ByteArrayOutputStream baos) throws Exception {
HttpPost postMethod = new HttpPost(config.getServiceUrl());
ByteArrayEntity entity = new ByteArrayEntity(baos.toByteArray());
entity.setContentType(getContentType());
postMethod.setEntity(entity);
BasicHttpContext context = null;
if (environment.useSslContext()) {
context = new BasicHttpContext();
context.setAttribute(HttpClientContext.USER_TOKEN, goAgentServerHttpClient.principal());
}
try (CloseableHttpResponse response = goAgentServerHttpClient.execute(postMethod, context)) {
validateResponse(response);
InputStream responseBody = getResponseBody(response);
return readRemoteInvocationResult(responseBody, config.getCodebaseUrl());
}
}
示例11: invoke
import org.springframework.remoting.support.RemoteInvocationResult; //导入依赖的package包/类
@Override
public Object invoke(MethodInvocation invocation) throws Throwable {
RemoteInvocation remoteInvocation = new RemoteInvocation(invocation);
ByteArrayOutputStream out = new ByteArrayOutputStream();
ObjectOutputStream os = new ObjectOutputStream(out);
os.writeObject(remoteInvocation);
RemoteInvocationResponse remoteInvocationResponse = remotingServiceBlockingStub.execute(RemoteInvocationRequest.newBuilder().setData(ByteString.copyFrom(out.toByteArray())).build());
ByteArrayInputStream in = new ByteArrayInputStream(remoteInvocationResponse.getData().toByteArray());
ObjectInputStream is = new ObjectInputStream(in);
RemoteInvocationResult remoteInvocationResult = (RemoteInvocationResult) is.readObject();
return remoteInvocationResult.getValue();
}
示例12: executeRequest
import org.springframework.remoting.support.RemoteInvocationResult; //导入依赖的package包/类
@Override
public final RemoteInvocationResult executeRequest(
HttpInvokerClientConfiguration config, RemoteInvocation invocation) throws Exception {
ByteArrayOutputStream baos = getByteArrayOutputStream(invocation);
if (logger.isDebugEnabled()) {
logger.debug("Sending HTTP invoker request for service at [" + config.getServiceUrl() +
"], with size " + baos.size());
}
return doExecuteRequest(config, baos);
}
示例13: handleRequest
import org.springframework.remoting.support.RemoteInvocationResult; //导入依赖的package包/类
/**
* Reads a remote invocation from the request, executes it,
* and writes the remote invocation result to the response.
* @see #readRemoteInvocation(HttpServletRequest)
* @see #invokeAndCreateResult(org.springframework.remoting.support.RemoteInvocation, Object)
* @see #writeRemoteInvocationResult(HttpServletRequest, HttpServletResponse, RemoteInvocationResult)
*/
@Override
public void handleRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
try {
RemoteInvocation invocation = readRemoteInvocation(request);
RemoteInvocationResult result = invokeAndCreateResult(invocation, getProxy());
writeRemoteInvocationResult(request, response, result);
}
catch (ClassNotFoundException ex) {
throw new NestedServletException("Class not found during deserialization", ex);
}
}
示例14: writeRemoteInvocationResult
import org.springframework.remoting.support.RemoteInvocationResult; //导入依赖的package包/类
/**
* Write the given RemoteInvocationResult to the given HTTP response.
* @param request current HTTP request
* @param response current HTTP response
* @param result the RemoteInvocationResult object
* @throws IOException in case of I/O failure
*/
protected void writeRemoteInvocationResult(
HttpServletRequest request, HttpServletResponse response, RemoteInvocationResult result)
throws IOException {
response.setContentType(getContentType());
writeRemoteInvocationResult(request, response, result, response.getOutputStream());
}
示例15: handle
import org.springframework.remoting.support.RemoteInvocationResult; //导入依赖的package包/类
/**
* 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);
}
}