|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object fulmine.AbstractLifeCycle fulmine.rpc.RpcRegistry
public final class RpcRegistry
Standard IRpcRegistry
implementation. This has a single
IRecord
that represents the set of RPC definitions that are published
by local application code. Remote contexts will subscribe for this to receive
the current and future RPC definitions. The record is addressed using the
following attributes:
IRpcRegistry.RPC_REGISTRY
Type.RECORD
Domain.FRAMEWORK
RPC key = "rpc" counter "_" compactForm counter = 1*DIGIT ; this increments each time a new definition is registered compactForm = ALPHA 0*(ALPHA/DIGIT) argTypeCompactForm; this is the RPC name argTypeCompactForm = 0*ALPHA ; this is a string formed from the first letter of each argument typeThis ensures that the key is deterministic. Application code can cycle through the fields of the RPC registry record and intercept any beginning with this pattern in order to find RPC definitions. The value of the key is the string representation of the RPC definition. E.g. rpc12lasersIDB is the key for the 12th registered RPC, the RPC definition is lasers(IntegerField, DoubleField, BooleanField) - compact form is lasersIDB
An IRpcDefinition
can re-construct itself from this representation so
this is what is sent on-the-wire to remote contexts. After the key is added,
an update event is then triggered for the registry which will be received by
all subscribers for the registry (including channels connected to remote
contexts).
When an RPC definition is unpublished, the key and value are removed.
This class is thread safe.
Field Summary |
---|
Fields inherited from interface fulmine.rpc.IRpcRegistry |
---|
RPC_KEY, RPC_KEY_COUNT, RPC_REGISTRY |
Constructor Summary | |
---|---|
RpcRegistry(IFrameworkContext context)
Construct the RPC repository |
Method Summary | |
---|---|
protected void |
doDestroy()
Overridden in subclasses to perform custom logic on destruction. |
protected void |
doStart()
Overridden in subclasses to perform custom logic on activation. |
IRpcDefinition |
getDefinition(String registryKey)
Get the IRpcDefinition registered against the RPC registry key. |
IRpcHandler |
getHandler(String registryKey)
Get the handler for the RPC registry key. |
String |
getRegistryKey(String rpcName,
IField[] args)
Get the RPC registry key for the RPC defined by the procedure name and arguments. |
boolean |
publishProdedure(IRpcHandler handler,
IRpcDefinition rpcDefinition)
Publish the named procedure to all known remote contexts. |
boolean |
publishRpcs(Class<?> definition,
Object handler)
Allows application code to remotely enable all methods in a handler object that are implementations of methods in an interface definition. |
String |
toString()
|
boolean |
unpublishProdedure(IRpcDefinition rpcDefinition)
Unpublish the procedure from all connected remote contexts. |
boolean |
unpublishRpcs(Class<?> definition,
Object handler)
Allows application code to remove any previously remotely enabled methods published via IRpcPublishOperations.publishRpcs(Class, Object) |
Methods inherited from class fulmine.AbstractLifeCycle |
---|
checkActive, destroy, finalize, getLog, isActive, start |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface fulmine.ILifeCycle |
---|
isActive, start |
Methods inherited from interface fulmine.IDestroyable |
---|
destroy |
Constructor Detail |
---|
public RpcRegistry(IFrameworkContext context)
context
- the local contextMethod Detail |
---|
public boolean publishProdedure(IRpcHandler handler, IRpcDefinition rpcDefinition)
IRpcPublishOperations
There can only be one handler per procedure instance. Different handlers can be used for overloaded procedures. RPC definitions cannot overload the result type, if this method is called with a definition that attempts to overload the result type, the operation is ignored and no publish happens.
After this method has completed, remote contexts will be able to invoke the RPC.
publishProdedure
in interface IRpcPublishOperations
handler
- the object that will handle any RPC invocations for this RPC
definition. This object must be thread safe.rpcDefinition
- the RPC definition
true
if the procedure was published,
false
if has already been publishedpublic boolean unpublishProdedure(IRpcDefinition rpcDefinition)
IRpcPublishOperations
unpublishProdedure
in interface IRpcPublishOperations
rpcDefinition
- the RPC definition to unpublish
true
if the procedure was unpublishedpublic boolean unpublishRpcs(Class<?> definition, Object handler)
IRpcPublishOperations
IRpcPublishOperations.publishRpcs(Class, Object)
unpublishRpcs
in interface IRpcPublishOperations
definition
- an interface that defines all the methods in the handler that
should be remotely disabled. This includes all methods in the
super-interfaces, if any.handler
- the object that implements the methods declared in the
definition interface. These methods will no longer be
available for remote invocation.
true
if all methods were successfully unpublishedpublic boolean publishRpcs(Class<?> definition, Object handler)
IRpcPublishOperations
There are some caveats to methods that can be remotely enabled; the method arguments and return types must be scalar and only the following types are supported:
This is a convenience method in-lieu of calling
IRpcPublishOperations.publishProdedure(IRpcHandler, IRpcDefinition)
.
publishRpcs
in interface IRpcPublishOperations
definition
- an interface that defines all the methods in the handler that
should be remotely enabled. This includes all methods in the
super-interfaces, if any.handler
- the object that implements the methods declared in the
definition interface. The handler does not necessarily have to
be an instance of the interface (i.e. does not need to
explicitly implement the interface, it only needs to implement
all the methods). All remote invocations of these methods will
be handled by this object. The remotely enabled methods
must be thread safe.
true
if all methods were successfully publishedpublic IRpcHandler getHandler(String registryKey)
IRpcRegistry
getHandler
in interface IRpcRegistry
registryKey
- the registry key of the RPC
null
if not foundpublic IRpcDefinition getDefinition(String registryKey)
IRpcRegistry
IRpcDefinition
registered against the RPC registry key.
getDefinition
in interface IRpcRegistry
registryKey
- the registry key of the RPC
null
if not foundpublic String getRegistryKey(String rpcName, IField[] args)
IRpcRegistry
getRegistryKey
in interface IRpcRegistry
rpcName
- the name of the RPCargs
- the arguments for the RPC
null
if no match is foundprotected void doDestroy()
AbstractLifeCycle
RuntimeException
or subclass
thereof.
doDestroy
in class AbstractLifeCycle
protected void doStart()
AbstractLifeCycle
RuntimeException
or subclass
thereof. When this method is called, the AbstractLifeCycle.isActive()
method will
return true
.
doStart
in class AbstractLifeCycle
public String toString()
toString
in class AbstractLifeCycle
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |