-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathScheduledEmployeeAlerter.java
More file actions
36 lines (25 loc) · 1004 Bytes
/
ScheduledEmployeeAlerter.java
File metadata and controls
36 lines (25 loc) · 1004 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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
*/
@Named
public class ScheduledEmployeeAlerter {
Future alertHandle = null;
@Resource(name="concurrent/__defaultManagedScheduledExecutorService")
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);
}
}