use of org.springframework.remoting.support.RemoteInvocation in project dubbo by alibaba.
the class HttpProtocol method doRefer.
@SuppressWarnings("unchecked")
@Override
protected <T> T doRefer(final Class<T> serviceType, URL url) throws RpcException {
final String generic = url.getParameter(GENERIC_KEY);
final boolean isGeneric = ProtocolUtils.isGeneric(generic) || serviceType.equals(GenericService.class);
JsonProxyFactoryBean jsonProxyFactoryBean = new JsonProxyFactoryBean();
JsonRpcProxyFactoryBean jsonRpcProxyFactoryBean = new JsonRpcProxyFactoryBean(jsonProxyFactoryBean);
jsonRpcProxyFactoryBean.setRemoteInvocationFactory((methodInvocation) -> {
RemoteInvocation invocation = new JsonRemoteInvocation(methodInvocation);
if (isGeneric) {
invocation.addAttribute(GENERIC_KEY, generic);
}
return invocation;
});
String key = url.setProtocol("http").toIdentityString();
if (isGeneric) {
key = key + "/" + GENERIC_KEY;
}
jsonRpcProxyFactoryBean.setServiceUrl(key);
jsonRpcProxyFactoryBean.setServiceInterface(serviceType);
jsonProxyFactoryBean.afterPropertiesSet();
return (T) jsonProxyFactoryBean.getObject();
}
use of org.springframework.remoting.support.RemoteInvocation in project fastjson by alibaba.
the class Issue363 method test_for_issue.
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);
}
use of org.springframework.remoting.support.RemoteInvocation in project gocd by gocd.
the class AgentRemoteInvokerServiceExporterTest method reportCompleted_rejectedForDifferentUUID.
@Test
void reportCompleted_rejectedForDifferentUUID() throws Exception {
final AgentRuntimeInfo agent = runtimeInfo("other");
final AgentRemoteInvokerServiceExporter invoker = deserializingWith(new RemoteInvocation("reportCompleted", new Class[] { AgentRuntimeInfo.class, JobIdentifier.class, JobResult.class }, new Object[] { agent, null, null }));
invoker.handleRequest(req, res);
verify(target, never()).reportCompleted(any(AgentRuntimeInfo.class), any(JobIdentifier.class), any(JobResult.class));
assertEquals(SC_FORBIDDEN, res.getStatus());
}
use of org.springframework.remoting.support.RemoteInvocation in project gocd by gocd.
the class AgentRemoteInvokerServiceExporterTest method deserializingWith.
private AgentRemoteInvokerServiceExporter deserializingWith(final RemoteInvocation invocation) {
final AgentRemoteInvokerServiceExporter invoker = new AgentRemoteInvokerServiceExporter(env) {
@Override
protected Object getProxyForService() {
return target;
}
@Override
protected RemoteInvocation readRemoteInvocation(HttpServletRequest request) {
return invocation;
}
@Override
protected RemoteInvocationResult invokeAndCreateResult(RemoteInvocation invocation, Object targetObject) {
try {
invocation.invoke(targetObject);
return new RemoteInvocationResult(true);
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
e.printStackTrace();
fail("invoke() failed; should never get here. error: " + e.getMessage());
return new RemoteInvocationResult(false);
}
}
@Override
protected void writeRemoteInvocationResult(HttpServletRequest request, HttpServletResponse response, RemoteInvocationResult result) {
if ((Boolean) result.getValue()) {
response.setStatus(SC_OK);
} else {
response.setStatus(SC_INTERNAL_SERVER_ERROR);
}
}
};
invoker.prepare();
return invoker;
}
use of org.springframework.remoting.support.RemoteInvocation in project gocd by gocd.
the class AgentRemoteInvokerServiceExporterTest method reportCompleted_allowedForSameUUID.
@Test
void reportCompleted_allowedForSameUUID() throws Exception {
final AgentRuntimeInfo agent = runtimeInfo(AGENT_UUID);
final AgentRemoteInvokerServiceExporter invoker = deserializingWith(new RemoteInvocation("reportCompleted", new Class[] { AgentRuntimeInfo.class, JobIdentifier.class, JobResult.class }, new Object[] { agent, null, null }));
invoker.handleRequest(req, res);
verify(target, only()).reportCompleted(agent, null, null);
assertEquals(SC_OK, res.getStatus());
}
Aggregations