|
EAF 7.4 API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface Application
Interface used to define a Lutris server application. Each application defines a class that implements this interface. The specific application class serves as an entry and control point for the application. This class is responsible for initializing any application specific resources, including instance of standard services that are needed. The class must have a constructor with a configuration file argument.
The class is instantiated from a presentation manager and is used to start and stop the application. This structure allows applications to be started on demand by URL reference, as is required for applications running under servlets in HTTPD virtual machines. If remote threads are part of the application, they are normally started from this object.
The application is in one of several states, documented below. The application state is used to determine what actions are take when a request is made for the application.
The following states are possible:
STOPPED
- The application is not running and maybe
started. This is the initial state and the state normally
entered on a shutdown()
.
RUNNING
- The application is currently running.
INCOMPLETE
- The application is not completely running
and the restartup() method maybe called to attempt to bring it into the
RUNNING
state. This state is normally used when a
remote server that is required by the application is not available
when startup()
is called. Partial initialization will
take place, but the request that caused the startup will fail.
A subsequent requests will results in calls to restartup()
until the application can be fully started. This eliminates startup
order dependencies when initializing a distributed application.
The state may also be entered by the application when a remote server
fails.
DEAD
- The application is in an fatal error state and
can not be restarted.
HALTED
- shutdown was called on the application and
the application is not designed so that in can be restarted.
RUNNING
state
when startup()
is called and the STOPPED
state
when shutdown()
is called.
The server provides synchronization on state changes to the application; however multiple requests threats may enter the application at the same time.
Two configuration parameters are required to start an application. Under servlets, these are specified as init args for the presentation servlet. They are:
appClass
- This is the class name of the application
class. If not specified, the presentation servlet will run
without an application object.
appConfig
- An arbitrary string to pass to the
startup(0
method. It normally contains the path or URL
of a Config or properties file containing the application configuration.
If not specified, null
is passed to startup
.
Field Summary | |
---|---|
static int |
DEAD
Dead state code. |
static int |
HALTED
|
static int |
INCOMPLETE
Incomplete state code. |
static int |
RUNNING
Running state code. |
static int |
STOPPED
Stopped state code. |
Method Summary | |
---|---|
com.lutris.util.Config |
getConfig()
Get the application's config object. |
DatabaseManager |
getDatabaseManager()
Get the DatabaseManager associated with this application. |
com.lutris.appserver.server.httpPresentation.HttpPresentationManager |
getHttpPresentationManager()
Get the HttpPresentationManager associated with this
application. |
org.enhydra.util.jivan.JivanFactory |
getJivanFactory()
Get the Jivan factory object being used by the application. |
LogChannel |
getLogChannel()
Get the LogChannel associated with this application. |
java.lang.String |
getName()
Get the application symbolic name. |
SessionManager |
getSessionManager()
Get the SessionManager associated with this application. |
int |
getState()
Get the application state. |
org.enhydra.xml.xmlc.XMLCFactory |
getXMLCFactory()
Get the XMLC factory object being used by the application. |
void |
requestPostProcessor(com.lutris.appserver.server.httpPresentation.HttpPresentationComms comms)
Request post-processing method. |
boolean |
requestPreprocessor(com.lutris.appserver.server.httpPresentation.HttpPresentationComms comms)
Request preprocessing method. |
void |
restartup(com.lutris.util.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 preprocessor hook is called before the request/response pair is processed by the HttpPresentationServlet. |
void |
setHttpPresentationManager(com.lutris.appserver.server.httpPresentation.HttpPresentationManager pm)
Called to tell the application about the presentation manager instance. |
void |
setJivanFactory(boolean reload)
Initializes the Jivan factory object which can be used by application. |
void |
setLogChannel(LogChannel chan)
Set the LogChannel associated with this application. |
void |
setName(java.lang.String name)
Set the application symbolic name. |
void |
setXMLCFactory()
Set the XMLC factory based on the deferred parsing option. |
void |
shutdown()
Shutdown the application. |
void |
startup(com.lutris.util.Config appConfig)
Start the application. |
Field Detail |
---|
static final int STOPPED
static final int RUNNING
static final int INCOMPLETE
static final int DEAD
static final int HALTED
Method Detail |
---|
int getState()
void setName(java.lang.String name)
name
- The application's name.java.lang.String getName()
com.lutris.util.Config getConfig()
void startup(com.lutris.util.Config appConfig) throws ApplicationException
RUNNING
.
appConfig
- Application configuration object.
ApplicationException
- If an error occurs starting the
application.void restartup(com.lutris.util.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 implement this method.
appConfig
- The same appConfig
object that was passed to
startup
.
ApplicationException
- If an error occurs starting the application.void shutdown()
STOPPED
.
boolean requestPreprocessor(com.lutris.appserver.server.httpPresentation.HttpPresentationComms comms) throws java.lang.Exception
Page redirect requests also go through this method, so care must be taken not to generate an endless page redirect loop. ErrorHandler presentation objects do not go through this method if they are invoked from within the presentation manager. However, direct URL requests to ErrorHandler presentation objects will go through this function.
Note: unlike the method servletRequestPreprocessor(), this method is commonly used in most applications. It is the only place that the application has where all requests come through. So you could, for example, put a check for HTTP basic authentication here, and that would automatically protect your entire application. Or, if you were so inclined, you could have a counter that counts the total pages served by your application.
comms
- Object containing request, response and redirect objects.
java.lang.Exception
- Any exception can be thrown.
PageRedirectExceptions are handled as with presentation object.
Other exceptions are handled by searching for an error handler
starting at the requested presentation object.void requestPostProcessor(com.lutris.appserver.server.httpPresentation.HttpPresentationComms comms) throws java.lang.Exception
comms
- Object containing request, response and redirect objects.
java.lang.Exception
- Any exception can be thrown.
PageRedirectExceptions are handled as with presentation object.
Other exceptions are handled by searching for an error handler
starting at the requested presentation object.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
Almost all applications should not override this! The version provided by StandardApplication simply returns false. Currently the debugger is the only application that used this, to support the flow-through debugging of non-Enhydra servlets, it needs to pass the raw request/response pair to the target servlet.
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.void setLogChannel(LogChannel chan)
LogChannel
associated with this application.
The
- LogChannel
to write to.LogChannel getLogChannel()
LogChannel
associated with this application.
null
if this application
does not have one.SessionManager getSessionManager()
SessionManager
associated with this application.
null
if the application
doesn't have a SessionManager
.DatabaseManager getDatabaseManager()
DatabaseManager
associated with this application.
null
if the application
doesn't have a DatabaseManager
.com.lutris.appserver.server.httpPresentation.HttpPresentationManager getHttpPresentationManager()
HttpPresentationManager
associated with this
application.
void setHttpPresentationManager(com.lutris.appserver.server.httpPresentation.HttpPresentationManager pm)
pm
- The presentation manager responsible for running this application.org.enhydra.xml.xmlc.XMLCFactory getXMLCFactory()
void setXMLCFactory()
void setJivanFactory(boolean reload)
reload
- switch which indicates reloading status of Jivan generated
pages in presentation layer (true = reload is on, false = reload is off)org.enhydra.util.jivan.JivanFactory getJivanFactory()
|
EAF 7.4 API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |