org.directwebremoting.impl
Class AbstractServerLoadMonitor

java.lang.Object
  extended by org.directwebremoting.impl.AbstractServerLoadMonitor
All Implemented Interfaces:
ServerLoadMonitor, UninitializingBean
Direct Known Subclasses:
DefaultServerLoadMonitor, PollingServerLoadMonitor, SmallSiteServerLoadMonitor, ThreadDroppingServerLoadMonitor

public abstract class AbstractServerLoadMonitor
extends java.lang.Object
implements ServerLoadMonitor, UninitializingBean

A base implementation of ServerLoadMonitor that implements waiting functionality, mostly to provide ServletContextListener.contextDestroyed(javax.servlet.ServletContextEvent)

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

Constructor Summary
AbstractServerLoadMonitor()
           
 
Method Summary
 void contextDestroyed()
          Called when a ServletContext is being destroyed.
 void servletDestroyed()
          Called when GenericServlet.destroy() is called.
 void shutdownRandomWaitControllers(int count)
          If there are too many WaitControllers waiting then we can kill one off at random.
 void threadWaitEnding(WaitController controller)
          A thread has just ended a wait period.
 void threadWaitStarting(WaitController controller)
          A thread is about to begin a wait period.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.directwebremoting.extend.ServerLoadMonitor
getConnectedTime, getDisconnectedTime, supportsStreaming
 

Constructor Detail

AbstractServerLoadMonitor

public AbstractServerLoadMonitor()
Method Detail

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

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

threadWaitStarting

public void threadWaitStarting(WaitController controller)
Description copied from interface: ServerLoadMonitor
A thread is about to begin a wait period. This can be used by implementations to dynamically adjust the poll timings.

Specified by:
threadWaitStarting in interface ServerLoadMonitor
Parameters:
controller - An object that we can use to control the wait

threadWaitEnding

public void threadWaitEnding(WaitController controller)
Description copied from interface: ServerLoadMonitor
A thread has just ended a wait period. This can be used by implementations to dynamically adjust the poll timings.

Specified by:
threadWaitEnding in interface ServerLoadMonitor
Parameters:
controller - An object that we can use to control the wait

shutdownRandomWaitControllers

public void shutdownRandomWaitControllers(int count)
If there are too many WaitControllers waiting then we can kill one off at random.

Parameters:
count - How many WaitControllers do we shutdown?

Copyright 2008