|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.elkoserver.foundation.actor.RefTable
public class RefTable
A mapping from object reference strings (as they would be used in JSON message parameters) to the objects they refer to. This mapping may be modified at any time by adding or removing objects. The class also supports the direct invocation (from JSON messages) of JSON methods on the mapped objects.
By convention, the object references mapped by this table take the form:
type-ref
where: 'type' designates the kind of object being referred to, while 'ref' designates a specific object of that type. The 'ref' and accompanying hyphen separator are optional (actually, you are not required to follow this convention at all, but various classes provide convenience methods that are helpful if you do). The specific forms of 'type' and 'ref' themselves are unconstrained (other than the use of a hyphen as separator).
| Constructor Summary | |
|---|---|
RefTable(TypeResolver resolver)
Constructor. |
|
| Method Summary | |
|---|---|
void |
addClass(Class targetClass)
Add JSON method dispatch information for a Java class to the table's message dispatcher, independent of any particular object instance. |
void |
addRef(Referenceable target)
Add an object to the table, using the reference string it knows for itself. |
void |
addRef(String ref,
DispatchTarget target)
Add an object to the table, explicitly specifying its reference string. |
List<DispatchTarget> |
clones(String ref)
Get a list of all objects in the table that have a common root reference string. |
void |
dispatchMessage(Deliverer from,
DispatchTarget target,
JSONObject message)
Dispatch a JSON message directly to the appropriate method of a given object. |
void |
dispatchMessage(Deliverer from,
JSONObject message)
Dispatch a JSON message to the appropriate method on the object that the message says it is addressed to. |
DispatchTarget |
get(String ref)
Look up an object by reference string. |
Iterator<DispatchTarget> |
iterator()
Support iteration over all objects in the table. |
void |
remove(Referenceable object)
Remove an object from the table, using the reference string it knows for itself. |
void |
remove(String ref)
Remove an object from the table, explicitly specifying its reference string. |
static String |
rootRef(String ref)
Extract the root from a reference string. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public RefTable(TypeResolver resolver)
resolver - Type resolver for the type tags of JSON encoded
object descriptors.| Method Detail |
|---|
public void addClass(Class targetClass)
targetClass - Java class whose JSON methods are to be added.
public void addRef(String ref,
DispatchTarget target)
ref - The reference string for the object.target - The object referenced by the reference string.public void addRef(Referenceable target)
target - The object referenced by the reference string.public List<DispatchTarget> clones(String ref)
ref - Reference string designating the object(s) of interest.
public void dispatchMessage(Deliverer from,
DispatchTarget target,
JSONObject message)
throws MessageHandlerException
from - Alleged sender of the message.target - The object to which the message is being sent.message - The message itself.
MessageHandlerException - if there was some kind of problem
handling the message.
public void dispatchMessage(Deliverer from,
JSONObject message)
throws MessageHandlerException
from - Alleged sender of the message.message - The message itself.
MessageHandlerException - if there was some kind of problem
handling the message.public DispatchTarget get(String ref)
ref - Reference string denoting the object sought.
public Iterator<DispatchTarget> iterator()
iterator in interface Iterable<DispatchTarget>Iterator over all the objects.public void remove(String ref)
ref - Reference string for the object to be removed.public void remove(Referenceable object)
object - The object to be removed.public static String rootRef(String ref)
ref - The reference string whose root is sought.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||