Top Description Fields Methods
jakarta.enterprise.concurrent

public Interface ManagedTask

Known Direct Implementers
jakarta.enterprise.concurrent.ManagedExecutors.Adapter
Imports
java.util.Map

A task submitted to an ManagedExecutorService or ManagedScheduledExecutorService can optionally implement this interface to provide identifying information about the task, to provide a ManagedTaskListener to get notification of lifecycle events of the task, or to provide additional execution properties.

See also ManagedExecutors.managedTask().

Since
1.0

Field Summary

Modifier and TypeField and Description
public static final String
IDENTITY_NAME

Execution property to be returned in getExecutionProperties() or ContextService.createContextualProxy() to provide a String that identifies the task.

public static final String
LONGRUNNING_HINT

Execution property to be returned in getExecutionProperties() or ContextService.createContextualProxy() to provide hint about whether the task could take a long time to complete.

public static final String
SUSPEND

Constant for the "SUSPEND" value of the TRANSACTION execution property.

public static final String
TRANSACTION

Execution property to be returned in getExecutionProperties() or ContextService.createContextualProxy() to inform the Jakarta EE Product Provider under which transaction should the task or proxy method of contextual proxy object be executed in. Valid values are:

"SUSPEND" (the default if unspecified) - Any transaction that is currently active on the thread will be suspended and a jakarta.transaction.UserTransaction (accessible in the local JNDI namespace as "java:comp/UserTransaction") will be available.

public static final String
USE_TRANSACTION_OF_EXECUTION_THREAD

Constant for the "USE_TRANSACTION_OF_EXECUTION_THREAD" value of the TRANSACTION execution property.

Method Summary

Modifier and TypeMethod and Description
public Map<String, String>

Returns:

A Map<String, String> containing additional execution properties, or null if no additional information is provided for this task.
getExecutionProperties
()

Provides additional information to the ManagedExecutorService or ManagedScheduledExecutorService when executing this task.

public ManagedTaskListener

Returns:

The ManagedTaskListener to receive notification of lifecycle events of this task, or null if it is not necessary to get notified of such events.
getManagedTaskListener
()

The ManagedTaskListener to receive notification of lifecycle events of this task.

Field Detail

IDENTITY_NAMEback to summary
public static final String IDENTITY_NAME

Execution property to be returned in getExecutionProperties() or ContextService.createContextualProxy() to provide a String that identifies the task. It may be the name or ID that allow management facilities to inspect the task to determine the intent of the task and its state. Implementations should not depend upon any thread execution context and should typically return only readily-available instance data to identify the task.

LONGRUNNING_HINTback to summary
public static final String LONGRUNNING_HINT

Execution property to be returned in getExecutionProperties() or ContextService.createContextualProxy() to provide hint about whether the task could take a long time to complete. Jakarta™ EE Product Providers may make use of this hint value to decide how to allocate thread resource for running this task. Valid values are "true" or "false".

SUSPENDback to summary
public static final String SUSPEND

Constant for the "SUSPEND" value of the TRANSACTION execution property. See ManagedTask#TRANSACTION.

TRANSACTIONback to summary
public static final String TRANSACTION

Execution property to be returned in getExecutionProperties() or ContextService.createContextualProxy() to inform the Jakarta EE Product Provider under which transaction should the task or proxy method of contextual proxy object be executed in. Valid values are:

"SUSPEND" (the default if unspecified) - Any transaction that is currently active on the thread will be suspended and a jakarta.transaction.UserTransaction (accessible in the local JNDI namespace as "java:comp/UserTransaction") will be available. The original transaction, if any was active on the thread, will be resumed when the task or contextual proxy object method returns.

"USE_TRANSACTION_OF_EXECUTION_THREAD" - The contextual proxy object method will run within the transaction (if any) of the execution thread. A jakarta.transaction.UserTransaction will only be available if it is also available in the execution thread (for example, when the proxy method is invoked from a Servlet or Bean Managed Transaction). When there is no existing transaction on the execution thread, such as when running tasks that are submitted to a ManagedExecutorService or a ManagedScheduledExecutorService, a jakarta.transaction.UserTransaction will be available.

USE_TRANSACTION_OF_EXECUTION_THREADback to summary
public static final String USE_TRANSACTION_OF_EXECUTION_THREAD

Constant for the "USE_TRANSACTION_OF_EXECUTION_THREAD" value of the TRANSACTION execution property. See ManagedTask#TRANSACTION.

Method Detail

getExecutionPropertiesback to summary
public Map<String, String> getExecutionProperties()

Provides additional information to the ManagedExecutorService or ManagedScheduledExecutorService when executing this task.

Some standard property keys are defined in this class. Custom property keys may be defined but must not begin with "jakarta.enterprise.concurrent.".

Returns:Map<String, String>

A Map<String, String> containing additional execution properties, or null if no additional information is provided for this task.

getManagedTaskListenerback to summary
public ManagedTaskListener getManagedTaskListener()

The ManagedTaskListener to receive notification of lifecycle events of this task.

Returns:ManagedTaskListener

The ManagedTaskListener to receive notification of lifecycle events of this task, or null if it is not necessary to get notified of such events.