|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectgnu.cajo.utils.extra.Wrapper
public class Wrapper
The base class for wrapping objects, remote references, and proxies for syntactical transparency with the remaining codebase. It allows the object type to change between local object/remote/proxy, without affecting the calling code. It enforces compile time type checking, and the standard invocation systax, while still allowing invocation of methods via the reflection based invoke paradigm. It also promotes "lazy instantiation," as the wrapped reference will not be loaded into the runtime unless and until it is needed. If the wrapped object url is compatible, the wrapper may be freely passed between JVM instances.
Field Summary | |
---|---|
protected java.lang.Object |
object
The object being wrapped by the reflection based invocation paradigm. |
protected java.lang.String |
url
The URL where to get the wrapped object: file://, http://, ftp://, /path/name, path/name, or //[host][:port]/[name]. |
Constructor Summary | |
---|---|
protected |
Wrapper()
The no-arg constructor does nothing, it is protected for use only by subclasses. |
|
Wrapper(java.lang.String url)
The constructor loads an object, or a zipped marshalled object (zedmob) from a URL, a file, or from a remote rmiregistry. |
Method Summary | |
---|---|
java.lang.String |
getDescription()
This method attempts to extract usage information about the inner object, if the method is supported. |
java.lang.Object |
invoke(java.lang.String method,
java.lang.Object args)
This method must be called by all interface methods of the subclass, as it will load the wrapped object if it has not yet been loaded. |
boolean |
isRemote()
This method is used to test if the inner object is a reference to a remote object. |
protected void |
load()
This method is used to support lazy loading of remote object references, only when needed. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected transient java.lang.Object object
MonitorItem
. It is transient to
force subclasses to manage application specific persistence.
protected java.lang.String url
Constructor Detail |
---|
protected Wrapper()
public Wrapper(java.lang.String url)
Loading an item from a file can be specified in one of three ways:
File loading will first be attempted from within the application's jar file, if that fails, it will then look in the local filesystem. Note: any socket connections made by the incoming item cannot be known at compile time, therefore proper operation if this VM is behind a firewall could be blocked. Use behind a firewall would require knowing all the ports that would be needed in advance, and enabling them before loading the item. Note: for efficiency, the item will not be loaded at this time, rather on the first time it is need to perform in a particular method.
url
- The URL where to get the object: file://, http://, ftp://,
/path/name, path/name, or //[host][:port]/[name]. The host, port,
and name, are all optional. If missing the host is presumed local, the
port 1099, and the name "main". The referenced resource can be
returned as a MarshalledObject, it will be extracted automatically.
If the URL is null, it will be assumed to be ///.Method Detail |
---|
protected void load()
public boolean isRemote()
public java.lang.String getDescription() throws java.lang.Exception
java.lang.NoSuchMethodException
- If the inner object does not support the
description method.
java.lang.Exception
- If the innter object rejected the invocation, for
any application specific reasons.public java.lang.Object invoke(java.lang.String method, java.lang.Object args) throws java.lang.Exception
invoke
in interface Invoke
method
- The method name to be invoked.args
- The arguments to provide to the method for its invocation,
possibly null.
RemoteException
- if the remote registry could not be reached.
NotBoundException
- if the requested name is not in the registry.
IOException
- if the zedmob format is invalid.
java.lang.InstantiationException
- when the URL specifies a class name
which cannot be instantiated at runtime.
java.lang.IllegalAccessException
- when the url specifies a class name
and it does not support a no-arg constructor.
MalformedURLException
- if the URL is not in the format explained
java.lang.IllegalArgumentException
- If the method argument is null.
java.lang.NoSuchMethodException
- If no matching method can be found.
java.lang.ClassNotFoundException
- If the wrapped object's codebase cannot be
found on deserialization.
StreamCorruptedException
- If control information in the stream is
not consistent on deserialization.
java.lang.Exception
- If the inner object rejected the invocation, for
any application specific reasons.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |