Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.lutris.appserver.server.httpPresentation
Class HttpPresentationManager  view HttpPresentationManager download HttpPresentationManager.java

java.lang.Object
  extended bycom.lutris.appserver.server.httpPresentation.HttpPresentationManager

public class HttpPresentationManager
extends java.lang.Object

Presentation manager class. Handles loading and execution of presentation objects.

Version:
$Revision: 1.67.2.1.4.1 $

Field Summary
private  com.lutris.appserver.server.Application application
          Application that this presentation manager is associate with.
private  boolean debugLoggingEnabled
          Is DEBUG logging enabled?
private  PresentationLoader loader
          Presentation and resource loader/cache.
private  com.lutris.logging.LogChannel logChannel
          Applications log channel.
private  int maxRedirectErrorLoops
          Maximum number of times to go through page redirect/error handling loops.
private  long nextRequestId
          Request id incremented on each request.
private  javax.servlet.Servlet servlet
          The Servlet we are running in.
private  javax.servlet.ServletContext servletContext
          The ServletContext that was used to initialize the Servlet we are running in.
 
Constructor Summary
HttpPresentationManager(java.lang.String appPresentationPrefix, com.lutris.appserver.server.Application presApplication, java.lang.ClassLoader applicationClassLoader, boolean cacheClasses, boolean cacheFiles)
          Construct a HTTP presentation manager.
 
Method Summary
 void addMimeType(java.lang.String mimeType, java.lang.String extension)
          Add a new mime type to extension mapping.
 void flushCache()
          Flush the presentation object and resource caches.
 java.lang.ClassLoader getAppClassLoader()
          Get the application class loader.
 java.io.InputStream getAppFileAsStream(java.lang.String appFileName)
          Get a file associated with the application.
 javax.servlet.Servlet getServlet()
          Get the servlet we are running in.
 javax.servlet.ServletContext getServletContext()
          Get the servlet context used to initialize the servlet we are running in.
 com.lutris.appserver.server.session.Session getSession(javax.servlet.ServletRequest request)
          Looks up the session object (if any) that would be used to process the request.
 boolean isPOCacheEnabled()
          Determine if the PO cache is enabled.
 boolean isPresentationRequest(HttpPresentationRequest request)
          Determine if a request URL references a presentation object.
 boolean isResourceCacheEnabled()
          Determine if the file resource class cache is enabled.
private  void logPresObjRun(HttpPresentationComms comms, java.lang.String presObjPath, java.lang.Throwable exception, java.lang.String requestedPrseObjPath, long requestId)
          Log the execution of a presentation object.
 void Run(HttpPresentationRequest request, HttpPresentationResponse response)
          The method is invoked to fulfill an HTTP request.
private  void runPresentationObj(HttpPresentationComms comms, java.lang.String urlPath, java.lang.Throwable exception, com.lutris.appserver.server.Application application)
          Load and run a presentation object (including error handlers).
private  void runRequestPostProcessor(HttpPresentationComms comms, long requestId, java.lang.String presObjPath)
          Run the request post-processor.
