danbikel.util.proxy
Class Reconnect
java.lang.Object
danbikel.util.proxy.Reconnect
- All Implemented Interfaces:
- Serializable, InvocationHandler
- Direct Known Subclasses:
- Failover
public class Reconnect
- extends Object
- implements InvocationHandler, Serializable
An invocation handler for which proxy instances may be constructed
for RMI clients such that the RMI server will be re-gotten from
the bootstrap registry in the event of method failure. Subclasses
may modify the behavior in the event of method failure, by overriding
the validate
method.
- See Also:
validate()
,
Serialized Form
Constructor Summary |
Reconnect(Object stub,
String name)
Constructs a proxy invocation handler to reconnect with an RMI
server in the event of a method failure. |
Method Summary |
Object |
invoke(Object proxy,
Method method,
Object[] args)
|
static Object |
proxyFor(Object stub,
String name)
|
protected void |
validate()
Ensures that the server stub on which remote methods will be executed
is valid, getting a server instance from the rmiregistry
if there was a previous method failure on the stub. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
stub
protected Object stub
name
protected String name
Reconnect
public Reconnect(Object stub,
String name)
- Constructs a proxy invocation handler to reconnect with an RMI
server in the event of a method failure. The reconnection is
performed by looking up the specified name in the bootstrap registry
(via
Naming.lookup
). The default lookup behavior may
be changed in a subclass by overriding the validate()
method.
- Parameters:
stub
- the remote object stub which should be validated
and which will be performing the actual method computationname
- the name of the server in the bootstrap registry, to be
used as the argument to Naming.lookup
when "re-connecting"
to the server
proxyFor
public static Object proxyFor(Object stub,
String name)
invoke
public Object invoke(Object proxy,
Method method,
Object[] args)
throws Throwable
- Specified by:
invoke
in interface InvocationHandler
- Throws:
Throwable
validate
protected void validate()
throws RemoteException
- Ensures that the server stub on which remote methods will be executed
is valid, getting a server instance from the
rmiregistry
if there was a previous method failure on the stub. A subclass may
override this method if a different type of validation is desired.
For example, if for client-side failover, this method may execute
some other remote method to get a different server from a registry.
- Throws:
RemoteException
Author: Dan Bikel.