|
|||||||||
| Home >> All >> com >> lutris >> appserver >> [ server overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
com.lutris.appserver.server
Class Enhydra

java.lang.Objectcom.lutris.appserver.server.Enhydra
- Direct Known Subclasses:
- LBS
- public class Enhydra
- extends java.lang.Object
The Enhydra class provides static methods that allow each application to conviently get at their application object. It also provides access
This class implements dynamically scoped global variables, accessed via static methods. Which variable is accessed (and thus which Application object is returned) depends on the flow of control of the program before the access (the call stack).
Currently a hashtable keyed on the threads themselves is used to store the different Application, in Java 1.2 threads will have a field already available for storing client data.
Normal usage of this class is to call register() when
a thread enters your application, then unRegister()
when it leaves. It is very important that every register()
is matched with an unRegister(), or else it will be
a memory leak, threads that re-enter the application will have
a stale Application (until the first register()), and
an extra pointer to the Application will be left around, preventing
garbage collection.
If no thread is passed in (the normal usage), the current thread is
used. If your application creates new threads, these will not initially be
associated with any Application. These new threads can be passed in to
register(), to assocaiate them with an Application.
You may call register() before calling start()
on the thread.
To ensure that every register() is balanced with an
unRegister(), the following code is recommended:
Enhydra.register(application);
try {
doSomeWork();
} finally {
Enhydra.unRegister();
}
This will ensure that the unRegister() is called even if
an exception is thrown, but it will not interfere with the exception
processing.
- Since:
- LBS1.8
- Version:
- $Revision: 1.7.14.1 $
| Field Summary | |
private static java.util.Hashtable |
applications
|
| Constructor Summary | |
protected |
Enhydra()
Prevent instantiation |
| Method Summary | |
static Application |
getApplication()
Return the application object for current application. |
static com.lutris.appserver.server.sql.DatabaseManager |
getDatabaseManager()
Return the database manager object for current application. |
static com.lutris.logging.LogChannel |
getLogChannel()
Return the LogChannel in the current Application object, or a log channel to the facility "Enhydra" if there is no current Application set. |
static com.lutris.appserver.server.session.SessionManager |
getSessionManager()
Return the session manager object for current application. |
static void |
register(Application app)
Associate the given application with the current thread. |
static void |
register(java.lang.Thread thread,
Application app)
Associate the given application with the given thread. |
static void |
unRegister()
Remove the association between the current thread and it's Application. |
static void |
unRegister(java.lang.Thread thread)
Remove the association between the specified thread and it's Application. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
applications
private static java.util.Hashtable applications
| Constructor Detail |
Enhydra
protected Enhydra()
- Prevent instantiation
| Method Detail |
register
public static void register(Application app)
- Associate the given application with the current thread.
After this call, calls to
getApplication()made by this thread will returnapp. Be sure to callunRegister()when you are done with the thread. This must be called before the any calls togetApplication().
register
public static void register(java.lang.Thread thread, Application app)
- Associate the given application with the given thread.
After this call, calls to
getApplication()made by the specified thread thread will returnapp. Be sure to callunRegister()when you are done with the thread. This must be called before the thread callsgetApplication().
unRegister
public static void unRegister()
- Remove the association between the current thread and it's Application.
This must be called when the thread is done using this Enhydra class.
The current thread should not call
getApplication()after this.
unRegister
public static void unRegister(java.lang.Thread thread)
- Remove the association between the specified thread and it's Application.
This must be called when the thread is done using this Enhydra class.
The thread should not call
getApplication()after this.
getApplication
public static Application getApplication()
- Return the application object for current application.
Returns null if there is no Application currently associated
with the current thread.
getDatabaseManager
public static com.lutris.appserver.server.sql.DatabaseManager getDatabaseManager()
- Return the database manager object for current application.
Returns null if there is no database manager associated
with the application or there is no application associated
with the current thread.
getSessionManager
public static com.lutris.appserver.server.session.SessionManager getSessionManager()
- Return the session manager object for current application.
Returns null if there is no session manager associated
with the application or there is no application associated
with the current thread.
getLogChannel
public static com.lutris.logging.LogChannel getLogChannel()
- Return the LogChannel in the current Application object, or
a log channel to the facility "Enhydra" if there is no current
Application set.
|
|||||||||
| Home >> All >> com >> lutris >> appserver >> [ server overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC
com.lutris.appserver.server.Enhydra