com.evolveum.midpoint.task.impl
Class TaskImpl

java.lang.Object
  extended by com.evolveum.midpoint.task.impl.TaskImpl
All Implemented Interfaces:
Task

public class TaskImpl
extends java.lang.Object
implements Task

Implementation of a Task. This is very simplistic now. It does not even serialize itself.

Author:
Radovan Semancik
See Also:
TaskManagerImpl

Method Summary
 boolean canRun()
          Returns true if the task can run (was not interrupted).
 void close(OperationResult parentResult)
          Close the task.
 java.lang.String dump()
          Return human-readable representation of the task content.
 boolean equals(java.lang.Object obj)
           
 OperationResult getCurrentResult()
          Returns an OperationResult that was marked as the "current".
 TaskExclusivityStatus getExclusivityStatus()
          Returns task exclusivity status.
 TaskExecutionStatus getExecutionStatus()
          Returns execution status.
 PropertyContainer getExtension()
          Returns task extension.
 Property getExtension(javax.xml.namespace.QName propertyName)
           
 java.lang.String getHandlerUri()
          Returns handler URI.
 java.lang.Long getLastRunFinishTimestamp()
           
 java.lang.Long getLastRunStartTimestamp()
           
 java.lang.String getName()
          Returns human-readable name of the task.
 ObjectType getObject(OperationResult parentResult)
          Returns object that the task is associated with.
 java.lang.String getObjectOid()
          Returns OID of the object that the task is associated with.
 ObjectReferenceType getObjectRef()
          Returns reference to the object that the task is associated with.
 java.lang.String getOid()
          Returns task OID.
 TaskPersistenceStatus getPersistenceStatus()
          Returns task persistence status.
 long getProgress()
           
 OperationResult getResult()
          Returns a top-level OperationResult stored in the task.
 ScheduleType getSchedule()
           
 TaskType getTaskTypeObject()
           
 int hashCode()
           
 boolean isAsynchronous()
          Returns true if the task is asynchronous.
 boolean isCycle()
           
 boolean isSingle()
           
 void modifyExtension(java.util.List<PropertyModification> modifications, OperationResult parentResult)
          TODO The modification path is relative to the extension, therefore it will almost always be "." (or null).
 void recordRunFinish(TaskRunResult runResult, OperationResult parentResult)
          Record finish of the last "run" of the task TODO: better documentation
 void recordRunStart(OperationResult parentResult)
           
 void refresh(OperationResult parentResult)
          Re-reads the task state from the persistent storage.
 void setExclusivityStatus(TaskExclusivityStatus exclusivityStatus)
          Sets task exclusivity status.
 void setExecutionStatus(TaskExecutionStatus executionStatus)
          Sets task execution status.
 void setHandlerUri(java.lang.String handlerUri)
          Sets handler URI.
 void setName(java.lang.String name)
          Sets the human-readable name of the task.
 void setObjectRef(ObjectReferenceType objectRef)
           
 void setOid(java.lang.String oid)
          Sets task OID.
 void setPersistenceStatus(TaskPersistenceStatus persistenceStatus)
          Sets task persistence status.
 void shutdown()
          Signal the task to shut down.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

getExecutionStatus

public TaskExecutionStatus getExecutionStatus()
Description copied from interface: Task
Returns execution status.

Specified by:
getExecutionStatus in interface Task
Returns:
execution status.
See Also:
TaskExecutionStatus

getPersistenceStatus

public TaskPersistenceStatus getPersistenceStatus()
Description copied from interface: Task
Returns task persistence status.

Specified by:
getPersistenceStatus in interface Task
Returns:
task persistence status.
See Also:
TaskPersistenceStatus

getExclusivityStatus

public TaskExclusivityStatus getExclusivityStatus()
Description copied from interface: Task
Returns task exclusivity status.

Specified by:
getExclusivityStatus in interface Task
Returns:
task exclusivity status.
See Also:
TaskExclusivityStatus

isAsynchronous

public boolean isAsynchronous()
Description copied from interface: Task
Returns true if the task is asynchronous. The asynchronous task is not executing in foreground. Therefore any thread that is not explicitly allocated for the task can be discarded. E.g. if a GUI thread detects that the task is asynchronous it knows that there is no point in waiting for the task result. It can just display appropriate message to the user (e.g. "please come back later") and return control back to the web container.

