atg.service.pipeline
Class PipelineManager

java.lang.Object
  extended by atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
      extended by atg.nucleus.GenericService
          extended by atg.service.pipeline.PipelineManager
All Implemented Interfaces:
NameContextBindingListener, NameContextElement, NameResolver, AdminableService, ApplicationLogging, atg.nucleus.logging.ApplicationLoggingSender, atg.nucleus.logging.TraceApplicationLogging, atg.nucleus.logging.VariableArgumentApplicationLogging, ComponentNameResolver, Service, ServiceListener, Schedulable, java.util.EventListener

public class PipelineManager
extends GenericService
implements Schedulable

This is the class responsible for the creation, registration and removal of pipeline chains. All access to pipeline chains is managed through this service.

See Also:
PipelineChain

Field Summary
static java.lang.String CLASS_VERSION
           
 
Fields inherited from class atg.nucleus.GenericService
SERVICE_INFO_KEY
 
Fields inherited from interface atg.nucleus.logging.TraceApplicationLogging
DEFAULT_LOG_TRACE_STATUS
 
Fields inherited from interface atg.nucleus.logging.ApplicationLogging
DEFAULT_LOG_DEBUG_STATUS, DEFAULT_LOG_ERROR_STATUS, DEFAULT_LOG_INFO_STATUS, DEFAULT_LOG_WARNING_STATUS
 
Constructor Summary
PipelineManager()
           
 
Method Summary
 boolean chainExists(java.lang.String pChainId)
           
 PipelineChain copyChain(java.lang.String pChainId, java.lang.String pNewChainId)
          Duplicates a chain and renames it.
protected  javax.servlet.Servlet createAdminServlet()
          Displays a table of the chains in the manager and their various states.
 PipelineChain createChain(java.lang.String pChainId)
          Creates a new chain in the PipelineManager.
 PipelineChain createChain(java.lang.String pChainId, java.lang.String pChainClassName, java.lang.String pReturnTypeClassName)
          Creates a new chain in the PipelineManager using the class whose name is in aChainClassName and a return type class whose name is in aReturnTypeClassName.
 void disableChain(java.lang.String pChainId)
          Disables the given chain so that threads cannot execute it.
 void doStartService()
          Calls the auto loader for the configuration file.
 void doStopService()
          Stops the scheduled service for reinitializing the PipelineManager
 PipelineChain duplicateChain(java.lang.String pChainId)
          Duplicates a chain and its links and returns the new chain object.
 void enableChain(java.lang.String pChainId)
          Enables the given chain so that threads can execute it.
 java.util.Hashtable getChainContexts()
          Expose our chain contexts using a hidden, expert method.
 long getChainLockWaitTimeout()
           
 atg.xml.XMLFile getDefinitionFile()
          Returns the definitionFile
 boolean getLoggingDebugOnProcessors()
          Returns true if loggingDebug is true for the processors, false otherwise
 boolean getReinitializeOnChainExec()
          Returns property reinitializeOnChainExec.
 Schedule getSchedule()
          Returns the schedule
 Scheduler getScheduler()
          Returns the scheduler
 javax.transaction.TransactionManager getTransactionManager()
           
 PipelineChain lockChain(java.lang.String pChainId)
          Locks a chain for editing.
 void performScheduledTask(Scheduler pScheduler, ScheduledJob pJob)
          This is called when a scheduled job tied to this object occurs.
 void reinitialize()
          Rereads the XML configuration file and reconstructs the chains
 void removeChain(java.lang.String pChainId)
          Removes the given chain from the PipelineManager.
 void replaceChain(PipelineChain pChain)
          Replaces the chain in the PipelineManager with the given chain of the same name.
 PipelineResult runProcess(java.lang.String pChainId, java.lang.Object pParam)
          This method runs the chain aChainId in the PipelineManager.
 void setChainLockWaitTimeout(long pChainLockWaitTimeout)
           
 void setDefinitionFile(atg.xml.XMLFile pDefinitionFile)
          Sets the definitionFile
 void setLoggingDebugOnProcessors(boolean pLoggingDebug)
          Turns on logging debug for all the processors in this PipelineManager
 void setReinitializeOnChainExec(boolean pReinitializeOnChainExec)
          Sets property reinitializeOnChainExec
 void setSchedule(Schedule pSchedule)
          Sets the schedule
 void setScheduler(Scheduler pScheduler)
          Sets the scheduler
 void setTransactionManager(javax.transaction.TransactionManager pTransactionManager)
           
 void unlockChain(java.lang.String pChainId)
          Unlocks the given chain.
 
