当前位置: 首页>>代码示例>>Java>>正文


Java RemoteInvocationResult类代码示例

本文整理汇总了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);
    }
}
 
开发者ID:vaibhav-sinha,项目名称:spring-remoting-grpc,代码行数:17,代码来源:RemotingServiceImpl.java

示例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();
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:28,代码来源:HttpComponentsHttpInvokerRequestExecutor.java

示例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();
    }
}
 
开发者ID:xingmima,项目名称:dubbos,代码行数:17,代码来源:CommonsHttpInvokerRequestExecutor.java

示例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);
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:30,代码来源:JmsInvokerClientInterceptor.java

示例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());
}
 
开发者ID:thinline72,项目名称:rpc-example,代码行数:27,代码来源:Http2InvokerRequestExecutor.java

示例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);
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:19,代码来源:HttpServiceProxy.java

示例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();
    }
}
 
开发者ID:payneteasy,项目名称:superfly,代码行数:29,代码来源:CommonsHttpInvokerRequestExecutor.java

示例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();
	}
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:29,代码来源:CommonsHttpInvokerRequestExecutor.java

示例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);
	}
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:25,代码来源:JmsInvokerClientInterceptor.java

示例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());
    }
}
 
开发者ID:gocd,项目名称:gocd,代码行数:22,代码来源:GoHttpClientHttpInvokerRequestExecutor.java

示例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();
}
 
开发者ID:vaibhav-sinha,项目名称:spring-remoting-grpc,代码行数:13,代码来源:GrpcInvokerProxyFactoryBean.java

示例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);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:12,代码来源:AbstractHttpInvokerRequestExecutor.java

示例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);
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:21,代码来源:HttpInvokerServiceExporter.java

示例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());
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:15,代码来源:HttpInvokerServiceExporter.java

示例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);
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:21,代码来源:SimpleHttpInvokerServiceExporter.java


注:本文中的org.springframework.remoting.support.RemoteInvocationResult类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。