Specified by:
isAsynchronous in interface Task
Returns:
true if the task is asynchronous.

getProgress

public long getProgress()
Specified by:
getProgress in interface Task

getObjectRef

public ObjectReferenceType getObjectRef()
Description copied from interface: Task
Returns reference to the object that the task is associated with. Tasks may be associated with a particular objects. For example a "import from resource" task is associated with the resource definition object that it imports from. Similarly for synchronization and reconciliation tasks (cycles). This is an optional property.

Specified by:
getObjectRef in interface Task
Returns:

setObjectRef

public void setObjectRef(ObjectReferenceType objectRef)
Specified by:
setObjectRef in interface Task

getObjectOid

public java.lang.String getObjectOid()
Description copied from interface: Task
Returns OID of the object that the task is associated with. Convenience method. This will get the OID from the objectRef.

Specified by:
getObjectOid in interface Task

getObject

public ObjectType getObject(OperationResult parentResult)
                     throws ObjectNotFoundException,
                            SchemaException
Description copied from interface: Task
Returns object that the task is associated with. Tasks may be associated with a particular objects. For example a "import from resource" task is associated with the resource definition object that it imports from. Similarly for synchronization and reconciliation tasks (cycles). This is an optional property. The object will only be returned if the task really contains an object without OID (e.g. unfinished account shadow). In all other cases this method may return null. Use getObjectRef instead. Optional. May return null.

Specified by:
getObject in interface Task
Throws:
ObjectNotFoundException
SchemaException

getResult

public OperationResult getResult()
Description copied from interface: Task
Returns a top-level OperationResult stored in the task.

Specified by:
getResult in interface Task
Returns:
task operation result.

getCurrentResult

public OperationResult getCurrentResult()
Description copied from interface: Task
Returns an OperationResult that was marked as the "current". It is the result used to compile task results (parent result) of an asynchronous operation, operation spanning a web service, etc.

Specified by:
getCurrentResult in interface Task
Returns:

getHandlerUri

public java.lang.String getHandlerUri()
Description copied from interface: Task
Returns handler URI. Handler URI indirectly specifies which class is responsible to handle the task. The handler will execute reaction to a task lifecycle events such as executing the task, task heartbeat, etc.

Specified by:
getHandlerUri in interface Task
Returns:
handler URI

setHandlerUri

public void setHandlerUri(java.lang.String handlerUri)
Description copied from interface: Task
Sets handler URI. Handler URI indirectly specifies which class is responsible to handle the task. The handler will execute reaction to a task lifecycle events such as executing the task, task heartbeat, etc.

Specified by:
setHandlerUri in interface Task
Parameters:
handlerUri - new handler URI

setExecutionStatus

public void setExecutionStatus(TaskExecutionStatus executionStatus)
Description copied from interface: Task
Sets task execution status.

Specified by:
setExecutionStatus in interface Task
Parameters:
executionStatus - new task execution status.
See Also:
TaskExecutionStatus

setPersistenceStatus

public void setPersistenceStatus(TaskPersistenceStatus persistenceStatus)
Description copied from interface: Task
Sets task persistence status.

Specified by:
setPersistenceStatus in interface Task
Parameters:
persistenceStatus - new task persistence status.
See Also:
TaskPersistenceStatus

setExclusivityStatus

public void setExclusivityStatus(TaskExclusivityStatus exclusivityStatus)
Description copied from interface: Task
Sets task exclusivity status.

Specified by:
setExclusivityStatus in interface Task
Parameters:
exclusivityStatus - new task exclusivity status.
See Also:
TaskExclusivityStatus

getOid

public java.lang.String getOid()
Description copied from interface: Task
Returns task OID. This returns null if the task is not persistent.

Specified by:
getOid in interface Task
Returns:
task OID

setOid

public void setOid(java.lang.String oid)
Description copied from interface: Task
Sets task OID. This method should not be used outside task manager. The OID should be considered read-only. TODO: be stricter and maybe do not publish this method at all.

