Interface Work

  • All Superinterfaces:

    Interfaces for work and work management are replaced by ManagedExecutorService and related interfaces.

    public interface Work
    extends java.lang.Runnable
    This is implemented by applications when they want to run code blocks asynchronously. If an application supplied Work implements, this tells the application server that the application will not interact with the Work directly while it is running. The application server reserves the right to dispatch serializable units of work to other JVMs. The application server currently chooses not to dispatch to remote JVMs but might decide to dispatch to remote JVMs in future releases. If the Work does not implement Serializable then it is guaranteed to execute in the same JVM as the thread invoking WorkManager.startWork.

    If the server is quiescing then the runtime may call the release method on the Work once it starts executing to tell it to exit. If it doesn't respond to this 'signal' then it may be terminated by the runtime without warning.

    The Work is also registered with its own EventSource once it is started. The WorkItem.getEventTrigger can be used to return a proxy that can be used to fire events to the running Work. This will work whether the Work is executed locally or remotely. However, in the remote case all arguments to the event being fired must be serializable or an IllegalArgumentException is thrown.

    A Work object should implement any necessary event interfaces if this mechanism is to be exploited. The WorkItem.getEventTrigger method can then be used to fire events to those interfaces. If the Work doesn't implement the interface supplied to WorkItem.getEventTrigger then nothing happens and the event is ignored.

    See Also:
    javax.enterprise.concurrent.ManagedExecutorService, WorkManager, WorkItem
    • Method Summary

      Modifier and Type Method and Description
      void release()
      The implementor should return from the method once this is called.
      • Methods inherited from interface java.lang.Runnable

    • Method Detail

      • release

        void release()
        The implementor should return from the method once this is called.

        This method can be called by the runtime when the JVM is shutting down. It should never be called directly by the application. The EventSource mechanism attached to the WorkItem should be used when the application needs to communicate with the Work after it is started. For example:

         WorkItem i = wm.startWork(myWork);
         Work proxy = (Work)i.getEventTrigger(Work.class);
        This is the 'safe' way to call release from an application in all cases. If an application uses the above approach then the run method should never be called on the proxy as this will almost definitely result in the application failing.
IBM WebSphere Application ServerTM
Release 9.0