Top Description Inners Fields Constructors Methods
jakarta.enterprise.concurrent

public final Class ManagedExecutors

extends Object
Class Inheritance
Imports
java.util.HashMap, .Map, java.util.concurrent.Callable

Utility methods for classes defined in this package.
Since
1.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class
pack-priv static class
ManagedExecutors.CallableAdapter<V>

Adapter for Callable to include ManagedTask interface methods.

pack-priv static class
ManagedExecutors.RunnableAdapter

Adapter for Runnable to include ManagedTask interface methods.

Field Summary

Modifier and TypeField and Description
pack-priv static final String
NULL_TASK_ERROR_MSG

Error message for null tasks.

Constructor Summary

AccessConstructor and Description
private
ManagedExecutors()

Not suppose to create instances of this class.

Method Summary

Modifier and TypeMethod and Description
public static boolean

Returns:

Returns the isShutdown() value if the current thread is a ManageableThread created by ManagedThreadFactory, or false if the current thread is not a ManageableThread.
isCurrentThreadShutdown
()

Utility method for checking the isShutdown() value of the current thread if it is a ManageableThread created from ManagedThreadFactory.newThread() .

public static Runnable

Returns:

a Runnable object
managedTask
(final Runnable
the task to have the given ManagedTaskListener associated with
task
,
final ManagedTaskListener
(optional) the ManagedTaskListener to receive lifecycle events notification when the task is submitted. If task implements ManagedTask, and taskListener is not null, the ManagedTaskListener interface methods of the task will not be called.
taskListener
)

Returns a Runnable object that also implements ManagedTask interface so it can receive notification of lifecycle events with the provided ManagedTaskListener when the task is submitted to a ManagedExecutorService or a ManagedScheduledExecutorService.

public static Runnable

Returns:

a Runnable object
managedTask
(final Runnable
the task to have the given ManagedTaskListener associated with
task
,
final Map<String, String>
(optional) execution properties to provide additional hints to ManagedExecutorService or ManagedScheduledExecutorService when the task is submitted. If task implements ManagedTask with non-empty execution properties, the Runnable returned will contain the union of the execution properties specified in the task and the executionProperties argument, with the latter taking precedence if the same property key is specified in both. After the method is called, further changes to the Map object will not be reflected in the Runnable returned by this method.
executionProperties
,
final ManagedTaskListener
(optional) the ManagedTaskListener to receive lifecycle events notification when the task is submitted. If task implements ManagedTask, and taskListener is not null, the ManagedTaskListener interface methods of the task will not be called.
taskListener
)

Returns a Runnable object that also implements ManagedTask interface so it can receive notification of lifecycle events with the provided ManagedTaskListener and to provide additional execution properties when the task is submitted to a ManagedExecutorService or a ManagedScheduledExecutorService.

public static <
the return type of the Callable
V
>
Callable<V>

Returns:

a Callable object
managedTask
(final Callable<V>
the task to have the given ManagedTaskListener associated with
task
,
final ManagedTaskListener
(optional) the ManagedTaskListener to receive lifecycle events notification when the task is submitted. If task implements ManagedTask, and taskListener is not null, the ManagedTaskListener interface methods of the task will not be called.
taskListener
)

Returns a Callable object that also implements ManagedTask interface so it can receive notification of lifecycle events with the provided ManagedTaskListener when the task is submitted to a ManagedExecutorService or a ManagedScheduledExecutorService.

public static <
the result type of the Callable
V
>
Callable<V>

Returns:

a Callable object
managedTask
(final Callable<V>
the task to have the given ManagedTaskListener associated with
task
,
final Map<String, String>
(optional) execution properties to provide additional hints to ManagedExecutorService or ManagedScheduledExecutorService when the task is submitted. If task implements ManagedTask with non-empty execution properties, the Runnable returned will contain the union of the execution properties specified in the task and the executionProperties argument, with the latter taking precedence if the same property key is specified in both. After the method is called, further changes to the Map object will not be reflected in the Callable returned by this method.
executionProperties
,
final ManagedTaskListener
(optional) the ManagedTaskListener to receive lifecycle events notification when the task is submitted. If task implements ManagedTask, and taskListener is not null, the ManagedTaskListener interface methods of the task will not be called.
taskListener
)

Returns a Callable object that also implements ManagedTask interface so it can receive notification of lifecycle events with the provided ManagedTaskListener and to provide additional execution properties when the task is submitted to a ManagedExecutorService or a ManagedScheduledExecutorService.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

NULL_TASK_ERROR_MSGback to summary
pack-priv static final String NULL_TASK_ERROR_MSG

Error message for null tasks.

Constructor Detail