Methods inherited from class atg.nucleus.GenericService
addLogListener, getAbsoluteName, getAdminServlet, getLoggingForVlogging, getLogListenerCount, getLogListeners, getName, getNameContext, getNucleus, getRoot, getServiceConfiguration, getServiceInfo, isLoggingDebug, isLoggingError, isLoggingInfo, isLoggingTrace, isLoggingWarning, isRunning, logDebug, logDebug, logDebug, logError, logError, logError, logInfo, logInfo, logInfo, logTrace, logTrace, logTrace, logWarning, logWarning, logWarning, nameContextElementBound, nameContextElementUnbound, removeLogListener, resolveName, resolveName, resolveName, resolveName, sendLogEvent, setLoggingDebug, setLoggingError, setLoggingInfo, setLoggingTrace, setLoggingWarning, setNucleus, setServiceInfo, startService, stopService
 
Methods inherited from class atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
vlogDebug, vlogDebug, vlogDebug, vlogDebug, vlogError, vlogError, vlogError, vlogError, vlogInfo, vlogInfo, vlogInfo, vlogInfo, vlogTrace, vlogTrace, vlogTrace, vlogTrace, vlogWarning, vlogWarning, vlogWarning, vlogWarning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLASS_VERSION

public static java.lang.String CLASS_VERSION
Constructor Detail

PipelineManager

public PipelineManager()
Method Detail

getDefinitionFile

public atg.xml.XMLFile getDefinitionFile()
Returns the definitionFile


setDefinitionFile

public void setDefinitionFile(atg.xml.XMLFile pDefinitionFile)
Sets the definitionFile


setChainLockWaitTimeout

public void setChainLockWaitTimeout(long pChainLockWaitTimeout)

getChainLockWaitTimeout

public long getChainLockWaitTimeout()

setTransactionManager

public void setTransactionManager(javax.transaction.TransactionManager pTransactionManager)

getTransactionManager

public javax.transaction.TransactionManager getTransactionManager()

getScheduler

public Scheduler getScheduler()
Returns the scheduler


setScheduler

public void setScheduler(Scheduler pScheduler)
Sets the scheduler


getSchedule

public Schedule getSchedule()
Returns the schedule


setSchedule

public void setSchedule(Schedule pSchedule)
Sets the schedule


getReinitializeOnChainExec

public boolean getReinitializeOnChainExec()
Returns property reinitializeOnChainExec. This property if true will check if the initialization files have changed whenever a chain is executed by calling runProcess(). If so, then the PipelineManager will be reinitialzed.

Returns:
returns property reinitializeOnChainExec

setReinitializeOnChainExec

public void setReinitializeOnChainExec(boolean pReinitializeOnChainExec)
Sets property reinitializeOnChainExec

Parameters:
pReinitializeOnChainExec - the value to set for property reinitializeOnChainExec

getLoggingDebugOnProcessors

public boolean getLoggingDebugOnProcessors()
Returns true if loggingDebug is true for the processors, false otherwise


setLoggingDebugOnProcessors

public void setLoggingDebugOnProcessors(boolean pLoggingDebug)
Turns on logging debug for all the processors in this PipelineManager


getChainContexts

public java.util.Hashtable getChainContexts()
Expose our chain contexts using a hidden, expert method.


doStartService

public void doStartService()
                    throws ServiceException
Calls the auto loader for the configuration file. Also schedules a job to reinitialize.

Overrides:
doStartService in class GenericService
Throws:
ServiceException - if the Service had a problem starting up

doStopService

public void doStopService()
                   throws ServiceException
Stops the scheduled service for reinitializing the PipelineManager

Overrides:
doStopService in class GenericService
Throws:
ServiceException - if the Service had a problem shutting down

performScheduledTask

public void performScheduledTask(Scheduler pScheduler,
                                 ScheduledJob pJob)
This is called when a scheduled job tied to this object occurs. The only scheduled job is to call reinitialize() to make the changes in the config file automatically.

Specified by:
performScheduledTask in interface Schedulable
Parameters:
pScheduler - calling the job
pJob - the ScheduledJob

reinitialize

public void reinitialize()
                  throws ServiceException
Rereads the XML configuration file and reconstructs the chains

Throws:
ServiceException

runProcess

public PipelineResult runProcess(java.lang.String pChainId,
                                 java.lang.Object pParam)
                          throws RunProcessException
This method runs the chain aChainId in the PipelineManager. It passes it aParam which is optional data. If the chain is disabled, then a RunProcessException is thrown.

