org.locomotive.loco.servlet
Class ServletFactoryEvent

java.lang.Object
  |
  +--java.util.EventObject
        |
        +--org.locomotive.loco.servlet.ServletFactoryEvent

public class ServletFactoryEvent
extends java.util.EventObject

Instances of this class are used by ServletFactory Threads to make Servlet instances available to ServletEntry and to ServletPool. The Servlets have been instantiated and properly initialized by the ServletFactory, and they are ready to be used to handle requests.

Author:
Jason Brittain
See Also:
Serialized Form

Field Summary
protected  int availability
          The availability status of the servlets.
protected  long event_timestamp
          The date/timestamp of when this event occurred.
protected  javax.servlet.Servlet servlet
          A reference to a servlet that the ServletFactory is passing to the listener(s)..
protected  java.lang.Class servlet_class
          The Class of servlets that the ServletFactory creates.
protected  java.lang.String unavailability_reason
          The reason for the unavailability.
protected  int unavailable_seconds
          The number of seconds that this kind of servlets are unavailable for.
 
Fields inherited from class java.util.EventObject
source
 
Constructor Summary
ServletFactoryEvent(java.lang.Object source, java.lang.Class servlet_class, int availability, int unavailable_seconds, java.lang.String unavailability_reason)
          Constructs a ServletFactoryEvent for specifying that servlets of the specified class are unavailable.
ServletFactoryEvent(java.lang.Object source, javax.servlet.Servlet servlet)
          Constructs a ServletFactoryEvent with a Servlet that is ready to serve requests.
 
Method Summary
 int getAvailability()
          Returns the availability status for the class of servlets that are made by the ServletFactory that created this ServletFactoryEvent.
 long getEventTimestamp()
          Gets the timestamp for when this event occurred, according to the object that created this ServletFactoryEvent.
 javax.servlet.Servlet getServlet()
          If this method returns null, then this ServletFactoryEvent was sent by the ServletFactory to tell the listeners that the servlets that it creates are currently unavailable.
 java.lang.Class getServletClass()
          Returns the class of servlets that this ServletFactoryEvent affects.
 java.lang.String getUnavailabilityReason()
          Get the reason for the unavailability.
 int getUnavailableSeconds()
          Gets the number of seconds that this ServletFactoryEvent's ServletFactory will wait (or is currently waiting) before trying to make more servlets.
 
Methods inherited from class java.util.EventObject
getSource, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

servlet

protected javax.servlet.Servlet servlet
A reference to a servlet that the ServletFactory is passing to the listener(s).. it is supposed to be ready to serve requests.

servlet_class

protected java.lang.Class servlet_class
The Class of servlets that the ServletFactory creates. FIXME: This will have to change soon to handle more than one differently-configured servlet of the same class in the same container.

availability

protected int availability
The availability status of the servlets.

unavailable_seconds

protected int unavailable_seconds
The number of seconds that this kind of servlets are unavailable for.

unavailability_reason

protected java.lang.String unavailability_reason
The reason for the unavailability.

event_timestamp

protected long event_timestamp
The date/timestamp of when this event occurred. It is stored as the number of milliseconds elapsed between Jan 1, 1970 00:00:00 GMT and the actual time this event occurred.
Constructor Detail

ServletFactoryEvent

public ServletFactoryEvent(java.lang.Object source,
                           javax.servlet.Servlet servlet)
Constructs a ServletFactoryEvent with a Servlet that is ready to serve requests.
Parameters:
Object - source the Object that created this event, probably a ServletFactory.
servlet - a Servlet instance that has been initialized and is ready to serve requests.

ServletFactoryEvent

public ServletFactoryEvent(java.lang.Object source,
                           java.lang.Class servlet_class,
                           int availability,
                           int unavailable_seconds,
                           java.lang.String unavailability_reason)
Constructs a ServletFactoryEvent for specifying that servlets of the specified class are unavailable.
Parameters:
Object - source the Object that created this event, probably a ServletFactory.
servlet_class - the class of servlets that are currently unavailable.
availability - the current availability status for the class of servlets that this ServletFactoryEvent's ServletFactory makes. Note that this value reflects the availability status of the servlets as of the time that this event was created, and that the value could be different by the time the listener acts on it.
unavailable_seconds - the number of seconds that this ServletFactoryEvent's ServletFactory is saying that its servlets are unavailable for.
unavailability_reason - the reason for the unavailability.
Method Detail

getServlet

public javax.servlet.Servlet getServlet()
If this method returns null, then this ServletFactoryEvent was sent by the ServletFactory to tell the listeners that the servlets that it creates are currently unavailable.

getServletClass

public java.lang.Class getServletClass()
Returns the class of servlets that this ServletFactoryEvent affects.

getAvailability

public int getAvailability()
Returns the availability status for the class of servlets that are made by the ServletFactory that created this ServletFactoryEvent. This value should be one of the following: ServletFactory.AVAILABLE, ServletFactory.UNAVAILABLE_AND_WAITING, ServletFactory.PERMANENTLY_UNAVAILABLE.

getUnavailableSeconds

public int getUnavailableSeconds()
Gets the number of seconds that this ServletFactoryEvent's ServletFactory will wait (or is currently waiting) before trying to make more servlets.

getUnavailabilityReason

public java.lang.String getUnavailabilityReason()
Get the reason for the unavailability. In the case where the event is an availability event, this method returns null.

getEventTimestamp

public long getEventTimestamp()
Gets the timestamp for when this event occurred, according to the object that created this ServletFactoryEvent.