Package org.apache.ofbiz.service.job
Class GenericServiceJob
- java.lang.Object
-
- org.apache.ofbiz.service.job.AbstractJob
-
- org.apache.ofbiz.service.job.GenericServiceJob
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Runnable
,Job
- Direct Known Subclasses:
PersistedServiceJob
public class GenericServiceJob extends AbstractJob implements java.io.Serializable
A generic async-service job.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected DispatchContext
dctx
static java.lang.String
module
protected GenericRequester
requester
-
Fields inherited from class org.apache.ofbiz.service.job.AbstractJob
currentState
-
-
Constructor Summary
Constructors Constructor Description GenericServiceJob(DispatchContext dctx, java.lang.String jobId, java.lang.String jobName, java.lang.String service, java.util.Map<java.lang.String,java.lang.Object> context, GenericRequester req)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
deQueue()
Transitions this job to the pre-queued (created) state.void
exec()
Invokes the service.protected void
failed(java.lang.Throwable t)
Method is called when the service fails.protected void
finish(java.util.Map<java.lang.String,java.lang.Object> result)
Method is called after the service has finished successfully.protected java.util.Map<java.lang.String,java.lang.Object>
getContext()
Gets the context for the service invocation.protected java.lang.String
getServiceName()
Gets the name of the service as defined in the definition file.protected void
init()
Method is called prior to running the service.boolean
isValid()
Returns true if this job is ready to be queued.-
Methods inherited from class org.apache.ofbiz.service.job.AbstractJob
currentState, getJobId, getJobName, getRuntime, getStartTime, queue, run
-
-
-
-
Field Detail
-
module
public static final java.lang.String module
-
requester
protected final transient GenericRequester requester
-
dctx
protected final transient DispatchContext dctx
-
-
Constructor Detail
-
GenericServiceJob
public GenericServiceJob(DispatchContext dctx, java.lang.String jobId, java.lang.String jobName, java.lang.String service, java.util.Map<java.lang.String,java.lang.Object> context, GenericRequester req)
-
-
Method Detail
-
exec
public void exec() throws InvalidJobException
Invokes the service.- Specified by:
exec
in classAbstractJob
- Throws:
InvalidJobException
-
init
protected void init() throws InvalidJobException
Method is called prior to running the service.- Throws:
InvalidJobException
-
finish
protected void finish(java.util.Map<java.lang.String,java.lang.Object> result) throws InvalidJobException
Method is called after the service has finished successfully.- Throws:
InvalidJobException
-
failed
protected void failed(java.lang.Throwable t) throws InvalidJobException
Method is called when the service fails.- Parameters:
t
- Throwable- Throws:
InvalidJobException
-
getContext
protected java.util.Map<java.lang.String,java.lang.Object> getContext() throws InvalidJobException
Gets the context for the service invocation.- Returns:
- Map of name value pairs making up the service context.
- Throws:
InvalidJobException
-
getServiceName
protected java.lang.String getServiceName()
Gets the name of the service as defined in the definition file.- Returns:
- The name of the service to be invoked.
-
isValid
public boolean isValid()
Description copied from interface:Job
Returns true if this job is ready to be queued.
-
deQueue
public void deQueue() throws InvalidJobException
Description copied from interface:Job
Transitions this job to the pre-queued (created) state. The job manager will call this method when there was a problem adding this job to the queue.- Specified by:
deQueue
in interfaceJob
- Overrides:
deQueue
in classAbstractJob
- Throws:
InvalidJobException
-
-