org.writersforge.catalan.process.workers
Class WorkerRegistry

java.lang.Object
  extended byorg.writersforge.catalan.process.workers.WorkerRegistry
Direct Known Subclasses:
XmlWorkerRegistry

public class WorkerRegistry
extends java.lang.Object

Container for all instantiated IWorker objects. Workers can be added as IWorker implementation Class references, as externally created IWorker objects, or as customized Workers derived from a IWorker class already in the registry but configured with custom parameters.

Author:
jsheets

Constructor Summary
WorkerRegistry()
          Creates a new instance of WorkerRegistry.
 
Method Summary
 void addClassWorker(java.lang.String name, java.lang.Class workerClass, IWorkProperties defaultProps)
          Adds a newly instantiated IWorker of the given Class to the registry.
 void addCustomWorker(java.lang.String name, java.lang.String origName, IWorkProperties defaultProps)
          Adds a IWorker to the registry, derived from a IWorker that already exists in the registry.
 void addExternalWorker(java.lang.String name, IWorker worker, IWorkProperties defaultProps)
          Adds an externally created IWorker to the registry.
 IWorker getWorker(java.lang.String name)
          Retrieves the named IWorker object from the registry.
 java.lang.String[] getWorkerNames()
          Retrieves an array of all IWorker names in this registry.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WorkerRegistry

public WorkerRegistry()
Creates a new instance of WorkerRegistry.

Method Detail

addClassWorker

public void addClassWorker(java.lang.String name,
                           java.lang.Class workerClass,
                           IWorkProperties defaultProps)
                    throws RegistryException
Adds a newly instantiated IWorker of the given Class to the registry. If the defaultProps parameter is non-null, it will be assigned to the IWorker before putting it into the registry.

Parameters:
name - name of IWorker to be added to the registry
workerClass - implementation class of IWorker
defaultProps - default properties for IWorker
Throws:
RegistryException - if unable to instantiate IWorker class, or if name is null or already exists

addExternalWorker

public void addExternalWorker(java.lang.String name,
                              IWorker worker,
                              IWorkProperties defaultProps)
                       throws RegistryException
Adds an externally created IWorker to the registry. If the defaultProps parameter is non-null, it will replace the IWorker's old default properties.

Parameters:
name - name of IWorker to be added to the registry
worker - previously instantiated IWorker object
defaultProps - default properties for IWorker
Throws:
RegistryException - if IWorker parameter is null, or if name is null or already exists

addCustomWorker

public void addCustomWorker(java.lang.String name,
                            java.lang.String origName,
                            IWorkProperties defaultProps)
                     throws RegistryException
Adds a IWorker to the registry, derived from a IWorker that already exists in the registry. The new IWorker will be of the same Class as the original IWorker, and will contain the parameters of the original IWorker, plus any additional parameters specified in defaultProps. If any parameters with the same name collide, the defaultProps values will take precedence in the new IWorker.

Parameters:
name - name of IWorker to be added to the registry
origName - name of a IWorker already in the registry
defaultProps - default properties for IWorker
Throws:
RegistryException - if name is null or already exists, or if origName worker does not exist

getWorkerNames

public java.lang.String[] getWorkerNames()
Retrieves an array of all IWorker names in this registry.

Returns:
worker names

getWorker

public IWorker getWorker(java.lang.String name)
Retrieves the named IWorker object from the registry.

Parameters:
name - name of the IWorker to get
Returns:
the requested IWorker