- java.lang.Object
-
- javax.enterprise.concurrent.ManagedExecutors
-
public class ManagedExecutors extends Object
Utility methods for classes defined in this package.- Since:
- 1.0
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method and Description static boolean
isCurrentThreadShutdown()
Utility method for checking theisShutdown()
value of the current thread if it is aManageableThread
created fromManagedThreadFactory.newThread()
.static <V> Callable<V>
managedTask(Callable<V> task, ManagedTaskListener taskListener)
Returns aCallable
object that also implementsManagedTask
interface so it can receive notification of lifecycle events with the providedManagedTaskListener
when the task is submitted to aManagedExecutorService
or aManagedScheduledExecutorService
.static <V> Callable<V>
managedTask(Callable<V> task, Map<String,String> executionProperties, ManagedTaskListener taskListener)
Returns aCallable
object that also implementsManagedTask
interface so it can receive notification of lifecycle events with the providedManagedTaskListener
and to provide additional execution properties when the task is submitted to aManagedExecutorService
or aManagedScheduledExecutorService
.static Runnable
managedTask(Runnable task, ManagedTaskListener taskListener)
Returns aRunnable
object that also implementsManagedTask
interface so it can receive notification of lifecycle events with the providedManagedTaskListener
when the task is submitted to aManagedExecutorService
or aManagedScheduledExecutorService
.static Runnable
managedTask(Runnable task, Map<String,String> executionProperties, ManagedTaskListener taskListener)
Returns aRunnable
object that also implementsManagedTask
interface so it can receive notification of lifecycle events with the providedManagedTaskListener
and to provide additional execution properties when the task is submitted to aManagedExecutorService
or aManagedScheduledExecutorService
.
-
-
-
Method Detail
-
isCurrentThreadShutdown
public static boolean isCurrentThreadShutdown()
Utility method for checking theisShutdown()
value of the current thread if it is aManageableThread
created fromManagedThreadFactory.newThread()
.- Returns:
- Returns the
isShutdown()
value if the current thread is aManageableThread
created byManagedThreadFactory
, or false if the current thread is not aManageableThread
.
-
managedTask
public static Runnable managedTask(Runnable task, ManagedTaskListener taskListener) throws IllegalArgumentException
Returns aRunnable
object that also implementsManagedTask
interface so it can receive notification of lifecycle events with the providedManagedTaskListener
when the task is submitted to aManagedExecutorService
or aManagedScheduledExecutorService
.Example:
Runnable task = ...; ManagedTaskListener myTaskListener = ...; ManagedExecutorService executor = ...; Runnable taskWithListener = ManagedExecutors.managedTask(task, myTaskListener); executor.submit(taskWithListener);
- Parameters:
task
- the task to have the given ManagedTaskListener associated withtaskListener
- (optional) theManagedTaskListener
to receive lifecycle events notification when the task is submitted. Iftask
implementsManagedTask
, andtaskListener
is notnull
, theManagedTaskListener
interface methods of the task will not be called.- Returns:
- a Runnable object
- Throws:
IllegalArgumentException
- iftask
isnull
-
managedTask
public static Runnable managedTask(Runnable task, Map<String,String> executionProperties, ManagedTaskListener taskListener) throws IllegalArgumentException
Returns aRunnable
object that also implementsManagedTask
interface so it can receive notification of lifecycle events with the providedManagedTaskListener
and to provide additional execution properties when the task is submitted to aManagedExecutorService
or aManagedScheduledExecutorService
.- Parameters:
task
- the task to have the given ManagedTaskListener associated withtaskListener
- (optional) theManagedTaskListener
to receive lifecycle events notification when the task is submitted. Iftask
implementsManagedTask
, andtaskListener
is notnull
, theManagedTaskListener
interface methods of the task will not be called.executionProperties
- (optional) execution properties to provide additional hints toManagedExecutorService
orManagedScheduledExecutorService
when the task is submitted. Iftask
implementsManagedTask
with non-empty execution properties, theRunnable
returned will contain the union of the execution properties specified in thetask
and theexecutionProperties
argument, with the latter taking precedence if the same property key is specified in both. After the method is called, further changes to theMap
object will not be reflected in theRunnable
returned by this method.- Returns:
- a Runnable object
- Throws:
IllegalArgumentException
- iftask
isnull
-
managedTask
public static <V> Callable<V> managedTask(Callable<V> task, ManagedTaskListener taskListener) throws IllegalArgumentException
Returns aCallable
object that also implementsManagedTask
interface so it can receive notification of lifecycle events with the providedManagedTaskListener
when the task is submitted to aManagedExecutorService
or aManagedScheduledExecutorService
.- Parameters:
task
- the task to have the given ManagedTaskListener associated withtaskListener
- (optional) theManagedTaskListener
to receive lifecycle events notification when the task is submitted. Iftask
implementsManagedTask
, andtaskListener
is notnull
, theManagedTaskListener
interface methods of the task will not be called.- Returns:
- a Callable object
- Throws:
IllegalArgumentException
- iftask
isnull
-
managedTask
public static <V> Callable<V> managedTask(Callable<V> task, Map<String,String> executionProperties, ManagedTaskListener taskListener) throws IllegalArgumentException
Returns aCallable
object that also implementsManagedTask
interface so it can receive notification of lifecycle events with the providedManagedTaskListener
and to provide additional execution properties when the task is submitted to aManagedExecutorService
or aManagedScheduledExecutorService
.- Parameters:
task
- the task to have the given ManagedTaskListener associated withtaskListener
- (optional) theManagedTaskListener
to receive lifecycle events notification when the task is submitted. Iftask
implementsManagedTask
, andtaskListener
is notnull
, theManagedTaskListener
interface methods of the task will not be called.executionProperties
- (optional) execution properties to provide additional hints toManagedExecutorService
orManagedScheduledExecutorService
when the task is submitted. Iftask
implementsManagedTask
with non-empty execution properties, theRunnable
returned will contain the union of the execution properties specified in thetask
and theexecutionProperties
argument, with the latter taking precedence if the same property key is specified in both. After the method is called, further changes to theMap
object will not be reflected in theCallable
returned by this method.- Returns:
- a Callable object
- Throws:
IllegalArgumentException
- iftask
isnull
-
-
Nederlandse vertaling
U hebt gevraagd om deze site in het Nederlands te bezoeken. Voor nu wordt alleen de interface vertaald, maar nog niet alle inhoud.Als je me wilt helpen met vertalingen, is je bijdrage welkom. Het enige dat u hoeft te doen, is u op de site registreren en mij een bericht sturen waarin u wordt gevraagd om u toe te voegen aan de groep vertalers, zodat u de gewenste pagina's kunt vertalen. Een link onderaan elke vertaalde pagina geeft aan dat u de vertaler bent en heeft een link naar uw profiel.
Bij voorbaat dank.
Document heeft de 11/06/2005 gemaakt, de laatste keer de 18/08/2025 gewijzigd
Bron van het afgedrukte document:https://www.gaudry.be/nl/java-api-javaee-rf-javax/enterprise/concurrent/ManagedExecutors.html
De infobrol is een persoonlijke site waarvan de inhoud uitsluitend mijn verantwoordelijkheid is. De tekst is beschikbaar onder CreativeCommons-licentie (BY-NC-SA). Meer info op de gebruiksvoorwaarden en de auteur.
Referenties
Deze verwijzingen en links verwijzen naar documenten die geraadpleegd zijn tijdens het schrijven van deze pagina, of die aanvullende informatie kunnen geven, maar de auteurs van deze bronnen kunnen niet verantwoordelijk worden gehouden voor de inhoud van deze pagina.
De auteur van deze site is als enige verantwoordelijk voor de manier waarop de verschillende concepten, en de vrijheden die met de referentiewerken worden genomen, hier worden gepresenteerd. Vergeet niet dat u meerdere broninformatie moet doorgeven om het risico op fouten te verkleinen.