org.directwebremoting.impl
Class AutoShutdownScheduledThreadPoolExecutor

java.lang.Object
  extended by java.util.concurrent.AbstractExecutorService
      extended by java.util.concurrent.ThreadPoolExecutor
          extended by java.util.concurrent.ScheduledThreadPoolExecutor
              extended by org.directwebremoting.impl.AutoShutdownScheduledThreadPoolExecutor
All Implemented Interfaces:
java.util.concurrent.Executor, java.util.concurrent.ExecutorService, java.util.concurrent.ScheduledExecutorService, UninitializingBean

public class AutoShutdownScheduledThreadPoolExecutor
extends java.util.concurrent.ScheduledThreadPoolExecutor
implements UninitializingBean

Just a standard ScheduledThreadPoolExecutor with a single default thread in the pool (we're not doing heavy scheduling) that is also a ServletContextListener so the Container can shut us down.

Author:
Joe Walker [joe at getahead dot ltd dot uk]

Nested Class Summary
 
Nested classes/interfaces inherited from class java.util.concurrent.ThreadPoolExecutor
java.util.concurrent.ThreadPoolExecutor.AbortPolicy, java.util.concurrent.ThreadPoolExecutor.CallerRunsPolicy, java.util.concurrent.ThreadPoolExecutor.DiscardOldestPolicy, java.util.concurrent.ThreadPoolExecutor.DiscardPolicy
 
Constructor Summary
AutoShutdownScheduledThreadPoolExecutor()
          This is generally used as an event timer, so we don't need more than one thread running at a time.
 
Method Summary
 void contextDestroyed()
          Called when a ServletContext is being destroyed.
 void servletDestroyed()
          Called when GenericServlet.destroy() is called.
 
Methods inherited from class java.util.concurrent.ScheduledThreadPoolExecutor
execute, getContinueExistingPeriodicTasksAfterShutdownPolicy, getExecuteExistingDelayedTasksAfterShutdownPolicy, getQueue, remove, schedule, schedule, scheduleAtFixedRate, scheduleWithFixedDelay, setContinueExistingPeriodicTasksAfterShutdownPolicy, setExecuteExistingDelayedTasksAfterShutdownPolicy, shutdown, shutdownNow, submit, submit, submit
 
Methods inherited from class java.util.concurrent.ThreadPoolExecutor
allowCoreThreadTimeOut, allowsCoreThreadTimeOut, awaitTermination, getActiveCount, getCompletedTaskCount, getCorePoolSize, getKeepAliveTime, getLargestPoolSize, getMaximumPoolSize, getPoolSize, getRejectedExecutionHandler, getTaskCount, getThreadFactory, isShutdown, isTerminated, isTerminating, prestartAllCoreThreads, prestartCoreThread, purge, setCorePoolSize, setKeepAliveTime, setMaximumPoolSize, setRejectedExecutionHandler, setThreadFactory
 
Methods inherited from class java.util.concurrent.AbstractExecutorService
invokeAll, invokeAll, invokeAny, invokeAny
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.concurrent.ExecutorService
awaitTermination, invokeAll, invokeAll, invokeAny, invokeAny, isShutdown, isTerminated
 

Constructor Detail

AutoShutdownScheduledThreadPoolExecutor

public AutoShutdownScheduledThreadPoolExecutor()
This is generally used as an event timer, so we don't need more than one thread running at a time.

Method Detail

contextDestroyed

public void contextDestroyed()
Description copied from interface: UninitializingBean
Called when a ServletContext is being destroyed. DWR finds out about this destruction if (and only if) in web.xml there is a DwrListener registered. This happens before the GenericServlet.destroy() is called.

If DwrListener is not registered, this will not happen

This method should only be used when we need to take action to enable the servlet to stop cleanly. Typically this will be restricted to stopping reverse ajax threads.

Specified by:
contextDestroyed in interface UninitializingBean

servletDestroyed

public void servletDestroyed()
Description copied from interface: UninitializingBean
Called when GenericServlet.destroy() is called. This event is the preferred time to close resources that don't require all connections to be closed. The servletDestroy method is far more likely to be called.

Specified by:
servletDestroyed in interface UninitializingBean

Copyright 2008