T - The type is the interface this invocation handler will handle
invocations for, i.e. the type of the service (getComponent())
and the type of the stub representing the service.public class InvocationHandler<T>
extends java.lang.Object
implements java.lang.reflect.InvocationHandler
T in a
distributed environment.
It catches the API method calls to the proxy object that represents the
service to the caller (i. e. the client) and delegates them to the
communication submodule that is responsible for
doing the remote calls on the remote service the proxy object is a proxy for.
If a callback object is passed within a parameter to the requested method, then the handler creates a callback URI, associates this URI with the passed callback object and passes this URI to the skeleton responsible for the execution of the requested method on server side instead of the callback object itself.
With this URI the receiver skeleton can create a stub/proxy object intended to do remote callback invocations on the callback object associated with the given callback URI.
The invocation handler only delegates calls to methods of the service
interface, which are neither annotated with ProxyIgnore nor with
ProxyFollow.
Calls to methods which are annotated with ProxyIgnore, are dismissed.
Calls to methods which are annotated with Replaces will be replaced by the method
described in the annotation. All further then applies to the replacing method, i. e. using cached
values for an immutable (replacing) method or following the proxy. Replacing methods may switch
from virtual to static invocation (i. e. from an instance method to a class method). In this case
the parameter values are shifted by one and the first parameter will be the provided object
instance. The replacing method has to consider this appropriately, i. e. the first parameter has
to be of the appropriate type (of the object instance).
Additionally, replacing may take place locally. In this case the method call on the proxy will
not be forwarded but executed locally instead of remote.
The return value of methods annotated with Immutable will cached internally using a
WeakReference. Consecutive calls will then use this cached value if it is still present.
Calls to methods which are annotated with ProxyFollow, are replied with another proxy
object.
| Modifier and Type | Field and Description |
|---|---|
protected java.util.logging.Logger |
logger
My logger.
|
| Modifier | Constructor and Description |
|---|---|
protected |
InvocationHandler(InvocationTarget invTarget,
java.util.concurrent.atomic.AtomicLong invId,
java.net.URI remoteObjectIdentifier,
boolean callback,
java.util.Stack<java.lang.reflect.Method> preceder,
java.util.logging.Logger logger)
Create an invocation handler for the configured component name, following
the provided methods to the interface this is a proxy for.
|
|
InvocationHandler(InvocationTarget invTarget,
java.util.concurrent.atomic.AtomicLong invId,
java.net.URI remoteIdentifier,
java.lang.Class<T> remoteInterface,
boolean callback,
java.util.logging.Logger logger)
Create a new invocation handler.
|
| Modifier and Type | Method and Description |
|---|---|
T |
getComponent() |
java.lang.Object |
invoke(java.lang.Object proxyPar,
java.lang.reflect.Method method,
java.lang.Object[] args) |
protected long |
nextInvocationId()
Generates unique invocation IDs.
|
public InvocationHandler(InvocationTarget invTarget, java.util.concurrent.atomic.AtomicLong invId, java.net.URI remoteIdentifier, java.lang.Class<T> remoteInterface, boolean callback, java.util.logging.Logger logger)
invTarget - The invocation target providing the callback export and
the invocation delegate to send messages to.invId - The count of each invocation to each have its unique ID.remoteIdentifier - The service URI of the ADEPT2 component this object
is a proxy for.remoteInterface - The interface of the ADEPT2 component, with
T defining the generic type of this handler.callback - Whether this invocation handler is a callback object, that
is, it is a stub that has been created for a callback parameter in
an invocation message.logger - The class-specific logger for this invocation handler.protected InvocationHandler(InvocationTarget invTarget, java.util.concurrent.atomic.AtomicLong invId, java.net.URI remoteObjectIdentifier, boolean callback, java.util.Stack<java.lang.reflect.Method> preceder, java.util.logging.Logger logger)
Invocation handler for ProxyFollow objects are created
automatically within this class.
invTarget - The invocation target providing the callback export and
the invocation delegate to send messages to.invId - The count of each invocation to each have its unique ID.remoteObjectIdentifier - The service URI of the ADEPT2 component this
object is a proxy for.callback - Whether this invocation handler is a callback object, that
is, it is a stub that has been created for a callback parameter in
an invocation message.preceder - The stack of methods of the component, to reach the object
this is a proxy for.logger - The class-specific logger for this invocation handler.public T getComponent()
Proxy).protected long nextInvocationId()
public java.lang.Object invoke(java.lang.Object proxyPar,
java.lang.reflect.Method method,
java.lang.Object[] args)
throws java.lang.Throwable
invoke in interface java.lang.reflect.InvocationHandlerjava.lang.Throwable