|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.healthmarketscience.rmiio.RemoteWrapper<RemoteType>
public class RemoteWrapper<RemoteType>
Base class for implementing remote stub wrappers with builtin retry
policies. Providers of remote interfaces can generate simple wrappers for
use by a remote client which handle the retry functionality under the hood,
simplifying client code dramatically. Note that this should only be done
for idempotent method calls. See RemoteInputStreamWrapper
and RemoteOutputStreamWrapper for example usage.
While subclassing presents an ability to fine tune the wrapper
implementation, it may be difficult and/or unnecessary for many interfaces.
In that case, a much simpler wrapper can be created using the wrap(java.lang.Class
method, which uses the java Proxy functionality to generate the
wrapper implementation at run time. This may be slightly less efficient
than a custom implementation since reflection is used for the actual method
invocations, but for remote method calls that overhead is probably
meaningless.
| Field Summary | |
|---|---|
protected org.apache.commons.logging.Log |
_log
the log which will be used by the retry facility when making the remote calls |
protected RemoteRetry |
_retry
the retry policy we are using for our remote calls |
protected RemoteType |
_stub
the handle to the remote interface which will do the real work of the remote method calls |
| Fields inherited from interface com.healthmarketscience.rmiio.RemoteClient |
|---|
DEFAULT_RETRY |
| Constructor Summary | |
|---|---|
RemoteWrapper(RemoteType stub,
RemoteRetry retry,
org.apache.commons.logging.Log log)
|
|
| Method Summary | ||
|---|---|---|
org.apache.commons.logging.Log |
getLog()
|
|
RemoteRetry |
getRemoteRetry()
|
|
RemoteType |
getStub()
|
|
static RemoteWrapper<?> |
getWrapper(Object proxy)
Gets the wrapper underlying a proxy created by a call to wrap(java.lang.Class. |
|
Object |
invoke(Object proxy,
Method method,
Object[] args)
|
|
void |
setRemoteRetry(RemoteRetry retry)
Sets the client side RemoteRetry policy to use for the underlying remote communication layer. |
|
static
|
wrap(Class<R> iface,
R stub,
RemoteRetry retry,
org.apache.commons.logging.Log log)
Simple wrapper generator which creates a Proxy for the given remote interface. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected final RemoteType _stub
protected RemoteRetry _retry
protected final org.apache.commons.logging.Log _log
| Constructor Detail |
|---|
public RemoteWrapper(RemoteType stub,
RemoteRetry retry,
org.apache.commons.logging.Log log)
| Method Detail |
|---|
public static <R> R wrap(Class<R> iface,
R stub,
RemoteRetry retry,
org.apache.commons.logging.Log log)
invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[]) method which makes the actual method calls on the
underlying stub within the retry logic.
iface - the remote interface to be implementedstub - the underlying implementation of the remote interface which
will actually make the remote callsretry - the retry policy to use for the remote callslog - the log to use during retry handling
public static RemoteWrapper<?> getWrapper(Object proxy)
wrap(java.lang.Class, R, com.healthmarketscience.rmiio.RemoteRetry, org.apache.commons.logging.Log) .
public RemoteType getStub()
public org.apache.commons.logging.Log getLog()
public RemoteRetry getRemoteRetry()
public void setRemoteRetry(RemoteRetry retry)
This may be useful for temporarily changing the retry policy for a specific set of calls (e.g. a startup/discovery sequence may be more forgiving than normal usage).
Note, this method is not thread-safe as this should only be used on a wrapper for which the caller has exclusive ownership (the retry policy will be changed for all users of the wrapper).
setRemoteRetry in interface RemoteClientretry - the new RemoteRetry policy to use for remote
communication. null causes the
RemoteClient.DEFAULT_RETRY policy to be used.
public Object invoke(Object proxy,
Method method,
Object[] args)
throws Throwable
invoke in interface InvocationHandlerThrowable
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||