Throws:
RunProcessException

lockChain

public PipelineChain lockChain(java.lang.String pChainId)
                        throws LockChainException
Locks a chain for editing. This method will block if there are any threads executing any processors in the chain. Once there are no threads executing the method will return. Any calls to runProcess() on this chain will block until the chain is unlocked. If the given chain is already locked a LockChainException will be thrown.

Throws:
LockChainException

unlockChain

public void unlockChain(java.lang.String pChainId)
                 throws UnlockChainException
Unlocks the given chain. If the chain is not locked then a UnlockChainException will be thrown.

Throws:
UnlockChainException

duplicateChain

public PipelineChain duplicateChain(java.lang.String pChainId)
                             throws DuplicateChainException
Duplicates a chain and its links and returns the new chain object. If the chain is locked by a thread other than the caller a DuplicateChainException will be thrown. Threads can be executing while a chain is being duplicated. Locking the chain before calling this method is not required. When the duplicate chain is created, it is disabled and locked so the user must call unlockChain() to allow other editors later, and enableChain() to allow execution on it.

Throws:
DuplicateChainException

copyChain

public PipelineChain copyChain(java.lang.String pChainId,
                               java.lang.String pNewChainId)
                        throws CopyChainException
Duplicates a chain and renames it. If the chain is locked by a thread other than the caller a CopyChainException will be thrown. Threads can be executing while a chain is being duplicated. Locking the chain before calling this method is not required. When the new chain is created, it is disabled and locked so the user must call unlockChain() to allow other editors later, and enableChain() to allow execution on it.

Throws:
CopyChainException

replaceChain

public void replaceChain(PipelineChain pChain)
                  throws ReplaceChainException
Replaces the chain in the PipelineManager with the given chain of the same name. If the given chain's name is not found in the PipelineManager then a ReplaceChainException is thrown. The chain in the PipelineManager which is to be replaced must be locked before calling this method. After this method completes, unlockChain() must be called with the chainId of these chains. The lock is implicitly passed from the src chain to the dest chain. If the chain is not locked when calling this method, then a ReplaceChainException is thrown.

Throws:
ReplaceChainException

enableChain

public void enableChain(java.lang.String pChainId)
                 throws EnableChainException,
                        LockChainException
Enables the given chain so that threads can execute it. The thread must have the chain locked first.

Throws:
EnableChainException
LockChainException

disableChain

public void disableChain(java.lang.String pChainId)
                  throws DisableChainException,
                         LockChainException
Disables the given chain so that threads cannot execute it. The thread must first lock the chain to ensure that no threads are executing it.

Throws:
DisableChainException
LockChainException

createChain

public PipelineChain createChain(java.lang.String pChainId)
                          throws CreateChainException
Creates a new chain in the PipelineManager. If the chainId exists a CreateChainException is thrown. When the chain is created, it is disabled and locked so the user must call unlockChain() to allow other editors later, and enableChain() to allow execution on it.

Throws:
CreateChainException

createChain

public PipelineChain createChain(java.lang.String pChainId,
                                 java.lang.String pChainClassName,
                                 java.lang.String pReturnTypeClassName)
                          throws CreateChainException
Creates a new chain in the PipelineManager using the class whose name is in aChainClassName and a return type class whose name is in aReturnTypeClassName. If the chainId exists a CreateChainException is thrown. The aChainClassName parameter contains the full name of a class which is to be used as the class for the PipelineChain object that the PipelineManager references. This class must be atg.pipeline.PipelineChain (the default) or a subclass of it. The aReturnTypeClassName is the name of the class that is to be used as the return type for the runProcess() method of the PipelineChain. The class must implement atg.pipeline.PipelineResult. The default is atg.pipeline.PipelineResult. When the chain is created, it is disabled and locked so the user must call unlockChain() to allow other editors later, and enableChain() to allow execution on it.

Throws:
CreateChainException

removeChain

public void removeChain(java.lang.String pChainId)
                 throws LockChainException,
                        RemoveChainException
Removes the given chain from the PipelineManager. The chain must be locked before calling this method, if not, then a RemoveChainException will be thrown. This method blocks until all threads executing this chain have completed. If the chainId is not found a RemoveChainException is thrown.

Throws:
LockChainException
RemoveChainException

chainExists

public boolean chainExists(java.lang.String pChainId)

createAdminServlet

protected javax.servlet.Servlet createAdminServlet()
Displays a table of the chains in the manager and their various states.

Overrides:
createAdminServlet in class GenericService