public final class Registry
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static Registry |
SYSTEM_REGISTRY
The system-(or at least Classloader)-wide Registry.
|
Constructor and Description |
---|
Registry()
Create a new Registry that uses the system registry as a parent.
|
Registry(Registry parent)
Create a new Registry with a particular parent.
|
Registry(java.lang.String name)
Create a new Registry with a particular name that uses the system
registry as a parent.
|
Registry(java.lang.String name,
Registry parent)
Create a new Registry with a particular name and parent.
|
Modifier and Type | Method and Description |
---|---|
Entity |
createEntity(java.lang.String urn,
EntityID id)
Create an entity from a urn.
|
Message |
createMessage(java.lang.String urn,
java.io.InputStream data)
Create a message from a urn.
|
Property |
createProperty(java.lang.String urn)
Create a property from a urn.
|
static Registry |
getCurrentRegistry()
Get the current Registry for this thread.
|
protected EntityFactory |
getEntityFactory(java.lang.String urn)
Get the entity factory for a URN, delegating to the parent if required.
|
protected MessageFactory |
getMessageFactory(java.lang.String urn)
Get the message factory for a URN, delegating to the parent if required.
|
java.lang.String |
getName()
Get the name of this registry.
|
protected PropertyFactory |
getPropertyFactory(java.lang.String urn)
Get the property factory for a URN, delegating to the parent if required.
|
void |
registerEntityFactory(EntityFactory factory)
Register an entity factory.
|
void |
registerEntityFactory(java.lang.String urn,
EntityFactory factory)
Register an entity URN and assign an EntityFactory for constructing
instances of this type.
|
void |
registerMessageFactory(MessageFactory factory)
Register a message factory.
|
void |
registerMessageFactory(java.lang.String urn,
MessageFactory factory)
Register a message URN and assign a MessageFactory for constructing
instances of this type.
|
void |
registerPropertyFactory(PropertyFactory factory)
Register a property factory.
|
void |
registerPropertyFactory(java.lang.String urn,
PropertyFactory factory)
Register a property URN and assign a PropertyFactory for constructing
instances of this type.
|
static void |
setCurrentRegistry(Registry r)
Set the current Registry for this thread.
|
java.lang.String |
toString() |
public static final Registry SYSTEM_REGISTRY
public Registry()
public Registry(java.lang.String name)
name
- The name of this Registry.public Registry(Registry parent)
parent
- The parent Registry.public Registry(java.lang.String name, Registry parent)
name
- The name of this Registry.parent
- The parent Registry.public static Registry getCurrentRegistry()
public static void setCurrentRegistry(Registry r)
r
- The current Registry for this thread.public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String getName()
public void registerEntityFactory(EntityFactory factory)
factory
- The entity factory to register.public void registerEntityFactory(java.lang.String urn, EntityFactory factory)
urn
- The urn to register.factory
- The factory that is responsible for constructing entity
instances of this type.public void registerPropertyFactory(PropertyFactory factory)
factory
- The property factory to register.public void registerPropertyFactory(java.lang.String urn, PropertyFactory factory)
urn
- The urn to register.factory
- The factory that is responsible for constructing property
instances of this type.public void registerMessageFactory(MessageFactory factory)
factory
- The message factory to register.public void registerMessageFactory(java.lang.String urn, MessageFactory factory)
urn
- The urn to register.factory
- The factory that is responsible for constructing message
instances of this type.public Entity createEntity(java.lang.String urn, EntityID id)
previously registered
EntityFactory.urn
- The urn of the entity type to create.id
- The EntityID of the Entity that will be created.public Property createProperty(java.lang.String urn)
previously registered
PropertyFactory.urn
- The urn of the property type to create.public Message createMessage(java.lang.String urn, java.io.InputStream data) throws java.io.IOException
previously registered
MessageFactory.urn
- The urn of the message type to create.data
- An InputStream to read message data from.java.io.IOException
- If there is a problem decoding the message.protected EntityFactory getEntityFactory(java.lang.String urn)
urn
- The URN to look up.protected PropertyFactory getPropertyFactory(java.lang.String urn)
urn
- The URN to look up.protected MessageFactory getMessageFactory(java.lang.String urn)
urn
- The URN to look up.