| Modifier and Type | Class and Description |
|---|---|
static class |
Cajo.Purger
This internal use only helper class automatically removes unresponsive
server references from the internal queue.
|
static class |
Cajo.Registrar
This internal use only helper class maintains a registry of exported
objects.
|
static class |
Cajo.Searchable
This internal use only helper class scans an exported object to see if
it has methods matching the client method set.
|
| Constructor and Description |
|---|
Cajo(int port,
String serverHost,
String clientHost)
The constructor configures the network address settings.
|
| Modifier and Type | Method and Description |
|---|---|
void |
export(Object object)
This method makes any object's public methods, whether instance or
static, remotely invocable.
|
protected void |
finalize() |
Object[] |
lookup(Class methodSetInterface)
This method finds all remotely invocable objects, supporting the
specified method set.
|
static void |
main(String[] args)
Technically this method is unrelated to the class, it is used
to furnish library version information.
|
static Object |
proxy(Object object)
This method is used to allow clients to pass references to its own
local objects, to other JVMs.
|
Object |
proxy(Object reference,
Class methodSetInterface)
This method instantiates a
Dynamic Proxy at the client, which implements the method set
specified.
|
void |
register(String hostname,
int port)
This method is used to manually collect remote registry entries.
|
public Cajo(int port,
String serverHost,
String clientHost)
throws UnknownHostException,
IOException
port - The TCP port to be used for communications, for servers
canonically it is the IANA assigned cajo port of 1198, for clients it
can be any value, including 0, meaining chosen from any unused port
available at the time of startupserverHost - The local network interface on which the item will
will be remotely invokable. Typically it is specified when the server
has multiple phyisical network interfaces, or is multi-homed, i.e.
having multiple logical network interfaces. The value can be null,
which will make the item accessible on all network interfaces,
this is identical to providing the special port address "0.0.0.0".clientHost - The host name, or IP address the remote client will
use to communicate with this server. If null, it will be the same as
serverHost resolution. This would need to be explicitly specified if
the server is operating behind NAT; i.e. when the server's subnet IP
address is not the same as its address outside the subnet.UnknownHostException - If the either host address/name cannot be
resolved, or is invalidIOException - If the startup announcement datagram packet could
not be sentprotected void finalize()
throws Throwable
public void export(Object object) throws IOException
Note: if an object is exported more than once, it will be registered each time, you generally do not want to do this. Also, if you plan to use the register method, to contact remote registries directly, it is highly advisible to export all objects prior to doing so.
export in interface Grailobject - The
POJO to be made remotely invocable, i.e. there is no requirement
for it to implement any special interfaces, nor to be derived from any
particular classRemoteException - If the internal registry could not be createdIOException - If the announcement datagram packet could not be
sentpublic Object[] lookup(Class methodSetInterface) throws Exception
lookup in interface GrailmethodSetInterface - The interface of methods that remote objects
are required to supportException - For any network or framework specific reasonspublic Object proxy(Object reference, Class methodSetInterface)
proxy in interface Grailreference - A reference to a remote object returned by the
lookup method of this interface, though actually, any object reference
implementing the client method set would workmethodSetInterface - The set (or subset) of public methods,
static or instance, that the object reference implementspublic static Object proxy(Object object)
object - The local client object for which a pass-by-reference is
soughtpublic void register(String hostname, int port) throws Exception
hostname - The address or domain name of a remote grail JVMport - The TCP port on which the object is being shared,
canonically it 1198Exception - Various types, related to network related errors:
invalid host name, host unavailable, host unreachable, etc...public static void main(String[] args) throws Exception
ExceptionCopyright © 2016. All Rights Reserved.