javax.enterprise.concurrent

Interface ManagedTaskListener


  • public interface ManagedTaskListener
    A ManagedTaskListener is used to monitor the state of a task's Future. It can be registered with a ManagedExecutorService using the submit methods and will be invoked when the state of the Future changes. Each listener method will run with unspecified context. All listeners run without an explicit transaction (they do not enlist in the application component's transaction). If a transaction is required, use a UserTransaction instance.

    Each listener instance will be invoked within the same process in which the listener was registered. If a single listener is submitted to multiple ManagedExecutorService instances, the listener object may be invoked concurrently by multiple threads.

    Each listener method supports a minimum quality of service of at-most-once. A listener is not guaranteed to be invoked due to a process failure or termination.

    State Transition Diagram

    The following state transition figure and tables describe the possible task lifecycle events that can occur when a ManagedTaskListener is associated with a task. Each method is invoked when the state of the Future moves from one state to another.

    A. The task runs normally:

    SequenceStateActionListenerNext state
    1.Nonesubmit()taskSubmittedSubmitted
    2.SubmittedAbout to call run()taskStartingStarted
    3.StartedExit run()taskDoneDone

    Erste Seite von API Java Inhaltsverzeichnis Haut

    B. The task is cancelled during taskSubmitted():

    SequenceStateActionListenerNext state
    1.Nonesubmit()taskSubmitted
    Future is cancelled.
    Cancelling
    2.Cancelling taskAbortedCancelled
    3.Cancelled taskDoneDone

    Erste Seite von API Java Inhaltsverzeichnis Haut

    C. The task is cancelled or aborted after submitted, but before started:

    SequenceStateActionListenerNext state
    1.Nonesubmit()taskSubmittedSubmitted
    2.Submittedcancel() or aborttaskAbortedCancelled
    3.Cancelled taskDoneDone

    Erste Seite von API Java Inhaltsverzeichnis Haut

    D. The task is cancelled when it is starting:

    SequenceStateActionListenerNext state
    1.Nonesubmit()taskSubmittedSubmitted
    2.SubmittedAbout to call run()taskStarting
    Future is cancelled.
    Cancelling
    3.Cancelling taskAbortedCancelled
    4.Cancelled taskDoneDone

    Erste Seite von API Java Inhaltsverzeichnis Haut

    Since:
    1.0
    • Method Detail

      • taskSubmitted

        void taskSubmitted(Future<?> future,
                           ManagedExecutorService executor,
                           Object task)
        Called after the task has been submitted to the Executor. The task will not enter the starting state until the taskSubmitted listener has completed. This method may be called from the same thread that the task was submitted with.

        This event does not indicate that the task has been scheduled for execution.

        Parameters:
        future - the Future instance that was created when the task was submitted.
        executor - the executor used to run the associated Future.
        task - the task that was submitted.
      • taskAborted

        void taskAborted(Future<?> future,
                         ManagedExecutorService executor,
                         Object task,
                         Throwable exception)
        Called when a task's Future has been cancelled anytime during the life of a task. This method may be called after taskDone(). The Future.isCancelled() method returns false if the task was aborted through another means other than Future.cancel(boolean). The exception argument will represent the cause of the cancellation: The AbortedException.getCause() method will return the exception that caused the task to fail to start.
        Parameters:
        future - the Future instance that was created when the task was submitted.
        executor - the executor used to run the associated Future.
        task - the task that was submitted.
        exception - the cause of the task abort.
      • taskDone

        void taskDone(Future<?> future,
                      ManagedExecutorService executor,
                      Object task,
                      Throwable exception)
        Called when a submitted task has completed running, either successfully or failed due to any exception thrown from the task, task being cancelled, rejected, or aborted.
        Parameters:
        future - the Future instance that was created when the task was submitted.
        executor - the executor used to run the associated Future.
        task - the task that was submitted.
        exception - if not null, the exception that caused the task to fail.
      • taskStarting

        void taskStarting(Future<?> future,
                          ManagedExecutorService executor,
                          Object task)
        This method is called before the task is about to start. The task will not enter the starting state until the taskSubmitted listener has completed. This method may be called from the same thread that the task was submitted with.
        Parameters:
        future - the Future instance that was created when the task was submitted.
        executor - the executor used to run the associated Future.
        task - the task that was submitted.

Deutsche Übersetzung

Sie haben gebeten, diese Seite auf Deutsch zu besuchen. Momentan ist nur die Oberfläche übersetzt, aber noch nicht der gesamte Inhalt.

Wenn Sie mir bei Übersetzungen helfen wollen, ist Ihr Beitrag willkommen. Alles, was Sie tun müssen, ist, sich auf der Website zu registrieren und mir eine Nachricht zu schicken, in der Sie gebeten werden, Sie der Gruppe der Übersetzer hinzuzufügen, die Ihnen die Möglichkeit gibt, die gewünschten Seiten zu übersetzen. Ein Link am Ende jeder übersetzten Seite zeigt an, dass Sie der Übersetzer sind und einen Link zu Ihrem Profil haben.

Vielen Dank im Voraus.

Dokument erstellt 11/06/2005, zuletzt geändert 18/08/2025
Quelle des gedruckten Dokuments:https://www.gaudry.be/de/java-api-javaee-rf-javax/enterprise/concurrent/managedtasklistener.html

Die Infobro ist eine persönliche Seite, deren Inhalt in meiner alleinigen Verantwortung liegt. Der Text ist unter der CreativeCommons-Lizenz (BY-NC-SA) verfügbar. Weitere Informationen auf die Nutzungsbedingungen und dem Autor.

Referenzen

  1. Zeigen Sie - html-Dokument Sprache des Dokuments:fr Manuel PHP : https://docs.oracle.com

Diese Verweise und Links verweisen auf Dokumente, die während des Schreibens dieser Seite konsultiert wurden, oder die zusätzliche Informationen liefern können, aber die Autoren dieser Quellen können nicht für den Inhalt dieser Seite verantwortlich gemacht werden.
Der Autor dieser Website ist allein dafür verantwortlich, wie die verschiedenen Konzepte und Freiheiten, die mit den Nachschlagewerken gemacht werden, hier dargestellt werden. Denken Sie daran, dass Sie mehrere Quellinformationen austauschen müssen, um das Risiko von Fehlern zu reduzieren.