ManagedExecutorsback to summary
private ManagedExecutors()

Not suppose to create instances of this class.

Method Detail

isCurrentThreadShutdownback to summary
public static boolean isCurrentThreadShutdown()

Utility method for checking the isShutdown() value of the current thread if it is a ManageableThread created from ManagedThreadFactory.newThread() .

Returns:boolean

Returns the isShutdown() value if the current thread is a ManageableThread created by ManagedThreadFactory, or false if the current thread is not a ManageableThread.

managedTaskback to summary
public static Runnable managedTask(final Runnable task, final ManagedTaskListener taskListener) throws IllegalArgumentException

Returns a Runnable object that also implements ManagedTask interface so it can receive notification of lifecycle events with the provided ManagedTaskListener when the task is submitted to a ManagedExecutorService or a ManagedScheduledExecutorService.

Example:

Runnable task = ...;
ManagedTaskListener myTaskListener = ...;
ManagedExecutorService executor = ...;

Runnable taskWithListener = ManagedExecutors.managedTask(task, myTaskListener);
executor.submit(taskWithListener);
Parameters
task:Runnable

the task to have the given ManagedTaskListener associated with

taskListener:ManagedTaskListener

(optional) the ManagedTaskListener to receive lifecycle events notification when the task is submitted. If task implements ManagedTask, and taskListener is not null, the ManagedTaskListener interface methods of the task will not be called.

Returns:Runnable

a Runnable object

Exceptions
IllegalArgumentException:
if task is null
managedTaskback to summary
public static Runnable managedTask(final Runnable task, final Map<String, String> executionProperties, final ManagedTaskListener taskListener) throws IllegalArgumentException

Returns a Runnable object that also implements ManagedTask interface so it can receive notification of lifecycle events with the provided ManagedTaskListener and to provide additional execution properties when the task is submitted to a ManagedExecutorService or a ManagedScheduledExecutorService.

Parameters
task:Runnable

the task to have the given ManagedTaskListener associated with

executionProperties:Map<String, String>

(optional) execution properties to provide additional hints to ManagedExecutorService or ManagedScheduledExecutorService when the task is submitted. If task implements ManagedTask with non-empty execution properties, the Runnable returned will contain the union of the execution properties specified in the task and the executionProperties argument, with the latter taking precedence if the same property key is specified in both. After the method is called, further changes to the Map object will not be reflected in the Runnable returned by this method.

taskListener:ManagedTaskListener

(optional) the ManagedTaskListener to receive lifecycle events notification when the task is submitted. If task implements ManagedTask, and taskListener is not null, the ManagedTaskListener interface methods of the task will not be called.

Returns:Runnable

a Runnable object

Exceptions
IllegalArgumentException:
if task is null
managedTaskback to summary
public static <V> Callable<V> managedTask(final Callable<V> task, final ManagedTaskListener taskListener) throws IllegalArgumentException

Returns a Callable object that also implements ManagedTask interface so it can receive notification of lifecycle events with the provided ManagedTaskListener when the task is submitted to a ManagedExecutorService or a ManagedScheduledExecutorService.

Parameters
<V>
the return type of the Callable
task:Callable<V>

the task to have the given ManagedTaskListener associated with

taskListener:ManagedTaskListener

(optional) the ManagedTaskListener to receive lifecycle events notification when the task is submitted. If task implements ManagedTask, and taskListener is not null, the ManagedTaskListener interface methods of the task will not be called.

Returns:Callable<V>

a Callable object

Exceptions
IllegalArgumentException:
if task is null
managedTaskback to summary
public static <V> Callable<V> managedTask(final Callable<V> task, final Map<String, String> executionProperties, final ManagedTaskListener taskListener) throws IllegalArgumentException

Returns a Callable object that also implements ManagedTask interface so it can receive notification of lifecycle events with the provided ManagedTaskListener and to provide additional execution properties when the task is submitted to a ManagedExecutorService or a ManagedScheduledExecutorService.

Parameters
<V>
the result type of the Callable
task:Callable<V>

the task to have the given ManagedTaskListener associated with

executionProperties:Map<String, String>

(optional) execution properties to provide additional hints to ManagedExecutorService or ManagedScheduledExecutorService when the task is submitted. If task implements ManagedTask with non-empty execution properties, the Runnable returned will contain the union of the execution properties specified in the task and the executionProperties argument, with the latter taking precedence if the same property key is specified in both. After the method is called, further changes to the Map object will not be reflected in the Callable returned by this method.

taskListener:ManagedTaskListener

(optional) the ManagedTaskListener to receive lifecycle events notification when the task is submitted. If task implements ManagedTask, and taskListener is not null, the ManagedTaskListener interface methods of the task will not be called.

