-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLogScheduler.java
More file actions
27 lines (20 loc) · 810 Bytes
/
LogScheduler.java
File metadata and controls
27 lines (20 loc) · 810 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
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;
import org.koushik.javabrains.messenger.resources.LogFactory;
@WebListener
public class LogScheduler implements ServletContextListener {
private ScheduledExecutorService scheduler;
@Override
public void contextInitialized(ServletContextEvent event) {
scheduler = Executors.newSingleThreadScheduledExecutor();
scheduler.scheduleAtFixedRate(new LogFactory(), 0, 100, TimeUnit.MILLISECONDS);
}
@Override
public void contextDestroyed(ServletContextEvent event) {
scheduler.shutdownNow();
}
}