public class BaseItem extends Object
| Modifier and Type | Class and Description |
|---|---|
class |
BaseItem.MainThread
The main processing thread of this object.
|
| Modifier and Type | Field and Description |
|---|---|
protected MarshalledObject |
proxy
A reference to the proxy served by this object, if it has one.
|
protected BaseItem.MainThread |
runnable
A reference to the object's processing code.
|
Thread |
thread
A reference to the object's processing thread.
|
| Constructor and Description |
|---|
BaseItem()
The constructor does nothing, server item configuration is to be done
by application specific subclasses.
|
| Modifier and Type | Method and Description |
|---|---|
void |
contact(String url)
This method is canonically called when an object announces its reference
via the
Multicast class. |
String |
getDescription()
This method is invoked by remote users of this object.
|
Remote |
getItem(String url)
A method will load either an object, or a zipped marshalled object
(zedmob) of an object, from a URL, file, or from a remote rmiregistry.
|
MarshalledObject |
getProxy()
This remotely invokable method is called by the remote clients, to
request the server object's default proxy, if it supports one.
|
Remote |
installProxy(Object proxy)
This remotely invokable method is called by remote clients to install
their proxies in this VM.
|
void |
setProxy(MarshalledObject proxy)
This method is called by the
ItemServer during a
bind operation to set the proxy member. |
void |
startThread()
This method is called by the
ItemServer during a
bind operation. |
protected BaseItem.MainThread runnable
protected MarshalledObject proxy
ItemServer during its bind
operation.public Thread thread
public BaseItem()
public Remote installProxy(Object proxy) throws Exception
ItemServer has been
called. The received proxy's init method will be invoked with a
reference to itself, remoted in the context of this VM. This is done
to initialise the proxy, and provide it with a handle to pass to other
remote objects, on which they can contact this proxy. The remote proxy
reference will be returned to the caller, providing an interface on
which to asynchronously call its proxy.proxy - The proxy to run in this VM, it is typically sent as a
MarshalledObject, from which it will be extracted automatically.ClassNotFoundException - If the item does not accept proxies.IllegalArgumentException - If the item provided is a remote
reference.Exception - If the proxy rejected the initialization invocation.public void setProxy(MarshalledObject proxy)
ItemServer during a
bind operation to set the proxy member. If the BaseItem
does not support a proxy, it can be given one, just once, by a remote
item. Conceptually this is very powerful, but must be used carefully.proxy - The object's proxy object, if it supports one.IllegalArgumentException - If the method is called more than
once, presumably by a remote object.public MarshalledObject getProxy()
public void startThread()
ItemServer during a
bind operation. If the item has a processing thread, meaning its
runnable member is not null, the thread will be
started, and its reference stored in the thread member.public Remote getItem(String url) throws RemoteException, NotBoundException, IOException, ClassNotFoundException, InstantiationException, IllegalAccessException, MalformedURLException
Loading an object from a file can be specified in one of three ways:
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 ///.RemoteException - if the remote registry could not be reached,
or the remote instance could not be be created.NotBoundException - if the requested name is not in the registry.IOException - if the zedmob format is invalid.ClassNotFoundException - if a proxy was sent to the VM, and
proxy hosting was not enabled.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 explainedpublic String getDescription()
public void contact(String url)
Multicast class. It is expected to receive
the URLs of objects that heard the announcement, and wish to be
contacted.url - A //host:port/name type URL on which the 'first-contact'
object of a remote VM can be reached.Copyright © 2016. All Rights Reserved.