|
||||||||||
| 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 at context initialization.
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>
If 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 java.util.Map |
allServletsMap
A (initially empty) Map that servlets can use to store a reference to themselves. |
static SystemLog |
appLog
A SystemLog object. |
static java.util.Map |
appMap
|
static java.util.Map |
connectionManagers
|
static long |
default_dbcache_time
|
static ThreadLocalCalendar |
default_tlcal
|
static ThreadLocalDateFormat |
default_tldf
|
static ThreadLocalNumberFormat |
default_tlnf
|
static ConnectionMgr |
defaultConnectionManager
|
static PropertyMgr |
propertyMgr
|
static java.util.Map |
tlcalMap
|
static java.util.Map |
tldfMap
|
static java.util.Map |
tlnfMap
|
| 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 java.lang.Object |
get(java.lang.Object key)
Returns the specified object from the global application map or null if the object was not found. |
static SystemLog |
getAppLog()
|
static java.sql.Connection |
getConnection()
|
static java.sql.Connection |
getConnection(java.lang.String databasename)
|
static ConnectionMgr |
getConnectionMgr()
Returns the connection manager corresponding to the default database name. |
static ConnectionMgr |
getConnectionMgr(java.lang.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(java.lang.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(java.lang.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(java.lang.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(java.lang.String name)
Returns the ThreadLocalNumberFormat object corresponding to the specified name (a new ThreadLocalNumberFormat is created if it does not exist). |
static void |
put(java.lang.Object key,
java.lang.Object val)
Puts the specified key/object into the global application map. |
static void |
putForm(Form f)
|
static void |
removeForm(java.lang.String name)
|
java.lang.String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static java.util.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 java.util.Map appMap
public static java.util.Map tlcalMap
public static java.util.Map tldfMap
public static java.util.Map tlnfMap
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 java.util.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(java.lang.String databasename)
java.lang.IllegalArgumentException - if the specified database is not foundpublic static ConnectionMgr getConnectionMgr()
public static java.sql.Connection getConnection(java.lang.String databasename)
throws java.sql.SQLException
java.sql.SQLException
public static java.sql.Connection getConnection()
throws java.sql.SQLException
java.sql.SQLExceptionpublic static SystemLog getAppLog()
public static Form getForm(java.lang.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(java.lang.String name)
public static Cache getDBCache()
public static ThreadLocalDateFormat getThreadLocalDateFormat(java.lang.String name)
public static ThreadLocalDateFormat getThreadLocalDateFormat()
public static ThreadLocalNumberFormat getThreadLocalNumberFormat(java.lang.String name)
public static ThreadLocalNumberFormat getThreadLocalNumberFormat()
public static ThreadLocalCalendar getThreadLocalCalendar(java.lang.String name)
public static ThreadLocalCalendar getThreadLocalCalendar()
public static java.lang.Object get(java.lang.Object key)
public static void put(java.lang.Object key,
java.lang.Object val)
public java.lang.String toString()
toString in class java.lang.Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||