Specified by:
setOid in interface Task
Parameters:
oid - new task OID.

getName

public java.lang.String getName()
Description copied from interface: Task
Returns human-readable name of the task.

Specified by:
getName in interface Task
Returns:
human-readable name of the task.

setName

public void setName(java.lang.String name)
Description copied from interface: Task
Sets the human-readable name of the task.

Specified by:
setName in interface Task
Parameters:
name - new human-readable name of the task.

getExtension

public PropertyContainer getExtension()
Description copied from interface: Task
Returns task extension. The extension is a part of task that can store arbitrary data. It usually holds data specific to a task type, internal task state, business state or similar data that are out of scope of this interface definition. Although this methods returns list, it should be rather regarded as set. The list is used to avoid unnecessary reordering of properties in the storage (in case store is ordering-sensitive). Returned list should be regarded as immutable. In case that the client does any change, weird things may happen.

Specified by:
getExtension in interface Task
Returns:
task extension

getExtension

public Property getExtension(javax.xml.namespace.QName propertyName)
Specified by:
getExtension in interface Task

modifyExtension

public void modifyExtension(java.util.List<PropertyModification> modifications,
                            OperationResult parentResult)
                     throws ObjectNotFoundException,
                            SchemaException
Description copied from interface: Task
TODO The modification path is relative to the extension, therefore it will almost always be "." (or null).

Specified by:
modifyExtension in interface Task
Throws:
ObjectNotFoundException
SchemaException

getTaskTypeObject

public TaskType getTaskTypeObject()
Specified by:
getTaskTypeObject in interface Task

getLastRunStartTimestamp

public java.lang.Long getLastRunStartTimestamp()
Specified by:
getLastRunStartTimestamp in interface Task

getLastRunFinishTimestamp

public java.lang.Long getLastRunFinishTimestamp()
Specified by:
getLastRunFinishTimestamp in interface Task

dump

public java.lang.String dump()
Description copied from interface: Task
Return human-readable representation of the task content. Useful for diagnostics. May return multi-line string.

Specified by:
dump in interface Task
Returns:
human-readable representation of the task content

recordRunStart

public void recordRunStart(OperationResult parentResult)
                    throws ObjectNotFoundException,
                           SchemaException
Specified by:
recordRunStart in interface Task
Throws:
ObjectNotFoundException
SchemaException

recordRunFinish

public void recordRunFinish(TaskRunResult runResult,
                            OperationResult parentResult)
                     throws ObjectNotFoundException,
                            SchemaException
Description copied from interface: Task
Record finish of the last "run" of the task TODO: better documentation

Specified by:
recordRunFinish in interface Task
Parameters:
runResult - result of the run to record
Throws:
ObjectNotFoundException
SchemaException

refresh

public void refresh(OperationResult parentResult)
             throws ObjectNotFoundException,
                    SchemaException
Description copied from interface: Task
Re-reads the task state from the persistent storage. The task state may be synchronized with the repository all the time. But the specified timing is implementation-specific. Call to this method will make sure that the task contains fresh data. This has no effect on transient tasks.

Specified by:
refresh in interface Task
Throws:
ObjectNotFoundException
SchemaException

close

public void close(OperationResult parentResult)
           throws ObjectNotFoundException,
                  SchemaException
Description copied from interface: Task
Close the task. This will NOT release the task. TODO

Specified by:
close in interface Task
Throws:
ObjectNotFoundException
SchemaException

isSingle

public boolean isSingle()
Specified by:
isSingle in interface Task

isCycle

public boolean isCycle()
Specified by:
isCycle in interface Task

getSchedule

public ScheduleType getSchedule()
Specified by:
getSchedule in interface Task

shutdown

public void shutdown()
Description copied from interface: Task
Signal the task to shut down. It may not stop immediately, but it should stop eventually.

Specified by:
shutdown in interface Task

canRun

public boolean canRun()
Description copied from interface: Task
Returns true if the task can run (was not interrupted). Will return false e.g. if shutdown was signaled.

Specified by:
canRun in interface Task
Returns:
true if the task can run

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

hashCode

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

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object


Copyright © 2011 evolveum. All Rights Reserved.