|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectfc.web.servlet.WebApp
public class WebApp
Application level global object running within a servlet web application (i.e., a servlet context). Global webapp data can be stored/retrieved via the put/get methods.
Initializes and stores various variables useful for all servlets/pages
running in our JVM. Implements ServletContextListener
and initializes itself when informed by the servlet container's context initialization event.
It's optional to use this class. If it is used, it's configured by adding the following to the appropriate sections of WEB-INF/web.xml:
<context-param>
<param-name>configfile</param-name>
<param-value>app.conf</param-value>
</context-param>
<listener>
<listener-class>fc.web.servlet.WebApp</listener-class>
</listener>
Important: If this class is used and its initialization is not successful, it tries to shut down the servlet JVM by calling System.exit. (The idea being it's better to fail early and safely then continue beyond this point).
If used, this class requires the following context configuration parameter:
- configfile: Path/name of the application configuration file. If the path starts with a '/', it is an absolute file system path. Otherwise, it is relative to this context root's WEB-INF directory.
This class can also be subclassed to initialize/contain website specific data and background/helper processing threads. Alternatively, along with this class as-is, additional independent site-specific ServletContextListener classes can be created and used as necessary.
| Field Summary | |
|---|---|
static Map |
allServletsMap
A (initially empty) Map that servlets can use to store a reference to themselves. |
static SystemLog |
appLog
A SystemLog object. |
static Map |
appMap
|
static Map |
connectionManagers
|
static long |
default_dbcache_time
|
static ThreadLocalCalendar |
default_tlcal
|
static ThreadLocalDateFormat |
default_tldf
|
static ThreadLocalNumberFormat |
default_tlnf
|
static ThreadLocalRandom |
default_tlrand
|
static ConnectionMgr |
defaultConnectionManager
|
static PropertyMgr |
propertyMgr
|
static Map |
tlcalMap
|
static Map |
tldfMap
|
static Map |
tlnfMap
|
static Map |
tlrandMap
|
| Constructor Summary | |
|---|---|
WebApp()
|
|
| Method Summary | |
|---|---|
void |
contextDestroyed(javax.servlet.ServletContextEvent sce)
Basic implementation of the web application cleanup upon context destruction. |
void |
contextInitialized(javax.servlet.ServletContextEvent sce)
Basic implementation of the web application cleanup upon context creation. |
static Object |
get(Object key)
Returns the specified object from the global application map or null if the object was not found. |
static SystemLog |
getAppLog()
|
static Connection |
getConnection()
|
static Connection |
getConnection(String databasename)
|
static ConnectionMgr |
getConnectionMgr()
Returns the connection manager corresponding to the default database name. |
static ConnectionMgr |
getConnectionMgr(String databasename)
Returns the connection manager corresponding to the database name. |
static Cache |
getDBCache()
Convenience method to get the pre-created application cache. |
static Form |
getForm(String name)
Convenience method to return a form stored previously via the putForm method. |
static ThreadLocalCalendar |
getThreadLocalCalendar()
Returns the default ThreadLocalCalendar object (a new ThreadLocalCalendar is created if it does not exist). |
static ThreadLocalCalendar |
getThreadLocalCalendar(String name)
Returns the ThreadLocalCalendar object corresponding to the specified name (a new ThreadLocalCalendar is created if it does not exist). |
static ThreadLocalDateFormat |
getThreadLocalDateFormat()
Returns the default threadLocalDateFormat object (a new ThreadLocalDateFormat is created if it does not exist). |
static ThreadLocalDateFormat |
getThreadLocalDateFormat(String name)
Returns the ThreadLocalDateFormat object corresponding to the specified name (a new ThreadLocalDateFormat is created if it does not exist). |
static ThreadLocalNumberFormat |
getThreadLocalNumberFormat()
Returns the default ThreadLocalNumberFormat object (a new ThreadLocalNumberFormat is created if it does not exist). |
static ThreadLocalNumberFormat |
getThreadLocalNumberFormat(String name)
Returns the ThreadLocalNumberFormat object corresponding to the specified name (a new ThreadLocalNumberFormat is created if it does not exist). |
static ThreadLocalRandom |
getThreadLocalRandom()
Returns the default ThreadLocalRandom object (a new ThreadLocalRandom is created if it does not exist). |
static ThreadLocalRandom |
getThreadLocalRandom(String name)
Returns the ThreadLocalRandom object corresponding to the specified name (a new ThreadLocalRandom is created if it does not exist). |
static void |
put(Object key,
Object val)
Puts the specified key/object into the global application map. |
static void |
putForm(Form f)
|
static void |
removeForm(String name)
|
String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static Map connectionManagers
public static ConnectionMgr defaultConnectionManager
public static long default_dbcache_time
public static ThreadLocalCalendar default_tlcal
public static ThreadLocalDateFormat default_tldf
public static ThreadLocalNumberFormat default_tlnf
public static ThreadLocalRandom default_tlrand
public static Map appMap
public static Map tlcalMap
public static Map tldfMap
public static Map tlnfMap
public static Map tlrandMap
public static SystemLog appLog
SystemLog object. Servlets typically create their own
loggers (with servlet specific logging levels) but can alternatively
use this default appLog. This appLog is used by non-servlet classes
such as this class itself, various listeners etc.
public static PropertyMgr propertyMgr
public static Map allServletsMap
| Constructor Detail |
|---|
public WebApp()
| Method Detail |
|---|
public void contextInitialized(javax.servlet.ServletContextEvent sce)
contextInitialized in interface javax.servlet.ServletContextListenerpublic void contextDestroyed(javax.servlet.ServletContextEvent sce)
contextDestroyed in interface javax.servlet.ServletContextListenerpublic static ConnectionMgr getConnectionMgr(String databasename)
IllegalArgumentException - if the specified database is not foundpublic static ConnectionMgr getConnectionMgr()
public static Connection getConnection(String databasename)
throws SQLException
SQLException
public static Connection getConnection()
throws SQLException
SQLExceptionpublic static SystemLog getAppLog()
public static Form getForm(String name)
putForm method. Returns null if no form with the specified name
was found.
public static void putForm(Form f)
public static void removeForm(String name)
public static Cache getDBCache()
public static ThreadLocalDateFormat getThreadLocalDateFormat(String name)
public static ThreadLocalDateFormat getThreadLocalDateFormat()
public static ThreadLocalNumberFormat getThreadLocalNumberFormat(String name)
public static ThreadLocalNumberFormat getThreadLocalNumberFormat()
public static ThreadLocalCalendar getThreadLocalCalendar(String name)
public static ThreadLocalCalendar getThreadLocalCalendar()
public static ThreadLocalRandom getThreadLocalRandom(String name)
public static ThreadLocalRandom getThreadLocalRandom()
public static Object get(Object key)
public static void put(Object key,
Object val)
public String toString()
toString in class Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||