Java Reference
In-Depth Information
package org.javaee7.chapter11;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import javax.annotation.Resource;
import javax.enterprise.concurrent.ManagedScheduledExecutorService;
import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;
import javax.inject.Named;
* Managed Bean for scheduling new employee alerts
* @author Juneau
public class ScheduledEmployeeAlerter {
Future alertHandle = null;
ManagedScheduledExecutorService mes;
public void alertScheduler() {
ScheduledEmployeeAlert ae = new ScheduledEmployeeAlert();
alertHandle = mes.scheduleAtFixedRate(
ae, 5L, 5L, TimeUnit.MINUTES);
FacesMessage facesMsg = new FacesMessage(FacesMessage.SEVERITY_INFO, "Task Scheduled",
"Task Scheduled");
FacesContext.getCurrentInstance().addMessage(null, facesMsg);
Thread Instances
Until the release of Java EE 7, multi-threaded enterprise applications were very customized. In fact, until the EE 7
release, there was no formal framework to utilize for spawning threads within an enterprise application. In this latest
release that includes the Concurrency utilities, thread processing has been formalized. To utilize threading within an
enterprise application, one should create ManagedThreadFactory resource(s) within the application server container,
and utilize those resources within application(s), as needed.
Before an application can use the service, it must be created within the application server container. As with
the other concurrent resources, there are a couple of different ways to create the ManagedThreadFactory within the
GlassFish application server. To create a ManagedThreadFactory instance within GlassFish utilizing the command line
utility, issue the following command from the command-line:
asadmin create-managed-thread-factory concurrent/name-of-service
Search WWH ::

Custom Search