public class LocalStaticRedirector 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.util.Map<java.lang.reflect.Method,java.lang.reflect.Method> |
map
Target methods mapped by interface methods.
|
private LocalStateSync |
state
Utility for local state synchronization.
|
Constructor and Description |
---|
LocalStaticRedirector(java.util.Map<java.lang.reflect.Method,java.lang.reflect.Method> map)
Creates a unique instance of an object that can handle invocations
of any proxied interface method by redirecting the method calls to
static methods in a local class that match the interface method
signatures.
|
LocalStaticRedirector(java.util.Map<java.lang.reflect.Method,java.lang.reflect.Method> map,
LocalStateSync state)
Creates a unique instance of an object that can handle invocations
of any proxied interface method by redirecting the method calls to
static 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.Map<java.lang.reflect.Method,java.lang.reflect.Method> map
private LocalStateSync state
public LocalStaticRedirector(java.util.Map<java.lang.reflect.Method,java.lang.reflect.Method> map)
No state synchronization will be performed.
map
- The map of interface methods to their static method
equivalents. Must not be null
.public LocalStaticRedirector(java.util.Map<java.lang.reflect.Method,java.lang.reflect.Method> map, LocalStateSync state)
map
- The map of interface methods to their static method
equivalents. 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.