org.ofbiz.service.job
Class JobManager

java.lang.Object
  extended by org.ofbiz.service.job.JobManager

public class JobManager
extends java.lang.Object

JobManager


Field Summary
protected  GenericDelegator delegator
           
static java.lang.String dispatcherName
           
static java.lang.String instanceId
           
protected  JobPoller jp
           
static java.lang.String module
           
static java.util.Map<java.lang.String,JobManager> registeredManagers
           
static java.util.Map<java.lang.String,java.lang.Object> updateFields
           
 
Constructor Summary
JobManager(GenericDelegator delegator)
          Creates a new JobManager object.
JobManager(GenericDelegator delegator, boolean enabled)
           
 
Method Summary
 void finalize()
           
 GenericDelegator getDelegator()
          Returns the GenericDelegator.
 LocalDispatcher getDispatcher()
          Returns the ServiceDispatcher.
static JobManager getInstance(GenericDelegator delegator, boolean enabled)
           
static RecurrenceInfo getRecurrenceInfo(GenericValue job)
          gets the recurrence info object for a job.
 void killThread(java.lang.String threadName)
          Kill a JobInvoker Thread.
 java.util.List<Job> poll()
           
 java.util.List<java.util.Map<java.lang.String,java.lang.Object>> processList()
          Get a List of each threads current state.
 void reloadCrashedJobs()
           
 void runJob(Job job)
          Queues a Job to run now.
 void schedule(java.lang.String serviceName, java.util.Map<java.lang.String,? extends java.lang.Object> context, long startTime, int frequency, int interval, int count)
          Schedule a job to start at a specific time with specific recurrence info
 void schedule(java.lang.String serviceName, java.util.Map<java.lang.String,? extends java.lang.Object> context, long startTime, int frequency, int interval, int count, long endTime)
          Schedule a job to start at a specific time with specific recurrence info
 void schedule(java.lang.String serviceName, java.util.Map<java.lang.String,? extends java.lang.Object> context, long startTime, int frequency, int interval, long endTime)
          Schedule a job to start at a specific time with specific recurrence info
 void schedule(java.lang.String poolName, java.lang.String serviceName, java.util.Map<java.lang.String,? extends java.lang.Object> context, long startTime, int frequency, int interval, int count, long endTime)
          Schedule a job to start at a specific time with specific recurrence info
 void schedule(java.lang.String poolName, java.lang.String serviceName, java.lang.String dataId, long startTime)
          Schedule a job to start at a specific time with specific recurrence info
 void schedule(java.lang.String jobName, java.lang.String poolName, java.lang.String serviceName, java.util.Map<java.lang.String,? extends java.lang.Object> context, long startTime, int frequency, int interval, int count, long endTime, int maxRetry)
          Schedule a job to start at a specific time with specific recurrence info
 void schedule(java.lang.String jobName, java.lang.String poolName, java.lang.String serviceName, java.lang.String dataId, long startTime, int frequency, int interval, int count, long endTime, int maxRetry)
          Schedule a job to start at a specific time with specific recurrence info
 void shutdown()
          Close out the scheduler thread.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

instanceId

public static final java.lang.String instanceId

updateFields

public static final java.util.Map<java.lang.String,java.lang.Object> updateFields

module

public static final java.lang.String module

dispatcherName

public static final java.lang.String dispatcherName
See Also:
Constant Field Values

registeredManagers

public static java.util.Map<java.lang.String,JobManager> registeredManagers

delegator

protected GenericDelegator delegator

jp

protected JobPoller jp
Constructor Detail

JobManager

public JobManager(GenericDelegator delegator)
Creates a new JobManager object.


JobManager

public JobManager(GenericDelegator delegator,
                  boolean enabled)
Method Detail

getInstance

public static JobManager getInstance(GenericDelegator delegator,
                                     boolean enabled)

runJob

public void runJob(Job job)
            throws JobManagerException
Queues a Job to run now.

Throws:
JobManagerException

getDispatcher

public LocalDispatcher getDispatcher()
Returns the ServiceDispatcher.


getDelegator

public GenericDelegator getDelegator()
Returns the GenericDelegator.


poll

public java.util.List<Job> poll()

reloadCrashedJobs

public void reloadCrashedJobs()

schedule

public void schedule(java.lang.String serviceName,
                     java.util.Map<java.lang.String,? extends java.lang.Object> context,
                     long startTime,
                     int frequency,
                     int interval,
                     int count)
              throws JobManagerException
Schedule a job to start at a specific time with specific recurrence info

Parameters:
serviceName - The name of the service to invoke
context - The context for the service
startTime - The time in milliseconds the service should run
frequency - The frequency of the recurrence (HOURLY,DAILY,MONTHLY,etc)
interval - The interval of the frequency recurrence
count - The number of times to repeat
Throws:
JobManagerException

