com.arsdigita.acs
Class Parameters

java.lang.Object
  |
  +--javax.servlet.GenericServlet
        |
        +--javax.servlet.http.HttpServlet
              |
              +--com.arsdigita.acs.Parameters
All Implemented Interfaces:
Serializable, Servlet, ServletConfig

public class Parameters
extends HttpServlet

Class to handle ACS parameters, loaded on server startup. Parameters are stored and accessed via static methods

EXPECTS: IniFileName servlet init parameter: points to an .xml file with ACS parameters

We chose to make the ACS parameters a separate XML file, rather than putting them in web.xml, because it allows us to make a more convenient syntax for having parameters with multiple (i.e., lists of) values. It also maintains some separation between things that are web-server specific, and the things that are specific to ACS and server-independent.

See Also:
Serialized Form

Constructor Summary
Parameters()
           
 
Method Summary
static String get(String param, String module)
          Gets a parameter as a String.
static String get(String param, String module, String def)
          Gets a parameter as a String.
static boolean getBoolean(String param, String module)
          Gets a parameter as a boolean primitive
static boolean getBoolean(String param, String module, boolean def)
          Gets a parameter as a boolean primitive
static Enumeration getInitClasses()
          Returns an enumeration of classes that need to be loaded at server start-up to invoke static initializers.
static int getInt(String param, String module)
          Gets a parameter as a boolean primitive
static int getInt(String param, String module, int def)
          Gets a parameter as an int primitive
static Object getObject(String param, String module)
          Gets a parameter as an Object.
static Object getObject(String param, String module, Object def)
          Gets a parameter as an Object.
static Vector getVector(String param, String module)
          Gets a list of parameter values as a Vector.
 void init()
          Calls readParameters at start-up.
 
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doGet, doOptions, doPost, doPut, doTrace, getLastModified, service, service
 
Methods inherited from class javax.servlet.GenericServlet
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Parameters

public Parameters()
Method Detail

getObject

public static Object getObject(String param,
                               String module,
                               Object def)
Gets a parameter as an Object.
Parameters:
param - The parameter
module - The module name (may be empty or null)
def - Default if not found
Returns:
The value of the parameter, or def if not found

getObject

public static Object getObject(String param,
                               String module)
Gets a parameter as an Object.
Parameters:
param - The parameter
module - The module name (may be empty or null)
Returns:
The value of the parameter, or null

get

public static String get(String param,
                         String module,
                         String def)
Gets a parameter as a String.
Parameters:
param - The parameter
module - The module name (may be empty or null)
def - Default value
Returns:
The value of the parameter, or def if not found

get

public static String get(String param,
                         String module)
Gets a parameter as a String.
Parameters:
param - The parameter
module - The module name (may be empty or null)
Returns:
The value of the parameter, or empty string (not null) if not found.

getVector

public static Vector getVector(String param,
                               String module)
Gets a list of parameter values as a Vector.
Parameters:
param - The parameter name
Returns:
The list of parameter values, or null if not found.

getBoolean

public static boolean getBoolean(String param,
                                 String module,
                                 boolean def)
Gets a parameter as a boolean primitive
Parameters:
param - The parameter
module - The module name (may be empty or null)
def - Default value
Returns:
The value of the parameter, or def if not found.

getBoolean

public static boolean getBoolean(String param,
                                 String module)
Gets a parameter as a boolean primitive
Parameters:
param - The parameter
module - The module name (may be empty or null)
Returns:
The value of the parameter, or false if not found.

getInt

public static int getInt(String param,
                         String module,
                         int def)
Gets a parameter as an int primitive
Parameters:
param - The parameter
module - The module name (may be empty or null)
def - Default value
Returns:
The value of the parameter, or def if not found.

getInt

public static int getInt(String param,
                         String module)
Gets a parameter as a boolean primitive
Parameters:
param - The parameter
module - The module name (may be empty or null)
Returns:
The value of the parameter, or 0 if not found.

init

public void init()
          throws ServletException
Calls readParameters at start-up.
Overrides:
init in class GenericServlet
Following copied from class: javax.servlet.GenericServlet
Throws:
ServletException - if an exception occurs that interrupts the servlet's normal operation

getInitClasses

public static final Enumeration getInitClasses()
Returns an enumeration of classes that need to be loaded at server start-up to invoke static initializers.