public interface Invoker
Modifier and Type | Method and Description |
---|---|
void |
decRefCount(ObjectRef objectRef,
Uid refId) |
ClassInfoMap |
getClassInfoMap() |
ObjectManager |
getObjectManager() |
void |
incRefCount(ObjectRef objectRef,
Uid refId) |
<T> T |
invoke(Object objectRef,
String methodName,
Class<?>[] argumentTypes,
Object... arguments) |
<T> T |
invoke(Object objectRef,
String methodName,
Object... arguments) |
<T> T |
invoke(Object objectRef,
String methodName,
String[] argumentTypeNames,
Object... arguments)
Invoke a method on the given
objectRef (which is a proxy) in the LocalServer or in its client
(from the respective other side). |
<T> T |
invokeConstructor(Class<T> clazz,
Class<?>[] argumentTypes,
Object... arguments) |
<T> T |
invokeConstructor(Class<T> clazz,
Object... arguments)
Invoke a constructor from the
LocalServerClient in the LocalServer or vice-versa. |
<T> T |
invokeConstructor(String className,
Object... arguments)
Invoke a constructor from the
LocalServerClient in the LocalServer or vice-versa. |
<T> T |
invokeConstructor(String className,
String[] argumentTypeNames,
Object... arguments) |
<T> T |
invokeStatic(Class<?> clazz,
String methodName,
Class<?>[] argumentTypes,
Object... arguments)
Invoke a static method from the
LocalServerClient in the LocalServer or vice-versa. |
<T> T |
invokeStatic(Class<?> clazz,
String methodName,
Object... arguments)
Invoke a static method from the
LocalServerClient in the LocalServer or vice-versa. |
<T> T |
invokeStatic(String className,
String methodName,
Object... arguments)
Invoke a static method from the
LocalServerClient in the LocalServer or vice-versa. |
<T> T |
invokeStatic(String className,
String methodName,
String[] argumentTypeNames,
Object... arguments)
Invoke a static method from the
LocalServerClient in the LocalServer or vice-versa. |
<T> T invokeStatic(Class<?> clazz, String methodName, Object... arguments)
LocalServerClient
in the LocalServer
or vice-versa.
Convenience method delegating to invokeStatic(String, String, String[], Object...)
.
See invoke(Object, String, String[], Object...)
for further details.
clazz
- the class owning the static method to be invoked. Must not be null
.methodName
- the name of the static method to be invoked. Must not be null
.arguments
- the arguments passed to the static method. May be null
(if the method does not take any parameters).null
.invokeStatic(String, String, String[], Object...)
,
invoke(Object, String, String[], Object...)
<T> T invokeStatic(String className, String methodName, Object... arguments)
LocalServerClient
in the LocalServer
or vice-versa.
Convenience method delegating to invokeStatic(String, String, String[], Object...)
.
See invoke(Object, String, String[], Object...)
for further details.
className
- the fully qualified name of the class owning the static method to be invoked. Must not be null
.methodName
- the name of the static method to be invoked. Must not be null
.arguments
- the arguments passed to the static method. May be null
(if the method does not take any parameters).null
.invokeStatic(String, String, String[], Object...)
,
invoke(Object, String, String[], Object...)
<T> T invokeStatic(Class<?> clazz, String methodName, Class<?>[] argumentTypes, Object... arguments)
LocalServerClient
in the LocalServer
or vice-versa.
Convenience method delegating to invokeStatic(String, String, String[], Object...)
.
See invoke(Object, String, String[], Object...)
for further details.
clazz
- the class owning the static method to be invoked. Must not be null
.methodName
- the name of the static method to be invoked. Must not be null
.argumentTypes
- the argument-types. May be null
; then a matching method
will be searched. If there are multiple matching methods, an exception is thrown, though (and the argument-types must be
specified). If argumentTypes
is not null
, its length
must match the one of arguments
.arguments
- the arguments passed to the static method. May be null
(if the method does not take any parameters).null
.invokeStatic(String, String, String[], Object...)
,
invoke(Object, String, String[], Object...)
<T> T invokeStatic(String className, String methodName, String[] argumentTypeNames, Object... arguments)
LocalServerClient
in the LocalServer
or vice-versa.
See invoke(Object, String, String[], Object...)
for further details.
className
- the fully qualified name of the class owning the static method to be invoked. Must not be null
.methodName
- the name of the static method to be invoked. Must not be null
.argumentTypeNames
- the fully qualified names of the argument-types. May be null
; then a matching method
will be searched. If there are multiple matching methods, an exception is thrown, though (and the argument-types must be
specified). If argumentTypeNames
is not null
, its length
must match the one of arguments
.arguments
- the arguments passed to the static method. May be null
(if the method does not take any parameters).null
.invoke(Object, String, String[], Object...)
<T> T invokeConstructor(Class<T> clazz, Object... arguments)
LocalServerClient
in the LocalServer
or vice-versa.
Convenience method delegating to invokeConstructor(String, String[], Object...)
.
See invoke(Object, String, String[], Object...)
for further details.
clazz
- the class to be instantiated. Must not be null
.arguments
- the arguments passed to the constructor. May be null
(if the constructor does not take any parameters).null
.invokeConstructor(String, String[], Object...)
,
invoke(Object, String, String[], Object...)
<T> T invokeConstructor(String className, Object... arguments)
LocalServerClient
in the LocalServer
or vice-versa.
See invoke(Object, String, String[], Object...)
for further details.
className
- the fully qualified name of the class to be instantiated. Must not be null
.arguments
- the arguments passed to the constructor. May be null
(if the constructor does not take any parameters).null
.invokeConstructor(String, String[], Object...)
,
invoke(Object, String, String[], Object...)
<T> T invokeConstructor(Class<T> clazz, Class<?>[] argumentTypes, Object... arguments)
<T> T invokeConstructor(String className, String[] argumentTypeNames, Object... arguments)
<T> T invoke(Object objectRef, String methodName, Class<?>[] argumentTypes, Object... arguments)
<T> T invoke(Object objectRef, String methodName, String[] argumentTypeNames, Object... arguments)
objectRef
(which is a proxy) in the LocalServer
or in its client
(from the respective other side).
The LocalServer
might reside in the same JVM or in a separate JVM (on the same computer, hence "local").
When invoking a method, the arguments
must be passed to the real objectRef on the other side (in the other
JVM). Therefore, all primitives (byte
, long
etc.) as well as all objects implementing
Serializable
are serialized (via Java native serialisation), transmitted via a REST call and deserialized.
If, however, an objectRef passed as an argument is a proxy of a real objectRef in the server (no matter, if it
implements Serializable
or not), it is converted into an Object
instead - and this reference
is transmitted via REST. The server then resolves the Object
to the real objectRef.
If an objectRef in the arguments
is neither a proxy of a LocalServer
-objectRef (it may be a proxy of
sth. else) nor implements Serializable
, instead a reverse-proxy is created on the server-side. Therefore, an
Object
in the local JVM is created and passed via REST. The server then determines all interfaces of
the real objectRef and instantiates a proxy (or re-uses an already existing one). This reverse-proxy-mechanism allows
for passing a listener, e.g. a PropertyChangeListener
: If the server invokes a method on the reverse-proxy,
the InverseInvoker
is used to invoke the corresponding method on the real objectRef in the client-JVM.
Important: For the proxies (both the ones on the client-side and the reverse-ones on the server-side), the
standard Java Proxy
is used. Therefore, only interfaces can be proxied - no classes. We cannot use cglib
or any other more advanced proxy-lib, because these libs cannot be used with Android.
However, if a method declared by a class and not an interface should be invoked, this can still be done via this
method - it's just less convenient. Additionally, reverse-proxies (on the server-side) obviously can only be passed
to the real objectRef's method, if the method-signature uses an interface (or Object
) for the argument in question.
objectRef
- the proxy on which to invoke a method. Must not be null
. This proxy
was returned by a previous invocation of one of the invoke* methods (which might have happened
indirectly via an invocation of a proxy's method).methodName
- the name of the method to be invoked. Must not be null
.argumentTypeNames
- the fully qualified names of the argument-types. May be null
; then a matching method
will be searched. If there are multiple matching methods, an exception is thrown, though (and the argument-types must be
specified). If argumentTypeNames
is not null
, its length
must match the one of arguments
.arguments
- the arguments passed to the method. May be null
(if the method does not take any parameters).void incRefCount(ObjectRef objectRef, Uid refId)
void decRefCount(ObjectRef objectRef, Uid refId)
ObjectManager getObjectManager()
ClassInfoMap getClassInfoMap()
Copyright © 2013–2019. All rights reserved.