Returns:Callable<V>

a Callable object

Exceptions
IllegalArgumentException:
if task is null
jakarta.enterprise.concurrent back to summary

pack-priv Class ManagedExecutors.Adapter

extends Object
implements ManagedTask
Class Inheritance
All Implemented Interfaces
jakarta.enterprise.concurrent.ManagedTask
Known Direct Subclasses
jakarta.enterprise.concurrent.ManagedExecutors.RunnableAdapter, jakarta.enterprise.concurrent.ManagedExecutors.CallableAdapter

Field Summary

Modifier and TypeField and Description
private final Map<String, String>
private final ManagedTask
private final ManagedTaskListener

Constructor Summary

AccessConstructor and Description
public
Adapter(final ManagedTaskListener taskListener, final Map<String, String> executionProperties, final ManagedTask managedTask)

Method Summary

Modifier and TypeMethod and Description
public Map<String, String>
public ManagedTaskListener
getManagedTaskListener()

Implements jakarta.enterprise.concurrent.ManagedTask.getManagedTaskListener.

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

private Map<String, String>
initExecutionProperties(final Map<String, String> base, final Map<String, String> override)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

executionPropertiesback to summary
private final Map<String, String> executionProperties
managedTaskback to summary
private final ManagedTask managedTask
taskListenerback to summary
private final ManagedTaskListener taskListener

Constructor Detail

Adapterback to summary
public Adapter(final ManagedTaskListener taskListener, final Map<String, String> executionProperties, final ManagedTask managedTask)

Method Detail

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

Implements jakarta.enterprise.concurrent.ManagedTask.getExecutionProperties.

Doc from jakarta.enterprise.concurrent.ManagedTask.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.

Annotations
@Override
getManagedTaskListenerback to summary
public ManagedTaskListener getManagedTaskListener()

Implements jakarta.enterprise.concurrent.ManagedTask.getManagedTaskListener.

Doc from jakarta.enterprise.concurrent.ManagedTask.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.

Annotations
@Override
initExecutionPropertiesback to summary
private Map<String, String> initExecutionProperties(final Map<String, String> base, final Map<String, String> override)
jakarta.enterprise.concurrent back to summary

pack-priv final Class ManagedExecutors.CallableAdapter<V>

extends Adapter
implements Callable<V>
Class Inheritance
All Implemented Interfaces
java.util.concurrent.Callable

Adapter for Callable to include ManagedTask interface methods.

Field Summary

Modifier and TypeField and Description
private final Callable<V>

Constructor Summary

AccessConstructor and Description
public
CallableAdapter(final Callable<V> task, final Map<String, String> executionProperties, final ManagedTaskListener taskListener)

Method Summary

Modifier and TypeMethod and Description
public V
call()

Implements java.util.concurrent.Callable.call.

Computes a result, or throws an exception if unable to do so.

Inherited from jakarta.enterprise.concurrent.ManagedExecutors.Adapter:
getExecutionPropertiesgetManagedTaskListener

Field Detail

taskback to summary
private final Callable<V> task

Constructor Detail

CallableAdapterback to summary
public CallableAdapter(final Callable<V> task, final Map<String, String> executionProperties, final ManagedTaskListener taskListener)

Method Detail

callback to summary
public V call() throws Exception

Implements java.util.concurrent.Callable.call.

Doc from java.util.concurrent.Callable.call.

Computes a result, or throws an exception if unable to do so.

Returns:V

computed result

Annotations
@Override
Exceptions
Exception:
if unable to compute a result
jakarta.enterprise.concurrent back to summary

pack-priv final Class ManagedExecutors.RunnableAdapter

extends Adapter
implements Runnable
Class Inheritance
All Implemented Interfaces
java.lang.Runnable

Adapter for Runnable to include ManagedTask interface methods.

Field Summary

Modifier and TypeField and Description
private final Runnable

Constructor Summary

AccessConstructor and Description
public
RunnableAdapter(final Runnable task, final Map<String, String> executionProperties, final ManagedTaskListener taskListener)

Method Summary

Modifier and TypeMethod and Description
public void
run()

Implements java.lang.Runnable.run.

Runs this operation.

Inherited from jakarta.enterprise.concurrent.ManagedExecutors.Adapter:
getExecutionPropertiesgetManagedTaskListener

Field Detail

taskback to summary
private final Runnable task

Constructor Detail

RunnableAdapterback to summary
public RunnableAdapter(final Runnable task, final Map<String, String> executionProperties, final ManagedTaskListener taskListener)

Method Detail

runback to summary
public void run()

Implements java.lang.Runnable.run.

Doc from java.lang.Runnable.run.

Runs this operation.

Annotations
@Override