public class Wrapper extends Object implements Invoke
| Modifier and Type | Field and Description |
|---|---|
protected Object |
object
The object being wrapped by the reflection based invocation paradigm.
|
protected String |
url
The URL where to get the wrapped object: file://, http://, ftp://,
/path/name, path/name, or //[host][:port]/[name].
|
| Modifier | Constructor and Description |
|---|---|
protected |
Wrapper()
The no-arg constructor does nothing, it is protected for use only by
subclasses.
|
|
Wrapper(String url)
The constructor loads an object, or a zipped marshalled object (zedmob)
from a URL, a file, or from a remote rmiregistry.
|
| Modifier and Type | Method and Description |
|---|---|
String |
getDescription()
This method attempts to extract usage information about the inner object,
if the method is supported.
|
Object |
invoke(String method,
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.
|
protected transient Object object
MonitorItem. It is transient to
force subclasses to manage application specific persistence.protected String url
protected Wrapper()
public Wrapper(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 ///.protected void load()
public boolean isRemote()
public String getDescription() throws Exception
NoSuchMethodException - If the inner object does not support the
description method.Exception - If the innter object rejected the invocation, for
any application specific reasons.public Object invoke(String method, Object args) throws Exception
invoke in interface Invokemethod - 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.InstantiationException - when the URL specifies a class name
which cannot be instantiated at runtime.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 explainedIllegalArgumentException - If the method argument is null.NoSuchMethodException - If no matching method can be found.ClassNotFoundException - If the wrapped object's codebase cannot be
found on deserialization.StreamCorruptedException - If control information in the stream is
not consistent on deserialization.Exception - If the inner object rejected the invocation, for
any application specific reasons.Copyright © 2016. All Rights Reserved.