@Override public Object invoke(RemoteInvocation invocation, Object targetObject) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException { assertNotNull(invocation.getAttributes()); assertEquals(1, invocation.getAttributes().size()); assertEquals("myValue", invocation.getAttributes().get("myKey")); assertEquals("myValue", invocation.getAttribute("myKey")); return super.invoke(invocation, targetObject); } });
String host = (String) invocation.getAttribute(SecureRemoteInvocationFactory.HOST_KEY); if (host != null) { builder.host(host); Serializable sessionId = invocation.getAttribute(SecureRemoteInvocationFactory.SESSION_ID_KEY); if (sessionId != null) { builder.sessionId(sessionId);
@Override public RemoteInvocation createRemoteInvocation(MethodInvocation methodInvocation) { RemoteInvocation invocation = new TestRemoteInvocation(methodInvocation); assertNull(invocation.getAttributes()); assertNull(invocation.getAttribute("myKey")); return invocation; } });
@Override public Object invoke(RemoteInvocation invocation, Object targetObject) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException { try { CallContext ctx = (CallContext) invocation.getAttribute("callContext"); if (ctx != null) { CallContextUtil.setContext(ctx); } return super.invoke(invocation, targetObject); } finally { CallContextUtil.clear(); } }
@Override public Object invoke(RemoteInvocation invocation, Object targetObject) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException { assertTrue(invocation instanceof TestRemoteInvocation); assertNull(invocation.getAttributes()); assertNull(invocation.getAttribute("myKey")); return super.invoke(invocation, targetObject); } });
String host = (String) invocation.getAttribute(SecureRemoteInvocationFactory.HOST_KEY); if (host != null) { builder.host(host); Serializable sessionId = invocation.getAttribute(SecureRemoteInvocationFactory.SESSION_ID_KEY); if (sessionId != null) { builder.sessionId(sessionId);
@Override public RemoteInvocation createRemoteInvocation(MethodInvocation methodInvocation) { RemoteInvocation invocation = new RemoteInvocation(methodInvocation); invocation.addAttribute("myKey", "myValue"); try { invocation.addAttribute("myKey", "myValue"); fail("Should have thrown IllegalStateException"); } catch (IllegalStateException ex) { // expected: already defined } assertNotNull(invocation.getAttributes()); assertEquals(1, invocation.getAttributes().size()); assertEquals("myValue", invocation.getAttributes().get("myKey")); assertEquals("myValue", invocation.getAttribute("myKey")); return invocation; } });
public void handleRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { try { RemoteInvocation invocation = readRemoteInvocation(request); Serializable interfaceNameObject = invocation.getAttribute(ServiceRegistryHttpInvokerProxyFactoryBean.ATTRIBUTE_INTERFACE_NAME); if (interfaceNameObject == null) { throw new NestedServletException("Interface name attribute not found. This class can only service requests to a " + ServiceRegistryHttpInvokerProxyFactoryBean.class.getSimpleName() + " client."); } else { String interfaceName = (String)interfaceNameObject; try { //RemoteInvocationResult result = invokeAndCreateResult(invocation, getProxy()); // TODO: Use a method similar to {@link RemoteExporter#getProxyForService()} to create an // interface proxy that masks any other methods on the remotely invoked object. RemoteInvocationResult result = invokeAndCreateResult(invocation, serviceRegistry.findProvider(Class.forName(interfaceName))); writeRemoteInvocationResult(request, response, result); } catch (IllegalArgumentException e) { throw new NestedServletException("No provider registered for interface " + interfaceName, e); } } } catch (ClassNotFoundException e) { throw new NestedServletException("Class not found during deserialization", e); } } }