Package gnu.cajo.utils.extra
Class DynamicObject
java.lang.Object
gnu.cajo.utils.extra.DynamicObject
- All Implemented Interfaces:
Invoke
,Serializable
,Remote
This is a dynamic server object dispatcher. Its purpose it to provide a
client with a single remote object reference, whose functionality can be
changed by the server at runtime. A server would remote this object
wrapper, then use its changeObject method to redefine the functionality
of the client's reference dynamically. Note: the wrapped
object can be of any type, and it need not even implement the
gnu.cajo.invoke.Invoke interface.
While being only 5 lines of Java source code, its capability is elegantly sophisticated.
- Version:
- 1.0, 03-Nov-05 Initial release
- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionDynamicObject
(Object object) The constructor assigns the initial server object reference. -
Method Summary
-
Field Details
-
object
-
-
Constructor Details
-
DynamicObject
The constructor assigns the initial server object reference.- Parameters:
object
- The initial encapsulated server functionality to be remoted through this object.
-
-
Method Details
-
invoke
This method simply redirects all invocations to the currently wrapped object.- Specified by:
invoke
in interfaceInvoke
- Parameters:
method
- The method name to be invoked on the wrapped object.args
- The arguments to provide to the method for its invocation.- Returns:
- The resulting data, if any, from the invocation.
- Throws:
NoSuchMethodException
- If no matching method can be found.Exception
- If the wrapped object rejected the invocation, for application specific reasons.
-
changeObject
This method is used to dynamically redefine the functionality of this wrapper at runtime. The remote client reference never changes, but what the reference does, can be updated by the server repeatedly.- Parameters:
object
- The new encapsulated functionality to be provided to the remote clients.
-