RMI / Shared
These are the shared ressources for RMI.
To register a service object on a client or a server use RMIRegisterObjectService.
Check your registered services by using TRMIServiceRegistry's method GetInstance().
Use RMIGetServiceObject (see fscom.rmiclient) and TRMIClient.GetRemoteServiceObject (see fscom.rmiserver) with
the service name "TRMIServiceRegistry" to get information about the services you can access on your network partner.
This file implements the fscom.rmi protocol:
Every message looks like this:
CHAN CMD DATA
CHAN: a byte representing a channel.
0-254: rmiblocking
255: rminonblocking
CMD: a char (ascii byte) representing the command
i: invoke a method on channel CHAN. The answer will be awaited on CHAN if CHAN is not 255.
r: return. This will be sent as answer to an invoke (only with CHAN <> 255)
t: throw. This will be sent as answer to an invoke (only with CHAN <> 255)
other values are invalid in this version.
DATA: Data is different for every CMD
CMD = i:
- BBString service name
- BBString method name
- for each parameter:
serialized object of the parameter. Primitives are represented by their string representations (like in BRL.Reflection)
There is no metadata sent, so there will be errors thrown if the sent invocation won't match up with the local implementation.
CMD = r: serialized object that was returned.
CMD = t: serialized object that was thrown.
Constants Summary
Globals Summary
Functions Summary
Types Summary
Constants
Const RMI_PRIVATE_FLAG:String |
Description | Use this flag in the service name to mark it as private. |
Information | Private services are not seen in the registry. |
Globals
Global RMI_BLOCKING_TIMEOUT:Int |
Description | Define timeout for method blocking. |
Global RMI_DEFAULT_METHOD_BLOCKING:Byte |
Description | Switch default method blocking on or off. See RMIInvokeRemote. |
Global RMI_MAX_INVOCATIONS_AT_ONCE:Int |
Description | Limit the invocations done by the server or a client at once when RMIPollNetwork is called. |
Information | Use -1 to not limit the invocations. |
Functions
Function RMIInvokeRemote:Object(serviceObject:Object , methodName:String , params:Object[] , metadata:String[], context:Object) |
Description | Invoke a remote method. |
Information | This function calls a method via fscom.rmi protocol using the stream and the service name given as context and the given parameters.
It is compatible with CreateProxy of fscom.proxy and is normally called by objets returned by RMIGetServiceObject in
fscom.rmiclient or TRMIClient.GetRemoteServiceObject() in fscom.rmiserver.
The context parameter is expected to be an TRMIInvokeRemoteContext.
This method will wait RMI_BLOCKING_TIMEOUT milliseconds for the remote method's return/throw if metadata contains "rmiblocking"
and will not wait for any reaction of the remote method if metadata contains "rminonblocking".
However if none is included in metadata it will consider RMI_DEFAULT_METHOD_BLOCKING.
If blocking, the method will submit any incoming invocations to the executor. Then it will return the value returned by the remote method or
throw the object thrown by the remote method. Also it will throw a TRMIException if a connection problem occurs.
Remote methods are unable to throw them via network, so if you can catch such exceptions to detect connection problems. |
Function RMIPollNetwork() |
Description | Poll the network for new invocations. |
Information | Call this method where it is called periodically e.g. your main loop.
Server and/or client will poll the network and submit invocations inside this method. |
Function RMIRegisterObjectService(serviceObject:Object , name:String = "") |
Description | Register an object as a RMI service. |
Information | Registering an object will expose the object's methods to be called
by RMI. Use name to set a name different to the type name of the object. |
Function RMIUnregisterObjectService(serviceObject:Object) |
Description | Remove an object from the RMI service registry. |
Types
Type TRMIException |
Description | RMI Exceptions. |
Information | These Exceptions are thrown by RMI. They are unable to be serialized,
so you can be sure they are thrown by the RMI in your process, not the remote process. |
Type TRMIServiceRegistry Abstract {proxy} |
Description | Service Registry. |
Information | This class provides information about the registered services (metadata).
Call GetRegistry() to get the local registry or get the registry of your network partner by
requesting the service object for the "TRMIServiceRegistry". |
Method GetMethodSignature:String(serviceName:String , methodName:String) Abstract {rmiblocking} |
Description | Get a method signature as "(TYPENAME,TYPENAME,..)" e.g. "(String,Object,Int)" |
Method GetServiceMethods:String[](serviceName:String) Abstract {rmiblocking} |
Description | Get an array of method names for a given service. |
Method GetServices:String[]() Abstract {rmiblocking} |
Description | Get an array of service names. |
Module Information
Version | 0.3 |
Author | Francesco Silvani |
License | zlib/libpng |
History | 0.3 |
History | Rewrote API to fix errors with concurrent invocations. |
History | Added threading support |
History | 0.2 |
History | Changed RMIRegisterServiceObject to RMIRegisterObjectService |
History | Moved RMIInvokeRemote and RMIInvokeLocal here both |