|
Enhydra 5.1 API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.lutris.appserver.server.StandardApplication
Default application implementation. This class provides standard start/stop services. This can be used as a base class to derive Application objects.
Field Summary | |
protected java.lang.String |
appName
The name of the application; defaults to the unqualified class name. |
protected Config |
config
This applications config object. |
protected ApplicationData |
data
Application Data accessable through Jolt Fields. |
protected DatabaseManager |
databaseManager
Database manager instance for application. |
protected java.lang.String |
defaultUrl
Default URL used for application if defined in Config file. |
protected LogChannel |
logChannel
The log channel for this application to write to. |
protected org.apache.log4j.Logger |
logger
|
protected HttpPresentationManager |
presentationManager
Presentation manager instance for application. |
protected boolean |
sendCookieForNewSession
Determines if a cookie with the session id is sent to the client. |
protected SessionManager |
sessionManager
Session manager for all application sessions. |
protected int |
state
Current state of the application. |
protected XMLCFactory |
xmlcFactory
XMLC Factory. |
Fields inherited from interface com.lutris.appserver.server.Application |
DEAD, HALTED, INCOMPLETE, RUNNING, STOPPED |
Constructor Summary | |
StandardApplication()
|
Method Summary | |
protected DatabaseManager |
createDatabaseManager(Config databaseMgrConfig)
Create the database manager to be used by this application. |
protected Session |
createSession(HttpPresentationComms comms)
Create a new session for application. |
protected SessionManager |
createSessionManager(Config sessionMgrConfig)
Create the session manager to be used by this application. |
java.lang.String |
encodeUrl(java.lang.String url,
java.lang.String sessionKey)
Returns the specified url rewritten to include the sessionId |
java.lang.String |
encodeUrl(java.lang.String url,
java.lang.String sessionKey,
java.lang.String appName)
Deprecated. Use encodeUrl(String,String) |
protected void |
ensureSession(HttpPresentationComms comms)
Default method used by requestPreprocessor
to ensure that a session exists and initialize the
session and sessionData fields
in the HttpPresentationComms object. |
ApplicationData |
getApplicationData()
Application Data accessable through Jolt Fields. |
Config |
getConfig()
Get the application's config object. |
DatabaseManager |
getDatabaseManager()
Get the DatabaseManager associated with this application. |
HttpPresentationManager |
getHttpPresentationManager()
Get the HttpPresentationManager associated with this
application. |
LogChannel |
getLogChannel()
Get the LogChannel associated with this application. |
org.apache.log4j.Logger |
getLogger()
|
java.lang.String |
getName()
Get the application symbolic name. |
SessionManager |
getSessionManager()
Get the SessionManager associated with this application. |
int |
getState()
Get the application state. |
XMLCFactory |
getXMLCFactory()
Get the XMLC factory object being used by the application. |
protected void |
initializeNewSession(HttpPresentationComms comms)
This is called when no valid session is found in an incoming request. |
void |
printCopyrightHeader()
|
void |
requestPostProcessor(HttpPresentationComms comms)
Calls application session manager's passivateSession method for the session associated with this request. |
boolean |
requestPreprocessor(HttpPresentationComms comms)
Default application request preprocessor. |
void |
restartup(Config appConfig)
Continue the startup up process with the application is in the INCOMPLETE state. |
boolean |
servletRequestPreprocessor(javax.servlet.Servlet servlet,
javax.servlet.ServletContext context,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
This is a hook that allows applications to act on requests before they enter the Enhydra framework. |
void |
setCookieForNewSession(boolean flag)
Tells the application if a cookie is used to bind new sessions to a client. |
void |
setHttpPresentationManager(HttpPresentationManager pm)
Tells the application about the Presentation Manager running it. |
void |
setLogChannel(LogChannel chan)
Set the LogChannel associated with this application. |
void |
setLogger(org.apache.log4j.Logger log)
|
void |
setName(java.lang.String name)
Set the application name. |
void |
setXMLCFactory(boolean enableReload,
boolean enableRecompilation)
Set the XMLC factory based on the recload and recompilation options. |
void |
shutdown()
Shutdown the application. |
void |
startup(Config appConfig)
Start the application. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected boolean sendCookieForNewSession
protected java.lang.String appName
protected int state
protected SessionManager sessionManager
protected HttpPresentationManager presentationManager
protected DatabaseManager databaseManager
protected Config config
Config
protected java.lang.String defaultUrl
protected LogChannel logChannel
protected org.apache.log4j.Logger logger
protected ApplicationData data
protected XMLCFactory xmlcFactory
Constructor Detail |
public StandardApplication()
Method Detail |
public int getState()
getState
in interface Application
public void setCookieForNewSession(boolean flag)
flag
- indicates whether to send a cookie or not.public Config getConfig()
getConfig
in interface Application
public void setName(java.lang.String name)
setName
in interface Application
name
- The new name for the application.public java.lang.String getName()
N.B. Purposely not syncronized for speed.
getName
in interface Application
public void setLogChannel(LogChannel chan)
LogChannel
associated with this application.
setLogChannel
in interface Application
public void setLogger(org.apache.log4j.Logger log)
setLogger
in interface Application
public LogChannel getLogChannel()
LogChannel
associated with this application.
getLogChannel
in interface Application
null
if this application
does not have one.public org.apache.log4j.Logger getLogger()
getLogger
in interface Application
public void startup(Config appConfig) throws ApplicationException
RUNNING
.
startup
in interface Application
appConfig
- Application configuration object.
ApplicationException
- If an error occurs starting the application.public void printCopyrightHeader()
public void restartup(Config appConfig) throws ApplicationException
INCOMPLETE
state. The default method generates an
error, as the application should never be in the INCOMPLETE
state if it doesn't implment this method.
restartup
in interface Application
appConfig
- The same appConfig
object that was passed to
startup
.
ApplicationException
- If an error occurs restarting the application.public void shutdown()
STOPPED
.
shutdown
in interface Application
protected SessionManager createSessionManager(Config sessionMgrConfig) throws ApplicationException
sessionMgrConfig
- Configuration object containing "SessionManager" keys.
This can be null
to use defaults.
ApplicationException
- If an error occurs in creating a session manager.protected DatabaseManager createDatabaseManager(Config databaseMgrConfig) throws ApplicationException
StandardDatabaseManager
.
This method can be overwritten to create a custom session
manager.
databaseMgrConfig
- Configuration object containing "DatabaseManager" keys.
ApplicationException
- If an error occurs in creating a database manager.protected Session createSession(HttpPresentationComms comms) throws ApplicationException
StandardSession
.
This method can be overwritten to create a custom session.
comms
- Object containing request, response and redirect objects.
Warning: comms.session and comms.sessionData will be null.
they are filled in after this method returns.
ApplicationException
- If an error occurs in creating the session.protected void ensureSession(HttpPresentationComms comms) throws ApplicationException
requestPreprocessor
to ensure that a session exists and initialize the
session
and sessionData
fields
in the HttpPresentationComms
object.
New sessions are only created on requests to presentation
objects, not requests for other types of files (such as gifs).
This avoids allocating multiple sessions when a browser makes
multiple requests for HREFs. If the session already exist, it
is alwasy set in comms
This normally looks up the session using a session key from a cookie.
comms
- Object containing request, response and redirect objects.
ApplicationException
- If an error occurs setting up the session.public void requestPostProcessor(HttpPresentationComms comms) throws ApplicationException
requestPostProcessor
in interface Application
comms
- Object containing request, response and redirect objects.
ApplicationException
- If the session manager was unable to "passivate" the session.com.lutris.appserver.server.session.SessionManager.passivateSession
protected void initializeNewSession(HttpPresentationComms comms) throws ApplicationException
comms
. If
sending session cookies is enabled, a cookie is created and
added to the response, so future requests will be associated
with the newly created session. If sending session cookies is
disabled, it is the application's responsibility to include
the session ID in URLs to associate further requests with the
session.
Warning: At first comms.session
and comms.sessionData
are null. This method initializes
them both.
comms
- Object containing request, response and redirect objects. Session
and SessionData objects are initialized.
ApplicationException
- If an error occurs setting up the session.setCookieForNewSession(boolean)
public java.lang.String encodeUrl(java.lang.String url, java.lang.String sessionKey) throws ApplicationException
url
- String to urlencode
ApplicationException
public java.lang.String encodeUrl(java.lang.String url, java.lang.String sessionKey, java.lang.String appName) throws ApplicationException
url
- String to urlencode
ApplicationException
public ApplicationData getApplicationData()
getApplicationData
in interface Application
public boolean requestPreprocessor(HttpPresentationComms comms) throws java.lang.Exception
N.B. Purposely not syncronized for speed/concurrency.
requestPreprocessor
in interface Application
comms
- Object containing request, response and redirect objects.
java.lang.Exception
- May throw any exception, as with a presentation object;
including page redirects.public SessionManager getSessionManager()
SessionManager
associated with this application.
getSessionManager
in interface Application
null
if the application
doesn't have a SessionManager
.public DatabaseManager getDatabaseManager()
DatabaseManager
associated with this application.
getDatabaseManager
in interface Application
null
if the application
doesn't have a DatabaseManager
.public HttpPresentationManager getHttpPresentationManager()
HttpPresentationManager
associated with this
application.
getHttpPresentationManager
in interface Application
public void setHttpPresentationManager(HttpPresentationManager pm)
setHttpPresentationManager
in interface Application
pm
- The HTTP presentation manager running this application.public boolean servletRequestPreprocessor(javax.servlet.Servlet servlet, javax.servlet.ServletContext context, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, java.io.IOException
In contrast, the method requestPreprocessor() is commonly overridden. It provides applications with a centeral place to put code that has to be run on every request before it is sent to the presentation objects.
servletRequestPreprocessor
in interface Application
servlet
- The servlet we are running in.context
- The ServletContext that was used to initialize our servlet.request
- The incomming request object.response
- The incomming response object.
javax.servlet.ServletException
- You are allowed to throw the same exceptions that the servlet's
service() method throws.
java.io.IOException
- You are allowed to throw the same exceptions that the servlet's
service() method throws.public XMLCFactory getXMLCFactory()
getXMLCFactory
in interface Application
public void setXMLCFactory(boolean enableReload, boolean enableRecompilation)
setXMLCFactory
in interface Application
|
Enhydra 5.1 API | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |