/** * Create a new RemoteInvocation object for the given AOP method invocation. * <p>The default implementation delegates to the configured * {@link #setRemoteInvocationFactory RemoteInvocationFactory}. * This can be overridden in subclasses in order to provide custom RemoteInvocation * subclasses, containing additional invocation parameters (e.g. user credentials). * <p>Note that it is preferable to build a custom RemoteInvocationFactory * as a reusable strategy, instead of overriding this method. * @param methodInvocation the current AOP method invocation * @return the RemoteInvocation object * @see RemoteInvocationFactory#createRemoteInvocation */ protected RemoteInvocation createRemoteInvocation(MethodInvocation methodInvocation) { return getRemoteInvocationFactory().createRemoteInvocation(methodInvocation); }
/** * 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); }
/** * Set the RemoteInvocationFactory to use for this accessor. * Default is a {@link DefaultRemoteInvocationFactory}. * <p>A custom invocation factory can add further context information * to the invocation, for example user credentials. */ public void setRemoteInvocationFactory(RemoteInvocationFactory remoteInvocationFactory) { this.remoteInvocationFactory = (remoteInvocationFactory != null ? remoteInvocationFactory : new DefaultRemoteInvocationFactory()); }
/** * Apply the given remote invocation to the given target object, wrapping * the invocation result in a serializable RemoteInvocationResult object. * The default implementation creates a plain RemoteInvocationResult. * <p>Can be overridden in subclasses for custom invocation behavior, * for example to return additional context information. Note that this * is not covered by the RemoteInvocationExecutor strategy! * @param invocation the remote invocation * @param targetObject the target object to apply the invocation to * @return the invocation result * @see #invoke */ protected RemoteInvocationResult invokeAndCreateResult(RemoteInvocation invocation, Object targetObject) { try { Object value = invoke(invocation, targetObject); return new RemoteInvocationResult(value); } catch (Throwable ex) { return new RemoteInvocationResult(ex); } }
@Override public Object invoke(RemoteInvocation invocation, Object targetObject) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException{ Assert.notNull(invocation, "RemoteInvocation must not be null"); Assert.notNull(targetObject, "Target object must not be null"); return invocation.invoke(targetObject); }
@Override public RemoteInvocation createRemoteInvocation(MethodInvocation methodInvocation) { return new RemoteInvocation(methodInvocation); }
@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); } });
/** * Recreate the invocation result contained in the given RemoteInvocationResult object. * <p>The default implementation calls the default {@code recreate()} method. * This can be overridden in subclass to provide custom recreation, potentially * processing the returned result object. * @param result the RemoteInvocationResult to recreate * @return a return value if the invocation result is a successful return * @throws Throwable if the invocation result is an exception * @see RemoteInvocationResult#recreate() */ protected Object recreateRemoteInvocationResult(RemoteInvocationResult result) throws Throwable { return result.recreate(); }
/** * Create a new {@code RemoteInvocation} object for the given AOP method invocation. * <p>The default implementation delegates to the {@link RemoteInvocationFactory}. * <p>Can be overridden in subclasses to provide custom {@code RemoteInvocation} * subclasses, containing additional invocation parameters like user credentials. * Note that it is preferable to use a custom {@code RemoteInvocationFactory} which * is a reusable strategy. * @param methodInvocation the current AOP method invocation * @return the RemoteInvocation object * @see RemoteInvocationFactory#createRemoteInvocation */ protected RemoteInvocation createRemoteInvocation(MethodInvocation methodInvocation) { return this.remoteInvocationFactory.createRemoteInvocation(methodInvocation); }
@Override public void afterPropertiesSet() { super.afterPropertiesSet(); prepare(); }
@Override public void afterPropertiesSet() { super.afterPropertiesSet(); prepare(); }
@Test public void fillInClientStackTraceIfPossibleWithNullThrowable() throws Exception { // just want to ensure that it doesn't bomb RemoteInvocationUtils.fillInClientStackTraceIfPossible(null); }
@Override public void afterPropertiesSet() { if (getServiceUrl() == null) { throw new IllegalArgumentException("Property 'serviceUrl' is required"); } }
/** * Check whether the service reference has been set. * @see #setService */ protected void checkService() throws IllegalArgumentException { Assert.notNull(getService(), "Property 'service' is required"); }
@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); } });
/** * Recreate the invocation result contained in the given {@link RemoteInvocationResult} * object. * <p>The default implementation calls the default {@code recreate()} method. * <p>Can be overridden in subclasses to provide custom recreation, potentially * processing the returned result object. * @param result the RemoteInvocationResult to recreate * @return a return value if the invocation result is a successful return * @throws Throwable if the invocation result is an exception * @see org.springframework.remoting.support.RemoteInvocationResult#recreate() */ @Nullable protected Object recreateRemoteInvocationResult(RemoteInvocationResult result) throws Throwable { return result.recreate(); }
/** * Set the {@link RemoteInvocationFactory} to use for this accessor. * <p>Default is a {@link DefaultRemoteInvocationFactory}. * <p>A custom invocation factory can add further context information * to the invocation, for example user credentials. */ public void setRemoteInvocationFactory(@Nullable RemoteInvocationFactory remoteInvocationFactory) { this.remoteInvocationFactory = (remoteInvocationFactory != null ? remoteInvocationFactory : new DefaultRemoteInvocationFactory()); }
/** * Create a new RemoteInvocation object for the given AOP method invocation. * <p>The default implementation delegates to the configured * {@link #setRemoteInvocationFactory RemoteInvocationFactory}. * This can be overridden in subclasses in order to provide custom RemoteInvocation * subclasses, containing additional invocation parameters (e.g. user credentials). * <p>Note that it is preferable to build a custom RemoteInvocationFactory * as a reusable strategy, instead of overriding this method. * @param methodInvocation the current AOP method invocation * @return the RemoteInvocation object * @see RemoteInvocationFactory#createRemoteInvocation */ protected RemoteInvocation createRemoteInvocation(MethodInvocation methodInvocation) { return getRemoteInvocationFactory().createRemoteInvocation(methodInvocation); }
@Override public void afterPropertiesSet() { super.afterPropertiesSet(); // Eagerly initialize the default HttpInvokerRequestExecutor, if needed. getHttpInvokerRequestExecutor(); }
/** * 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); }