public class SrvcRegistry
extends java.lang.Object
Object instances in the registry are indexed by the the
string representation of the object name.
Only one object of a given type can exist.
An object can be inserted under multiple types if all additional types
are superclasses of the object's native type.
Modifier and Type | Field and Description |
---|---|
static java.lang.String[] |
DEP_LIST
Class dependencies.
|
static java.lang.String |
VERSION
Class version.
|
Constructor and Description |
---|
SrvcRegistry()
Create a new Service Registry.
|
Modifier and Type | Method and Description |
---|---|
boolean |
addObject(java.lang.Object inst)
Add an object to the registry.
|
boolean |
addObjectSuperclass(java.lang.Object inst,
java.lang.Class sClass)
Add an object to the registry under a superclass type.
|
boolean |
containsClass(java.lang.Class regClass)
Determine if the registry contains an object of type regClass.
|
java.lang.Object |
createObject(java.lang.String className,
java.lang.String params)
Create an object, initialize it, and add it to the registry.
|
java.lang.Object |
getObject(java.lang.Class regClass)
Get an object instance from the registry.
|
static SrvcRegistry |
getRegistry()
Get a reference to the root registry.
|
java.util.Iterator |
nameIterator()
Get an iterator over the class names in the registry.
|
java.lang.Object |
obtainObject(java.lang.Class regClass,
java.lang.String params)
Get an object instance from the registry.
|
java.lang.Object |
obtainObject(java.lang.Class regClass,
java.lang.String params,
boolean registerNew)
Get an object instance from the registry.
|
public static final java.lang.String VERSION
public static final java.lang.String[] DEP_LIST
public static SrvcRegistry getRegistry()
public boolean containsClass(java.lang.Class regClass)
regClass
- The class to look forpublic boolean addObject(java.lang.Object inst)
inst
- Object instance to be addedpublic boolean addObjectSuperclass(java.lang.Object inst, java.lang.Class sClass)
sClass must be a superclass of inst.
If an object of the same type is already in the registry,
or the type of inst is not a subclass of sClass,
the new instance will not be added, and the method will return false.
The same instance can be added under it's own type (using addObject),
and again under a superclass (using addObjectSuperclass)
inst
- Object instance to be added.sClass
- Superclass to add the object under.public java.lang.Object createObject(java.lang.String className, java.lang.String params)
This is a convienence method for creating and adding objects to the registry. If the object created does not implement the RegInit interface, it will be created and added to the registry, but it will not be initialized. If the object does not have a zero parameter constructor, the method will fail, and null will be returned
className
- The name of the class to be obtained.params
- Initialization parameters. (Can be null.)public java.lang.Object getObject(java.lang.Class regClass)
regClass
- The class of the object to be obtained.public java.lang.Object obtainObject(java.lang.Class regClass, java.lang.String params)
regClass
- The class of the object to be obtained.params
- Initialization parameters. (Can be null.)public java.lang.Object obtainObject(java.lang.Class regClass, java.lang.String params, boolean registerNew)
regClass
- The class of the object to be obtained.params
- Initialization parameters. (Can be null.)registerNew
- If true, and a new instance is created,
add it to the registry.public java.util.Iterator nameIterator()