|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectgnu.cajo.utils.extra.Implements
public final class Implements
This class takes any service object, and allows its methods to be tested for existence, without having to invoke them. This is particularly important to enable Type Substitution. In other words; a client could check if a service object implemented its specific interface.
When a service is remoted, wrapped in this object; clients can invoke the methods they assume this object implements. Instead of the normal method return; it will return a boolean. True will indicate that the service supports the method, otherwise it will return false. No side effects to the wrapped object will be incurred by this service. In fact; the service object will be completely unaware of the testing.
One suggested protocol: A service object could provide a public getImplements(); method, which would return a remote reference to the service object, wrapped by an Implements instance. A new reference needn't be created for each call, and in fact, the reference can even be instantiated lazily, i.e. if needed.
As a template:
private Remote myImplements; public RemoteInvoke getImplements() throws java.rmi.RemoteException { return myImplements == null ? myImplements = new Remote(new Implements(this)) : myImplements; }
Constructor Summary | |
---|---|
Implements(java.lang.Object service)
The constructor takes any service object, and allows it to be remotely tested for method existence, without having to invoke it. |
Method Summary | |
---|---|
java.lang.Object |
invoke(java.lang.String method,
java.lang.Object args)
Instead of actually invoking the method on the target object, this object will test for the existence of the method on the target object, either and return true or false. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Implements(java.lang.Object service)
service
- The service object to make remotely testable for method
callability.Method Detail |
---|
public java.lang.Object invoke(java.lang.String method, java.lang.Object args)
invoke
in interface Invoke
method
- The method to check for existenceargs
- The signature of the particular method would accept, the
arguments can be null, or subclasses of the expected arguments.
Typically these are represented by class, but they also can be passed
in by instance.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |