fscom.rmishared: Constants Globals Functions Types Modinfo Source  

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

RMI_PRIVATE_FLAG

Globals Summary

RMI_BLOCKING_TIMEOUT , RMI_DEFAULT_METHOD_BLOCKING , RMI_MAX_INVOCATIONS_AT_ONCE

Functions Summary

RMIInvokeRemote Invoke a remote method.
RMIPollNetwork Poll the network for new invocations.
RMIRegisterObjectService Register an object as a RMI service.
RMIUnregisterObjectService Remove an object from the RMI service registry.

Types Summary

TRMIException RMI Exceptions.
TRMIServiceRegistry Service Registry.

Constants

Const RMI_PRIVATE_FLAG:String
DescriptionUse this flag in the service name to mark it as private.
InformationPrivate services are not seen in the registry.

Globals

Global RMI_BLOCKING_TIMEOUT:Int
DescriptionDefine timeout for method blocking.

Global RMI_DEFAULT_METHOD_BLOCKING:Byte
DescriptionSwitch default method blocking on or off. See RMIInvokeRemote.

Global RMI_MAX_INVOCATIONS_AT_ONCE:Int
DescriptionLimit the invocations done by the server or a client at once when RMIPollNetwork is called.
InformationUse -1 to not limit the invocations.

Functions

Function RMIInvokeRemote:Object(serviceObject:Object , methodName:String , params:Object[] , metadata:String[], context:Object)
DescriptionInvoke a remote method.
InformationThis 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()
DescriptionPoll the network for new invocations.
InformationCall 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 = "")
DescriptionRegister an object as a RMI service.
InformationRegistering 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)
DescriptionRemove an object from the RMI service registry.

Types

Type TRMIException
DescriptionRMI Exceptions.
InformationThese 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}
DescriptionService Registry.
InformationThis 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".
Methods Summary
GetMethodSignature Get a method signature as "(TYPENAME,TYPENAME,..)" e.g. "(String,Object,Int)"
GetServiceMethods Get an array of method names for a given service.
GetServices Get an array of service names.
Method GetMethodSignature:String(serviceName:String , methodName:String) Abstract {rmiblocking}
DescriptionGet a method signature as "(TYPENAME,TYPENAME,..)" e.g. "(String,Object,Int)"
Method GetServiceMethods:String[](serviceName:String) Abstract {rmiblocking}
DescriptionGet an array of method names for a given service.
Method GetServices:String[]() Abstract {rmiblocking}
DescriptionGet an array of service names.

Module Information

Version0.3
AuthorFrancesco Silvani
Licensezlib/libpng
History0.3
HistoryRewrote API to fix errors with concurrent invocations.
HistoryAdded threading support
History0.2
HistoryChanged RMIRegisterServiceObject to RMIRegisterObjectService
HistoryMoved RMIInvokeRemote and RMIInvokeLocal here both