public class LocalRedirector extends InvocationStub
Optionally, a LocalStateSync
instance can be provided. If provided,
it will be used to maintain the StateSynchronizer
semantics which
is missing in local redirector environments which have no Session
object which would otherwise service that requirement.
Modifier and Type | Field and Description |
---|---|
private java.lang.Object |
instance
Instance on which to invoke methods.
|
private java.util.Set<java.lang.reflect.Method> |
methods
Target methods.
|
private LocalStateSync |
state
Utility for local state synchronization.
|
Constructor and Description |
---|
LocalRedirector(java.lang.Object instance,
java.util.Set<java.lang.reflect.Method> methods)
Creates a unique instance of an object that can handle invocations
of any proxied interface method by redirecting the method calls to
instance methods in a local class that match the interface method
signatures.
|
LocalRedirector(java.lang.Object instance,
java.util.Set<java.lang.reflect.Method> methods,
LocalStateSync state)
Creates a unique instance of an object that can handle invocations
of any proxied interface method by redirecting the method calls to
instance methods in a local class that match the interface method
signatures.
|
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
invokeCore(java.lang.Object proxy,
java.lang.reflect.Method method,
java.lang.Object[] args)
This method acts as an interceptor which is called every time a
method of the proxy object is invoked.
|
invoke
private java.util.Set<java.lang.reflect.Method> methods
private java.lang.Object instance
null
for statics.private LocalStateSync state
public LocalRedirector(java.lang.Object instance, java.util.Set<java.lang.reflect.Method> methods)
No state synchronization will be performed.
instance
- The instance upon which to target the method invocations. Use
null
if the methods are static.methods
- The set of target interface methods. Must not be
null
.public LocalRedirector(java.lang.Object instance, java.util.Set<java.lang.reflect.Method> methods, LocalStateSync state)
instance
- The instance upon which to target the method invocations. Use
null
if the methods are static.methods
- The set of target interface methods. Must not be
null
.state
- The state synchronizer on which to get and apply changes
before invoking the method call.public java.lang.Object invokeCore(java.lang.Object proxy, java.lang.reflect.Method method, java.lang.Object[] args) throws java.lang.Throwable
If a state synchronizer instance has been provided, the call to
LocalStateSync.sync()
will be implemented before the proxied
method is invoked.
invokeCore
in class InvocationStub
proxy
- Proxy object upon which the intercepted method is invoked.method
- Method to be invoked through reflection.args
- Arguments, if any, to method
.java.lang.Throwable
- if an exception/error occurs upon the invocation target,
or if any problem occurs during pre- or post-processing.