public class LocalServerClient extends Object implements Invoker, Closeable
Modifier | Constructor and Description |
---|---|
protected |
LocalServerClient() |
Modifier and Type | Method and Description |
---|---|
protected LocalServerRestClient |
_getLocalServerRestClient() |
void |
close() |
void |
decRefCount(ObjectRef objectRef,
Uid refId) |
protected void |
finalize() |
ClassInfoMap |
getClassInfoMap() |
static LocalServerClient |
getInstance() |
protected Uid |
getLocalProcessId() |
LocalServerRestClient |
getLocalServerRestClient() |
ObjectManager |
getObjectManager() |
Object |
getRemoteObjectProxyOrCreate(ObjectRef objectRef) |
protected Uid |
getRemoteProcessId() |
void |
incRefCount(ObjectRef objectRef,
Uid refId) |
<T> T |
invoke(Object object,
String methodName,
Class<?>[] argumentTypes,
Object... arguments) |
<T> T |
invoke(Object object,
String methodName,
Object... arguments) |
<T> T |
invoke(Object object,
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. |
boolean |
isLocalServerInSeparateProcess() |
protected LocalServerClient()
public ClassInfoMap getClassInfoMap()
getClassInfoMap
in interface Invoker
public static LocalServerClient getInstance()
public final LocalServerRestClient getLocalServerRestClient()
protected LocalServerRestClient _getLocalServerRestClient()
public ObjectManager getObjectManager()
getObjectManager
in interface Invoker
public <T> T invokeStatic(Class<?> clazz, String methodName, Object... arguments)
Invoker
LocalServerClient
in the LocalServer
or vice-versa.
Convenience method delegating to Invoker.invokeStatic(String, String, String[], Object...)
.
See Invoker.invoke(Object, String, String[], Object...)
for further details.
invokeStatic
in interface Invoker
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
.Invoker.invokeStatic(String, String, String[], Object...)
,
Invoker.invoke(Object, String, String[], Object...)
public <T> T invokeStatic(String className, String methodName, Object... arguments)
Invoker
LocalServerClient
in the LocalServer
or vice-versa.
Convenience method delegating to Invoker.invokeStatic(String, String, String[], Object...)
.
See Invoker.invoke(Object, String, String[], Object...)
for further details.
invokeStatic
in interface Invoker
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
.Invoker.invokeStatic(String, String, String[], Object...)
,
Invoker.invoke(Object, String, String[], Object...)
public <T> T invokeStatic(Class<?> clazz, String methodName, Class<?>[] argumentTypes, Object... arguments)
Invoker
LocalServerClient
in the LocalServer
or vice-versa.
Convenience method delegating to Invoker.invokeStatic(String, String, String[], Object...)
.
See Invoker.invoke(Object, String, String[], Object...)
for further details.
invokeStatic
in interface Invoker
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
.Invoker.invokeStatic(String, String, String[], Object...)
,
Invoker.invoke(Object, String, String[], Object...)
public <T> T invokeStatic(String className, String methodName, String[] argumentTypeNames, Object... arguments)
Invoker
LocalServerClient
in the LocalServer
or vice-versa.
See Invoker.invoke(Object, String, String[], Object...)
for further details.
invokeStatic
in interface Invoker
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
.Invoker.invoke(Object, String, String[], Object...)
public <T> T invokeConstructor(Class<T> clazz, Object... arguments)
Invoker
LocalServerClient
in the LocalServer
or vice-versa.
Convenience method delegating to Invoker.invokeConstructor(String, String[], Object...)
.
See Invoker.invoke(Object, String, String[], Object...)
for further details.
invokeConstructor
in interface Invoker
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
.Invoker.invokeConstructor(String, String[], Object...)
,
Invoker.invoke(Object, String, String[], Object...)
public <T> T invokeConstructor(String className, Object... arguments)
Invoker
LocalServerClient
in the LocalServer
or vice-versa.
See Invoker.invoke(Object, String, String[], Object...)
for further details.
invokeConstructor
in interface Invoker
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
.Invoker.invokeConstructor(String, String[], Object...)
,
Invoker.invoke(Object, String, String[], Object...)
public <T> T invokeConstructor(Class<T> clazz, Class<?>[] argumentTypes, Object... arguments)
invokeConstructor
in interface Invoker
public <T> T invokeConstructor(String className, String[] argumentTypeNames, Object... arguments)
invokeConstructor
in interface Invoker
public <T> T invoke(Object object, String methodName, Class<?>[] argumentTypes, Object... arguments)
public <T> T invoke(Object object, String methodName, String[] argumentTypeNames, Object... arguments)
Invoker
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.
invoke
in interface Invoker
object
- 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).public void incRefCount(ObjectRef objectRef, Uid refId)
incRefCount
in interface Invoker
public void decRefCount(ObjectRef objectRef, Uid refId)
decRefCount
in interface Invoker
public void close()
close
in interface Closeable
close
in interface AutoCloseable
public Object getRemoteObjectProxyOrCreate(ObjectRef objectRef)
protected Uid getLocalProcessId()
protected Uid getRemoteProcessId()
public boolean isLocalServerInSeparateProcess()
Copyright © 2013–2019. All rights reserved.