Top Description Inners Fields Constructors Methods
javax.enterprise.concurrent

public Class ManagedExecutors

extends Object
Class Inheritance
Imports
java.util.HashMap, .Locale, .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

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
(Runnable
the task to have the given ManagedTaskListener associated with
task
,
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
(Runnable
the task to have the given ManagedTaskListener associated with
task
,
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
,
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 <V> Callable<V>

Returns:

a Callable object
managedTask
(Callable<V>
the task to have the given ManagedTaskListener associated with
task
,
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 <V> Callable<V>

Returns:

a Callable object
managedTask
(Callable<V>
the task to have the given ManagedTaskListener associated with
task
,
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
,
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

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(Runnable task, 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(Runnable task, Map<String, String> executionProperties, 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(Callable<V> task, 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
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(Callable<V> task, Map<String, String> executionProperties, 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
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
javax.enterprise.concurrent back to summary

pack-priv Class ManagedExecutors.Adapter

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

Field Summary

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

Constructor Summary

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

Method Summary

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

Implements javax.enterprise.concurrent.ManagedTask.getManagedTaskListener.

The ManagedTaskListener to receive notification of lifecycle events of this task.
private Map<String, String>
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

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

Constructor Detail

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

Method Detail

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

Implements javax.enterprise.concurrent.ManagedTask.getExecutionProperties.

Doc from javax.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 "javax.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 javax.enterprise.concurrent.ManagedTask.getManagedTaskListener.

Doc from javax.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(Map<String, String> base, Map<String, String> override)
javax.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
pack-priv final Callable<V>
Inherited from javax.enterprise.concurrent.ManagedExecutors.Adapter:
executionPropertiesmanagedTasktaskListener

Constructor Summary

AccessConstructor and Description
public
CallableAdapter(Callable<V> task, Map<String, String> executionProperties, 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 javax.enterprise.concurrent.ManagedExecutors.Adapter:
getExecutionPropertiesgetManagedTaskListener

Field Detail

taskback to summary
pack-priv final Callable<V> task

Constructor Detail

CallableAdapterback to summary
public CallableAdapter(Callable<V> task, Map<String, String> executionProperties, 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
javax.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
pack-priv final Runnable
Inherited from javax.enterprise.concurrent.ManagedExecutors.Adapter:
executionPropertiesmanagedTasktaskListener

Constructor Summary

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

Method Summary

Modifier and TypeMethod and Description
public void
run()

Implements java.lang.Runnable.run.

Runs this operation.
Inherited from javax.enterprise.concurrent.ManagedExecutors.Adapter:
getExecutionPropertiesgetManagedTaskListener

Field Detail

taskback to summary
pack-priv final Runnable task

Constructor Detail

RunnableAdapterback to summary
public RunnableAdapter(Runnable task, Map<String, String> executionProperties, 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