schedule

public void schedule(java.lang.String serviceName,
                     java.util.Map<java.lang.String,? extends java.lang.Object> context,
                     long startTime,
                     int frequency,
                     int interval,
                     long endTime)
              throws JobManagerException
Schedule a job to start at a specific time with specific recurrence info

Parameters:
serviceName - The name of the service to invoke
context - The context for the service
startTime - The time in milliseconds the service should run
frequency - The frequency of the recurrence (HOURLY,DAILY,MONTHLY,etc)
interval - The interval of the frequency recurrence
endTime - The time in milliseconds the service should expire
Throws:
JobManagerException

schedule

public void schedule(java.lang.String serviceName,
                     java.util.Map<java.lang.String,? extends java.lang.Object> context,
                     long startTime,
                     int frequency,
                     int interval,
                     int count,
                     long endTime)
              throws JobManagerException
Schedule a job to start at a specific time with specific recurrence info

Parameters:
serviceName - The name of the service to invoke
context - The context for the service
startTime - The time in milliseconds the service should run
frequency - The frequency of the recurrence (HOURLY,DAILY,MONTHLY,etc)
interval - The interval of the frequency recurrence
count - The number of times to repeat
endTime - The time in milliseconds the service should expire
Throws:
JobManagerException

schedule

public void schedule(java.lang.String poolName,
                     java.lang.String serviceName,
                     java.util.Map<java.lang.String,? extends java.lang.Object> context,
                     long startTime,
                     int frequency,
                     int interval,
                     int count,
                     long endTime)
              throws JobManagerException
Schedule a job to start at a specific time with specific recurrence info

Parameters:
poolName - The name of the pool to run the service from
serviceName - The name of the service to invoke
context - The context for the service
startTime - The time in milliseconds the service should run
frequency - The frequency of the recurrence (HOURLY,DAILY,MONTHLY,etc)
interval - The interval of the frequency recurrence
count - The number of times to repeat
endTime - The time in milliseconds the service should expire
Throws:
JobManagerException

schedule

public void schedule(java.lang.String jobName,
                     java.lang.String poolName,
                     java.lang.String serviceName,
                     java.util.Map<java.lang.String,? extends java.lang.Object> context,
                     long startTime,
                     int frequency,
                     int interval,
                     int count,
                     long endTime,
                     int maxRetry)
              throws JobManagerException
Schedule a job to start at a specific time with specific recurrence info

Parameters:
jobName - The name of the job
poolName - The name of the pool to run the service from
serviceName - The name of the service to invoke
context - The context for the service
startTime - The time in milliseconds the service should run
frequency - The frequency of the recurrence (HOURLY,DAILY,MONTHLY,etc)
interval - The interval of the frequency recurrence
count - The number of times to repeat
endTime - The time in milliseconds the service should expire
maxRetry - The max number of retries on failure (-1 for no max)
Throws:
JobManagerException

schedule

public void schedule(java.lang.String poolName,
                     java.lang.String serviceName,
                     java.lang.String dataId,
                     long startTime)
              throws JobManagerException
Schedule a job to start at a specific time with specific recurrence info

Parameters:
poolName - The name of the pool to run the service from
serviceName - The name of the service to invoke
dataId - The persisted context (RuntimeData.runtimeDataId)
startTime - The time in milliseconds the service should run
Throws:
JobManagerException

schedule

public void schedule(java.lang.String jobName,
                     java.lang.String poolName,
                     java.lang.String serviceName,
                     java.lang.String dataId,
                     long startTime,
                     int frequency,
                     int interval,
                     int count,
                     long endTime,
                     int maxRetry)
              throws JobManagerException
Schedule a job to start at a specific time with specific recurrence info

Parameters:
jobName - The name of the job
poolName - The name of the pool to run the service from
serviceName - The name of the service to invoke
dataId - The persisted context (RuntimeData.runtimeDataId)
startTime - The time in milliseconds the service should run
frequency - The frequency of the recurrence (HOURLY,DAILY,MONTHLY,etc)
interval - The interval of the frequency recurrence
count - The number of times to repeat
endTime - The time in milliseconds the service should expire
maxRetry - The max number of retries on failure (-1 for no max)
Throws:
JobManagerException

killThread

public void killThread(java.lang.String threadName)
Kill a JobInvoker Thread.

Parameters:
threadName - Name of the JobInvoker Thread to kill.

processList

public java.util.List<java.util.Map<java.lang.String,java.lang.Object>> processList()
Get a List of each threads current state.

Returns:
List containing a Map of each thread's state.

shutdown

public void shutdown()
Close out the scheduler thread.


finalize

public void finalize()
              throws java.lang.Throwable
Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable

getRecurrenceInfo

public static RecurrenceInfo getRecurrenceInfo(GenericValue job)
gets the recurrence info object for a job.