Java EE 7 SDK |
This sample demonstrates how to use javax.enterprise.concurrent.ManagedExecutorService
for submitting tasks.
The demo contains a collection of servlets that show how to use methods from the ManagedExecutorService
interface to submit tasks to be processed asynchronously.
All the sample servlets in this demo use the
default ManagedExecutorService
as defined in the Concurrency Utilities for Java EE 1.0 specification which is
available in all compliant Java EE Products. Thus no special configuration is required.
The following is a list of servlets included in this demo:
URI pattern | Description |
---|---|
/TestResourceServlet | Submit tasks using a ManagedExecutorService retrieved using @Resource
in a servlet, using the execute() and submit() methods. |
/TestJNDIServlet | Submit tasks using a ManagedExecutorService retrieved using JNDI
lookup in a servlet, using the execute() and submit() methods. |
/TestEJBServlet | Submit tasks using a ManagedExecutorService in an EJB session bean,
using the sumbit() method. |
/TestInvokeAllServlet | Submit a collection of tasks using the invokeAll() method in
ManagedExecutorService , and wait for all tasks to complete. |
/TestInvokeAnyServlet | Submit a collection of tasks using the invokeAny() method in
ManagedExecutorService , and wait for the first task to complete. |
/TestListenerServlet | Submit a ManagedTask with a ManagedTaskListener to
receive task lifecycle callbacks. |
/TestTransactionServlet | Submit tasks that make use of javax.transaction.UserTransaction . |
The application is built and deployed as a WAR file.
ManagedExecutorService
from servlets and EJBssubmit()
, execute()
, invokeAll()
,
invokeAny()
methods in ManagedExecutorService
ManagedTaskListener
to receive task lifecycle notificationsjavax.transaction.UserTransaction
from a taskPerform the following steps to build, deploy, and run the application:
samples_install_dir
is the sample application base directory. Go to: samples_install_dir/javaee7/concurrency/executor
.
run
outcome.
mvn clean verify cargo:run
http://localhost:8080/executor
clean
outcome to undeploy the sample application and to remove the temporary directories such as
build
and dist
.
mvn clean
If you have problems when running the application, refer to the troubleshooting document.
Copyright © 1997-2013 Oracle and/or its affiliates. All rights reserved.