com.ora.jsp.beans.counter
Class CounterBean

java.lang.Object
  |
  +--com.ora.jsp.beans.counter.CounterBean
All Implemented Interfaces:
java.io.Serializable

public class CounterBean
extends java.lang.Object
implements java.io.Serializable

This class maintains page counters. Note that this class is intended to be used in session and application scope so regular setter and getter methods for pageContext can not be used; all info needed to get and increment the counter value must be provided as parameters to the corresponding method to avoid multi-threading issues.

Version:
1.0.1
Author:
Hans Bergsten, Gefion software
See Also:
Serialized Form

Field Summary
private  java.util.Hashtable counters
           
 
Constructor Summary
CounterBean()
           
 
Method Summary
 int getCurrentValue(java.lang.String uri)
          Returns the current value of the counter for this page.
 int getNextValue(java.lang.String uri)
          Increments the counter for this page and returns the new value.
 void incrementValue(java.lang.String uri)
          Increments the counter for this page.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

counters

private java.util.Hashtable counters
Constructor Detail

CounterBean

public CounterBean()
Method Detail

getCurrentValue

public int getCurrentValue(java.lang.String uri)
Returns the current value of the counter for this page.
Parameters:
uri - the URI for the page, as provided by HttpServletRequest.getRequestURI()
Returns:
the current counter value, or -1 if it's not found

getNextValue

public int getNextValue(java.lang.String uri)
Increments the counter for this page and returns the new value.
Parameters:
uri - the URI for the page, as provided by HttpServletRequest.getRequestURI()
Returns:
the current counter value incremented by one

incrementValue

public void incrementValue(java.lang.String uri)
Increments the counter for this page. If the permanent is true, the new value is also saved in a file.
Parameters:
uri - the URI for the page, as provided by HttpServletRequest.getRequestURI()