de.phleisch.app.itsucks.job.impl
Class AbstractJob

java.lang.Object
  extended by de.phleisch.app.itsucks.job.impl.AbstractJob
All Implemented Interfaces:
Job, java.io.Serializable
Direct Known Subclasses:
UrlDownloadJob

public abstract class AbstractJob
extends java.lang.Object
implements java.io.Serializable, Job

A job is a single task to be done. This is the abstract class for the basic functionality.

Author:
olli
See Also:
Serialized Form

Field Summary
protected  Context mGroupContext
           
protected  JobManager mJobManager
           
 
Fields inherited from interface de.phleisch.app.itsucks.job.Job
JOB_PRIORITY_PROPERTY, JOB_STATE_PROPERTY, MAX_PRIORITY, MIN_PRIORITY, STATE_ALREADY_PROCESSED, STATE_ASSIGNED, STATE_CLOSED, STATE_ERROR, STATE_FAILED, STATE_FINISHED, STATE_IGNORED, STATE_IN_PROGRESS, STATE_IN_PROGRESS_RETRY, STATE_OPEN, STATE_REOPEN
 
Constructor Summary
AbstractJob()
           
 
Method Summary
abstract  void abort()
          Aborts the job when running.
 void addPropertyChangeListener(java.beans.PropertyChangeListener pListener)
          Adds a PropertyChangeListener to the listener list.
protected  java.beans.PropertyChangeEvent firePropertyChange(java.lang.String propertyName, java.lang.Object oldValue, java.lang.Object newValue)
           
 Context getGroupContext()
          The context for this job group.
 int getId()
          Returns the unique id of this job.
 JobManager getJobManager()
          The job manager the job is managed by.
 java.lang.String getName()
          Gets the name of the job
 JobParameter getParameter(java.lang.String pKey)
          Returns the parameter under the given key or null.
 java.util.List<JobParameter> getParameterList()
          Get a list of all job parameter
 int getPriority()
          The higher the number, the higher the priority, max is 999, min is 0 Default is 500
 int getState()
          Returns the current state of the Job.
 int hashCode()
           
 boolean isClosed()
          Returns true when the job is closed.
 boolean isIgnoreFilter()
          Returns true when the filter should not be applied for this job.
 void removePropertyChangeListener(java.beans.PropertyChangeListener pListener)
          Removes a PropertyChangeListener from the listener list.
abstract  void run()
          Starts the execution of the job.
 void setGroupContext(Context pContext)
          Sets the context for this job group.
 void setId(int pJobId)
          Sets the id of this job.
 void setIgnoreFilter(boolean pIgnoreFilter)
          When set to true, the JobFilter will not filter out this job.
 void setJobManager(JobManager pJobManager)
          Sets the jobManager for this job.
 void setName(java.lang.String pName)
          Sets the name of the job
 void setParameter(JobParameter pParameter)
          Set a parameter to the job
 void setPriority(int pPriority)
          The higher the number, the higher the priority, max is 999, min is 0 Default is 500
 void setState(int pState)
          Sets the current state of the job.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mGroupContext

protected transient Context mGroupContext

mJobManager

protected transient JobManager mJobManager
Constructor Detail

AbstractJob

public AbstractJob()
Method Detail

run

public abstract void run()
                  throws java.lang.Exception
Description copied from interface: Job
Starts the execution of the job. It returns when the job is finished.

Specified by:
run in interface Job
Throws:
java.lang.Exception

isClosed

public boolean isClosed()
Description copied from interface: Job
Returns true when the job is closed.

Specified by:
isClosed in interface Job
Returns:
true when job is closed.

getJobManager

public JobManager getJobManager()
Description copied from interface: Job
The job manager the job is managed by.

Specified by:
getJobManager in interface Job
Returns:
the job manager the job is managed by.

setJobManager

public void setJobManager(JobManager pJobManager)
Description copied from interface: Job
Sets the jobManager for this job.

Specified by:
setJobManager in interface Job

getGroupContext

public Context getGroupContext()
Description copied from interface: Job
The context for this job group.

Specified by:
getGroupContext in interface Job
Returns:
the context the job belongs.

setGroupContext

public void setGroupContext(Context pContext)
Description copied from interface: Job
Sets the context for this job group.

Specified by:
setGroupContext in interface Job
Parameters:
pContext - the context the job belongs.

isIgnoreFilter

public boolean isIgnoreFilter()
Description copied from interface: Job
Returns true when the filter should not be applied for this job.

Specified by:
isIgnoreFilter in interface Job
Returns:

setIgnoreFilter

public void setIgnoreFilter(boolean pIgnoreFilter)
Description copied from interface: Job
When set to true, the JobFilter will not filter out this job. Handy for manual added jobs.

Specified by:
setIgnoreFilter in interface Job

getState

public int getState()
Description copied from interface: Job
Returns the current state of the Job. Check out the STATE_* constants for possible values.

Specified by:
getState in interface Job
Returns:
the current state of the Job.

setState

public void setState(int pState)
Description copied from interface: Job
Sets the current state of the job. The observers will be notificated from this change.

Specified by:
setState in interface Job

getPriority

public int getPriority()
Description copied from interface: Job
The higher the number, the higher the priority, max is 999, min is 0 Default is 500

Specified by:
getPriority in interface Job
Returns:
the current priority for this job.

setPriority

public void setPriority(int pPriority)
Description copied from interface: Job
The higher the number, the higher the priority, max is 999, min is 0 Default is 500

Specified by:
setPriority in interface Job

getId

public int getId()
Description copied from interface: Job
Returns the unique id of this job.

Specified by:
getId in interface Job
Returns:
the unique id of this job.

setId

public void setId(int pJobId)
Description copied from interface: Job
Sets the id of this job. Do this only when the job is not added to a job list!

Specified by:
setId in interface Job

getName

public java.lang.String getName()
Description copied from interface: Job
Gets the name of the job

Specified by:
getName in interface Job
Returns:

setName

public void setName(java.lang.String pName)
Description copied from interface: Job
Sets the name of the job

Specified by:
setName in interface Job

setParameter

public void setParameter(JobParameter pParameter)
Description copied from interface: Job
Set a parameter to the job

Specified by:
setParameter in interface Job

getParameter

public JobParameter getParameter(java.lang.String pKey)
Description copied from interface: Job
Returns the parameter under the given key or null.

Specified by:
getParameter in interface Job
Returns:

getParameterList

public java.util.List<JobParameter> getParameterList()
Description copied from interface: Job
Get a list of all job parameter

Specified by:
getParameterList in interface Job
Returns:

abort

public abstract void abort()
Description copied from interface: Job
Aborts the job when running.

Specified by:
abort in interface Job

addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener pListener)
Description copied from interface: Job
Adds a PropertyChangeListener to the listener list. The listener is registered for all Accessible properties and will be called when those properties change.

Specified by:
addPropertyChangeListener in interface Job
Parameters:
pListener - The PropertyChangeListener to be added
See Also:
Job.JOB_PRIORITY_PROPERTY, Job.JOB_STATE_PROPERTY

removePropertyChangeListener

public void removePropertyChangeListener(java.beans.PropertyChangeListener pListener)
Description copied from interface: Job
Removes a PropertyChangeListener from the listener list. This removes a PropertyChangeListener that was registered for all properties.

Specified by:
removePropertyChangeListener in interface Job
Parameters:
pListener - The PropertyChangeListener to be removed

firePropertyChange

protected java.beans.PropertyChangeEvent firePropertyChange(java.lang.String propertyName,
                                                            java.lang.Object oldValue,
                                                            java.lang.Object newValue)

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object


Copyright © 2010. All Rights Reserved.