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 Invokerpublic static LocalServerClient getInstance()
public final LocalServerRestClient getLocalServerRestClient()
protected LocalServerRestClient _getLocalServerRestClient()
public ObjectManager getObjectManager()
getObjectManager in interface Invokerpublic <T> T invokeStatic(Class<?> clazz, String methodName, Object... arguments)
InvokerLocalServerClient 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 Invokerclazz - 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)
InvokerLocalServerClient 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 InvokerclassName - 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)
InvokerLocalServerClient 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 Invokerclazz - 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)
InvokerLocalServerClient in the LocalServer or vice-versa.
See Invoker.invoke(Object, String, String[], Object...) for further details.
invokeStatic in interface InvokerclassName - 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)
InvokerLocalServerClient 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 Invokerclazz - 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)
InvokerLocalServerClient in the LocalServer or vice-versa.
See Invoker.invoke(Object, String, String[], Object...) for further details.
invokeConstructor in interface InvokerclassName - 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 Invokerpublic <T> T invokeConstructor(String className, String[] argumentTypeNames, Object... arguments)
invokeConstructor in interface Invokerpublic <T> T invoke(Object object, String methodName, Class<?>[] argumentTypes, Object... arguments)
public <T> T invoke(Object object, String methodName, String[] argumentTypeNames, Object... arguments)
InvokerobjectRef (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 Invokerobject - 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 Invokerpublic void decRefCount(ObjectRef objectRef, Uid refId)
decRefCount in interface Invokerpublic void close()
close in interface Closeableclose in interface AutoCloseablepublic Object getRemoteObjectProxyOrCreate(ObjectRef objectRef)
protected Uid getLocalProcessId()
protected Uid getRemoteProcessId()
public boolean isLocalServerInSeparateProcess()
Copyright © 2013–2019. All rights reserved.