Subversion Repositories XServices

Compare Revisions

Ignore whitespace Rev 102 → Rev 188

/xservices/trunk/src/java/net/brutex/xservices/util/cache/CacheExecutorService.java
28,33 → 28,28
*
*/
 
public class CacheExecutorService implements ServletContextListener {
static final String EXECUTOR_NAME = "CACHE_EXECUTOR";
private ExecutorService executor;
 
public void contextInitialized(ServletContextEvent arg0) {
ServletContext context = arg0.getServletContext();
int nr_executors = 5;
ThreadFactory daemonFactory = new DaemonThreadFactory();
try {
nr_executors = Integer.parseInt(context.getInitParameter("cache:thread-count"));
} catch (NumberFormatException localNumberFormatException) {
}
if (nr_executors <= 1)
this.executor = Executors.newSingleThreadExecutor(daemonFactory);
else {
this.executor = Executors.newFixedThreadPool(nr_executors, daemonFactory);
}
context.setAttribute("CACHE_EXECUTOR", this.executor);
}
 
public class CacheExecutorService
implements ServletContextListener
{
static final String EXECUTOR_NAME = "CACHE_EXECUTOR";
private ExecutorService executor;
 
public void contextInitialized(ServletContextEvent arg0)
{
ServletContext context = arg0.getServletContext();
int nr_executors = 5;
ThreadFactory daemonFactory = new DaemonThreadFactory();
try {
nr_executors = Integer.parseInt(context.getInitParameter("cache:thread-count"));
} catch (NumberFormatException localNumberFormatException) {
}
if (nr_executors <= 1)
this.executor = Executors.newSingleThreadExecutor(daemonFactory);
else {
this.executor = Executors.newFixedThreadPool(nr_executors, daemonFactory);
}
context.setAttribute("CACHE_EXECUTOR", this.executor);
}
 
public void contextDestroyed(ServletContextEvent arg0) {
ServletContext context = arg0.getServletContext();
this.executor.shutdownNow();
}
public void contextDestroyed(ServletContextEvent arg0) {
ServletContext context = arg0.getServletContext();
this.executor.shutdownNow();
}
}