private  boolean runRequestPreprocessor(HttpPresentationComms comms, long requestId, java.lang.String presObjPath)
          Run the request preprocessor.
 boolean servletRequestPreprocessor(javax.servlet.Servlet me, javax.servlet.ServletContext context, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          This is an internal use only hook, see the description in Application.java.
 void setServletAndContext(javax.servlet.Servlet servlet, javax.servlet.ServletContext servletContext)
          Notify the presentation manager which servlet we are running in.
 int sizeofPOCache()
          Return the number of entries in the PO cache.
 int sizeofResourceCache()
          Return the number of entries in the resource cache.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

maxRedirectErrorLoops

private final int maxRedirectErrorLoops
Maximum number of times to go through page redirect/error handling loops.

See Also:
Constant Field Values

loader

private PresentationLoader loader
Presentation and resource loader/cache.


application

private com.lutris.appserver.server.Application application
Application that this presentation manager is associate with.


logChannel

private com.lutris.logging.LogChannel logChannel
Applications log channel. No logging is done if null.


debugLoggingEnabled

private boolean debugLoggingEnabled
Is DEBUG logging enabled?


nextRequestId

private long nextRequestId
Request id incremented on each request.


servlet

private javax.servlet.Servlet servlet
The Servlet we are running in. Will be an instance of com.lutris.appserver.server.httpPresenation.HttpPresentationServlet .


servletContext

private javax.servlet.ServletContext servletContext
The ServletContext that was used to initialize the Servlet we are running in. This is needed to, for example, get the other servlets that are our peers in the server.

Constructor Detail

HttpPresentationManager

public HttpPresentationManager(java.lang.String appPresentationPrefix,
                               com.lutris.appserver.server.Application presApplication,
                               java.lang.ClassLoader applicationClassLoader,
                               boolean cacheClasses,
                               boolean cacheFiles)
                        throws HttpPresentationException
Construct a HTTP presentation manager.

Method Detail

Run

public void Run(HttpPresentationRequest request,
                HttpPresentationResponse response)
         throws HttpPresentationException,
                java.io.IOException
The method is invoked to fulfill an HTTP request. This function is thread-safe and does not need synchronization. It is expected that the protocol layer invoking this function provide multi-threading to handle requests. The alogrithm for handling a request is:
 presObj = requestUrl
 while request-not-handled {
    if not error-handler-redirect
        invoke-application-request-preprocessor presObj
    load-presentation-object-class
    invoke-presentation-object
    if not error-handler-redirect
        invoke-application-request-postprocessor presObj
    if (client-side-page-redirect-exception) {
        send-redirect-to-client
        break
    }
    if (server-side-page-redirect-exception) {
        (Not implemented yet)
        set-request-to-redirectUrl
        presObj = redirectUrl
        continue
    }
    if (401-unauthorized-exception) {
        set-header-and-response-code
        break
    }
    if (other-exception) {
        presObj = find-error-handler
    }
 }
 


logPresObjRun

private void logPresObjRun(HttpPresentationComms comms,
                           java.lang.String presObjPath,
                           java.lang.Throwable exception,
                           java.lang.String requestedPrseObjPath,
                           long requestId)
                    throws HttpPresentationException
Log the execution of a presentation object.


servletRequestPreprocessor

public boolean servletRequestPreprocessor(javax.servlet.Servlet me,
                                          javax.servlet.ServletContext context,
                                          javax.servlet.http.HttpServletRequest request,
                                          javax.servlet.http.HttpServletResponse response)
                                   throws javax.servlet.ServletException,
                                          java.io.IOException
This is an internal use only hook, see the description in Application.java. The call is passed through to the application.


runRequestPreprocessor

private boolean runRequestPreprocessor(HttpPresentationComms comms,
                                       long requestId,
                                       java.lang.String presObjPath)
                                throws java.lang.Exception
Run the request preprocessor.


runRequestPostProcessor

private void runRequestPostProcessor(HttpPresentationComms comms,
                                     long requestId,
                                     java.lang.String presObjPath)
                              throws java.lang.Exception
Run the request post-processor.


runPresentationObj

private void runPresentationObj(HttpPresentationComms comms,
                                java.lang.String urlPath,
                                java.lang.Throwable exception,
                                com.lutris.appserver.server.Application application)
                         throws java.lang.Throwable
Load and run a presentation object (including error handlers). A return without exception indicates that the presentation has been processed. Will rethrow an exception if one is being handled and a handler is not found.


isPOCacheEnabled

public boolean isPOCacheEnabled()
Determine if the PO cache is enabled.


sizeofPOCache

public int sizeofPOCache()
Return the number of entries in the PO cache.


isResourceCacheEnabled

public boolean isResourceCacheEnabled()
Determine if the file resource class cache is enabled.


sizeofResourceCache

public int sizeofResourceCache()
Return the number of entries in the resource cache.


getAppFileAsStream

public java.io.InputStream getAppFileAsStream(java.lang.String appFileName)
                                       throws java.io.IOException,
                                              HttpPresentationException
Get a file associated with the application. The file is located in the same manner as presentation objects are located. That is, prepending the presentationPrefix to the specified path and searching the class path for a directory or JAR containing the file.


isPresentationRequest

public boolean isPresentationRequest(HttpPresentationRequest request)
                              throws HttpPresentationException
Determine if a request URL references a presentation object.


getSession

public com.lutris.appserver.server.session.Session getSession(javax.servlet.ServletRequest request)
Looks up the session object (if any) that would be used to process the request. This is will not used normally, because the session is give to the application's preprocessor method and the presentation objects. Also, it is not normal to have a raw ServletRequest. The debugger uses this to examine the session data before and after each request. Consider this an internal use onlyu method.


setServletAndContext

public void setServletAndContext(javax.servlet.Servlet servlet,
                                 javax.servlet.ServletContext servletContext)
Notify the presentation manager which servlet we are running in. This will be done immediatly after this object is created, if this ojbject is created by an HttpPresentationServlet (currently the only creator). In the future, if this class is used in non-servlet situations, this need not be called.


getServlet

public javax.servlet.Servlet getServlet()
Get the servlet we are running in. Currently this class is only used in a servlet (HttpPresentationServlet), so this value will always be set. But in the future this class may be used in other non-servlet enviornments, in which case this method will return null.


getServletContext

public javax.servlet.ServletContext getServletContext()
Get the servlet context used to initialize the servlet we are running in. Currently this class is only used in a servlet (HttpPresentationServlet), so this value will always be set. But in the future this class may be used in other non-servlet enviornments, in which case this method will return null.


flushCache

public void flushCache()
Flush the presentation object and resource caches.


addMimeType

public void addMimeType(java.lang.String mimeType,
                        java.lang.String extension)
Add a new mime type to extension mapping.


getAppClassLoader

public java.lang.ClassLoader getAppClassLoader()
Get the application class loader.