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


Java RemoteInvocation类代码示例

本文整理汇总了Java中org.springframework.remoting.support.RemoteInvocation的典型用法代码示例。如果您正苦于以下问题:Java RemoteInvocation类的具体用法?Java RemoteInvocation怎么用?Java RemoteInvocation使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


RemoteInvocation类属于org.springframework.remoting.support包,在下文中一共展示了RemoteInvocation类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: execute

import org.springframework.remoting.support.RemoteInvocation; //导入依赖的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: invoke

import org.springframework.remoting.support.RemoteInvocation; //导入依赖的package包/类
@Override
protected Object invoke(final RemoteInvocation invocation, final Object targetObject)
	throws NoSuchMethodException, IllegalAccessException, InvocationTargetException
{
	Throwable unwrapped = null;
	try
	{
		Object rval = super.invoke(invocation, targetObject);
		rval = initialiser.unwrapHibernate(rval);
		rval = initialiser.initialise(rval, new RemoteSimplifier());
		return rval;
	}
	catch( InvocationTargetException e )
	{
		unwrapped = e.getTargetException();
		Throwable t2 = unwrapped;
		// We want to determine if hibernate exception is thrown at any
		// point
		while( t2 != null )
		{
			if( t2 instanceof NestedRuntimeException )
			{
				logger.error(unwrapped.getMessage(), unwrapped);
				throw new RuntimeApplicationException(unwrapped.getMessage());
			}
			t2 = t2.getCause();
		}
		logger.error("Error invoking " + invocation.getMethodName(), unwrapped);
		throw e;
	}
}
 
开发者ID:equella,项目名称:Equella,代码行数:32,代码来源:RemoteInterceptor.java

示例3: executeRequest

import org.springframework.remoting.support.RemoteInvocation; //导入依赖的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

示例4: createRemoteInvocation

import org.springframework.remoting.support.RemoteInvocation; //导入依赖的package包/类
@Override
public RemoteInvocation createRemoteInvocation(MethodInvocation methodInvocation) {
    SecurityContext securityContext = AppContext.getSecurityContext();

    CubaRemoteInvocation remoteInvocation = new CubaRemoteInvocation(methodInvocation,
            securityContext == null ? null : securityContext.getSessionId());

    if (securityContext != null) {
        UserSession session = securityContext.getSession();

        if (session instanceof ClientBasedSession && ((ClientBasedSession) session).hasRequestScopedInfo()) {
            remoteInvocation.setLocale(session.getLocale() != null ? session.getLocale().toLanguageTag() : null);
            remoteInvocation.setTimeZone(session.getTimeZone());
            remoteInvocation.setAddress(session.getAddress());
            remoteInvocation.setClientInfo(session.getClientInfo());
        }
    }

    return remoteInvocation;
}
 
开发者ID:cuba-platform,项目名称:cuba,代码行数:21,代码来源:CubaRemoteInvocationFactory.java

示例5: executeRequest

import org.springframework.remoting.support.RemoteInvocation; //导入依赖的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

示例6: doRefer

import org.springframework.remoting.support.RemoteInvocation; //导入依赖的package包/类
@SuppressWarnings("unchecked")
protected <T> T doRefer(final Class<T> serviceType, final URL url) throws RpcException {
    final RmiProxyFactoryBean rmiProxyFactoryBean = new RmiProxyFactoryBean();
    //RMI传输时使用自定义的远程执行对象,从而传递额外的参数
    rmiProxyFactoryBean.setRemoteInvocationFactory(new RemoteInvocationFactory() {
        public RemoteInvocation createRemoteInvocation(MethodInvocation methodInvocation) {
            return new RmiRemoteInvocation(methodInvocation);
        }
    });
    rmiProxyFactoryBean.setServiceUrl(url.toIdentityString());
    rmiProxyFactoryBean.setServiceInterface(serviceType);
    rmiProxyFactoryBean.setCacheStub(true);
    rmiProxyFactoryBean.setLookupStubOnStartup(true);
    rmiProxyFactoryBean.setRefreshStubOnConnectFailure(true);
    rmiProxyFactoryBean.afterPropertiesSet();
    return (T) rmiProxyFactoryBean.getObject();
}
 
开发者ID:hufeng,项目名称:dubbo2.js,代码行数:18,代码来源:RmiProtocol.java

示例7: test_for_issue

import org.springframework.remoting.support.RemoteInvocation; //导入依赖的package包/类
public void test_for_issue() throws Exception {
    RemoteInvocation remoteInvocation = new RemoteInvocation();
    remoteInvocation.setMethodName("test");
    remoteInvocation.setParameterTypes(new Class[] { int.class, Date.class,
            String.class });
    remoteInvocation.setArguments(new Object[] { 1, new Date(),
            "this is a test" });
    String json = JSON.toJSONString(remoteInvocation);
    remoteInvocation = JSON.parseObject(json, RemoteInvocation.class);
    System.out.println(remoteInvocation);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:12,代码来源:Issue363.java

示例8: invoke

import org.springframework.remoting.support.RemoteInvocation; //导入依赖的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

示例9: invoke

import org.springframework.remoting.support.RemoteInvocation; //导入依赖的package包/类
/*******************
 * Stub to call the remote invoke() method.
 ******************/
public Object invoke(RemoteInvocation ri) throws RemoteException {
	try {
		Object result = this.ref.invoke(this, RmiInvocationHandler.class.getMethod("invoke", new Class[] {RemoteInvocation.class}), new Object[] { ri }, -5752512342587169831L);
		return result;
	} catch(RuntimeException | RemoteException ex1) {
		throw ex1;
	} catch(Exception ex2) {
		throw new RemoteException("Unexpected exception.", ex2);
	}
}
 
开发者ID:NickstaDB,项目名称:BaRMIe,代码行数:14,代码来源:RmiInvocationWrapper_Stub.java

示例10: writeRemoteInvocation

import org.springframework.remoting.support.RemoteInvocation; //导入依赖的package包/类
@Override
protected void writeRemoteInvocation(RemoteInvocation invocation, OutputStream os) throws IOException
{
	ObjectOutputStream oos = new PluginAwareObjectOutputStream(decorateOutputStream(os));
	try
	{
		doWriteRemoteInvocation(invocation, oos);
		oos.flush();
	}
	finally
	{
		oos.close();
	}
}
 
开发者ID:equella,项目名称:Equella,代码行数:15,代码来源:ClientLauncher.java

示例11: invoke

import org.springframework.remoting.support.RemoteInvocation; //导入依赖的package包/类
/**
 * Delegates the actual invocation handling to the RMI exporter.
 * @see RmiBasedExporter#invoke(org.springframework.remoting.support.RemoteInvocation, Object)
 */
@Override
public Object invoke(RemoteInvocation invocation)
	throws RemoteException, NoSuchMethodException, IllegalAccessException, InvocationTargetException {

	return this.rmiExporter.invoke(invocation, this.wrappedObject);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:11,代码来源:RmiInvocationWrapper.java

示例12: invoke

import org.springframework.remoting.support.RemoteInvocation; //导入依赖的package包/类
/**
 * Redefined here to be visible to RmiInvocationWrapper.
 * Simply delegates to the corresponding superclass method.
 */
@Override
protected Object invoke(RemoteInvocation invocation, Object targetObject)
		throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {

	return super.invoke(invocation, targetObject);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:11,代码来源:RmiBasedExporter.java

示例13: executeRequest

import org.springframework.remoting.support.RemoteInvocation; //导入依赖的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

示例14: handleRequest

import org.springframework.remoting.support.RemoteInvocation; //导入依赖的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

示例15: handle

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