| com.lutris.appserver.server.Application
All known Subclasses: com.lutris.appserver.server.StandardApplication,
Application | public interface Application (Code) | | 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.
The state is under control of the application. Its is used by the
server to know what actions are allowed, but never modified by
the server. The simplest application enters the 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 .
version: $Revision: 1.3 $ author: Mark Diekhans |
Field Summary | |
final public static int | DEAD Dead state code. | final public static int | HALTED | final public static int | INCOMPLETE Incomplete state code. | final public static int | RUNNING Running state code. | final public static int | STOPPED Stopped state code. |
DEAD | final public static int DEAD(Code) | | Dead state code.
|
HALTED | final public static int HALTED(Code) | | |
INCOMPLETE | final public static int INCOMPLETE(Code) | | Incomplete state code.
|
RUNNING | final public static int RUNNING(Code) | | Running state code.
|
STOPPED | final public static int STOPPED(Code) | | Stopped state code.
|
getConfig | public Config getConfig()(Code) | | Get the application's config object.
The config object. |
getDatabaseManager | public DatabaseManager getDatabaseManager()(Code) | | Get the DatabaseManager associated with this application.
The database manager or null if the applicationdoesn't have a DatabaseManager . |
getHttpPresentationManager | public HttpPresentationManager getHttpPresentationManager()(Code) | | Get the HttpPresentationManager associated with this
application.
The presentation manager used by this application. |
getJivanFactory | public JivanFactory getJivanFactory()(Code) | | Get the Jivan factory object being used by the application.
|
getLogChannel | public LogChannel getLogChannel()(Code) | | Get the LogChannel associated with this application.
The log channel or null if this applicationdoes not have one. |
getName | public String getName()(Code) | | Get the application symbolic name.
The symbolic name. |
getSessionManager | public SessionManager getSessionManager()(Code) | | Get the SessionManager associated with this application.
The session manager or null if the applicationdoesn't have a SessionManager . |
getState | public int getState()(Code) | | Get the application state.
The application's state code. |
getXMLCFactory | public XMLCFactory getXMLCFactory()(Code) | | Get the XMLC factory object being used by the application.
If one was not configured, a default one is created on the
first call to this method.
|
requestPostProcessor | public void requestPostProcessor(HttpPresentationComms comms) throws Exception(Code) | | Request post-processing method. All requests for URLs associated
with this application go through this function. It may do any
post-processing desired (e.g. saving sessions to persistent store).
Parameters: comms - Object containing request, response and redirect objects. exception: Exception - Any exception can be thrown.PageRedirectExceptions are handled as with presentation object.Other exceptions are handled by searching for an error handlerstarting at the requested presentation object. |
requestPreprocessor | public boolean requestPreprocessor(HttpPresentationComms comms) throws Exception(Code) | | Request preprocessing method. All requests for URLs associated
with this application go through this function. It may do any
preprocessing desired, including handling the request or generating
a page redirect. It can be used to force login, allocate session
objects, restrict access, etc.
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.
Parameters: comms - Object containing request, response and redirect objects.true if the request has been handled, false if normal requesthandling should continue. exception: Exception - Any exception can be thrown.PageRedirectExceptions are handled as with presentation object.Other exceptions are handled by searching for an error handlerstarting at the requested presentation object. |
restartup | public void restartup(Config appConfig) throws ApplicationException(Code) | | Continue the startup up process with the application is in the
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.
Parameters: appConfig - The same appConfig object that was passed tostartup . exception: ApplicationException - If an error occurs starting the application. |
servletRequestPreprocessor | public boolean servletRequestPreprocessor(Servlet servlet, ServletContext context, HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException(Code) | | This preprocessor hook is called before the request/response pair
is processed by the HttpPresentationServlet. It gives the
application a chance to work with the raw request/response pair
before they are wrapped by HttpPresentationRequest and
HttpPresentationResponse objects. Return false to indicate
that the request should continue to be processed normally
or true to indicate that this method has handled the request,
and all processing of the request should stop, in which case
it will not be passed on to the presentation manager etc...
The default method in StandardApplication always returns false.
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.
Parameters: servlet - The servlet we are running in. Parameters: context - The ServletContext that was used to initialize our servlet. Parameters: request - The incomming request object. Parameters: response - The incomming response object.True if this method handled the request, in which case nofurther action will be taken. Or false if normal processingshould continue. exception: ServletException - You are allowed to throw the same exceptions that the servlet'sservice() method throws. exception: IOException - You are allowed to throw the same exceptions that the servlet'sservice() method throws. |
setHttpPresentationManager | public void setHttpPresentationManager(HttpPresentationManager pm)(Code) | | Called to tell the application about the presentation manager
instance. This is necessary because the Presentation Manager is
created in parallel with the application by the
HttpPresentationServlet.
Parameters: pm - The presentation manager responsible for running this application. |
setJivanFactory | public void setJivanFactory(boolean reload)(Code) | | Initializes the Jivan factory object which can be used by application.
Parameters: reload - switch which indicates reloading status of Jivan generatedpages in presentation layer (true = reload is on, false = reload is off) |
setLogChannel | public void setLogChannel(LogChannel chan)(Code) | | Set the LogChannel associated with this application.
Parameters: The - LogChannel to write to. |
setName | public void setName(String name)(Code) | | Set the application symbolic name.
Parameters: name - The application's name. |
setXMLCFactory | public void setXMLCFactory()(Code) | | Set the XMLC factory based on the deferred parsing option.
|
shutdown | public void shutdown()(Code) | | Shutdown the application. The default method sets the state to
STOPPED .
|
startup | public void startup(Config appConfig) throws ApplicationException(Code) | | Start the application. The default method sets the state to
RUNNING .
Parameters: appConfig - Application configuration object. exception: ApplicationException - If an error occurs starting theapplication. |
|
|