org.hd.d.pg2k.webSvr.util
Class JavadocBundleServlet

java.lang.Object
  extended by javax.servlet.GenericServlet
      extended by javax.servlet.http.HttpServlet
          extended by org.hd.d.pg2k.webSvr.util.JavadocBundleServlet
All Implemented Interfaces:
java.io.Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig

public final class JavadocBundleServlet
extends javax.servlet.http.HttpServlet

This is the servlet that serves the content of the (latest) Gallery javadoc bundle. Essentially this does what the default WAR container support would do if the javadoc files were simply laid out in WAR as static data, though giving us the option to tune cacheing and similar behaviour.

We only respond to GET (and possibly HEAD) requests.

See Also:
Serialized Form

Field Summary
private static DataSourceBean.AEPLinkedKey dirKey
          Private key for cache of ZIP directory against current AEP instance; never null.
private static DataSourceBean.AEPLinkedKey fffKey
          Cache key for most frequently-fetched (small) files; never null.
private static int MAX_FFF_BYTES
          Maximum uncompressed size in bytes of a file to be considered for the fff cache; strictly positive.
private static int MAX_FFF_BYTES_COMPRESSED
          Maximum compressed size in bytes of a file to be considered for the fff cache; strictly positive.
private static int MAX_FFF_ENTRIES
          Maximum number of entries to hold in FFF cache; strictly positive.
private static int MIN_FFF_ENTRIES
          Minimum number of entries ('working set') to try to hold in FFF cache; strictly positive.
private static long serialVersionUID
          Unique serialisation ID.
 
Constructor Summary
JavadocBundleServlet()
           
 
Method Summary
private  void doAction(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, boolean isHEAD)
          Respond to a GET or HEAD request for the content served by this servlet.
 void doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Respond to a GET request for the content served by this servlet.
 void doHead(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          Respond to a HEAD request for the content served by this servlet.
private static Name.ExhibitFull getBundleExhibitName(DataSourceBean dsb)
          Get full exhibit name of the latest javadoc bundle; null if none.
private static DataSourceBean getDataSource(javax.servlet.ServletConfig config, javax.servlet.http.HttpServletRequest request)
          Get singleton (per-servlet-context) data pipeline/cache instance.
 long getLastModified(javax.servlet.http.HttpServletRequest request)
          Get `last-modified' time for the entire bundle.
private static java.util.SortedMap<java.lang.CharSequence,FileTools.ZE> getZIPEntryOffsets(DataSourceBean dsb)
          Get ZIP directory/offsets; null if none.
 
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doOptions, doPost, doPut, doTrace, service, service
 
Methods inherited from class javax.servlet.GenericServlet
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, init, log, log
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

fffKey

private static final DataSourceBean.AEPLinkedKey fffKey
Cache key for most frequently-fetched (small) files; never null. Linked to the AEP instance to be automatically discarded when the exhibit set changes.


MAX_FFF_BYTES

private static final int MAX_FFF_BYTES
Maximum uncompressed size in bytes of a file to be considered for the fff cache; strictly positive.

See Also:
Constant Field Values

MAX_FFF_BYTES_COMPRESSED

private static final int MAX_FFF_BYTES_COMPRESSED
Maximum compressed size in bytes of a file to be considered for the fff cache; strictly positive.

See Also:
Constant Field Values

MIN_FFF_ENTRIES

private static final int MIN_FFF_ENTRIES
Minimum number of entries ('working set') to try to hold in FFF cache; strictly positive. Much smaller than MAX_FFF_ENTRIES, even as small as (say) 10.

See Also:
Constant Field Values

MAX_FFF_ENTRIES

private static final int MAX_FFF_ENTRIES
Maximum number of entries to hold in FFF cache; strictly positive. Much larger than MIN_FFF_ENTRIES.

See Also:
Constant Field Values

dirKey

private static final DataSourceBean.AEPLinkedKey dirKey
Private key for cache of ZIP directory against current AEP instance; never null.


serialVersionUID

private static final long serialVersionUID
Unique serialisation ID.

See Also:
Constant Field Values
Constructor Detail

JavadocBundleServlet

public JavadocBundleServlet()
Method Detail

doAction

private void doAction(javax.servlet.http.HttpServletRequest request,
                      javax.servlet.http.HttpServletResponse response,
                      boolean isHEAD)
               throws java.io.IOException
Respond to a GET or HEAD request for the content served by this servlet.

Parameters:
request - The servlet request we are processing
response - The servlet response we are producing
Throws:
java.io.IOException - if an input/output error occurs

doGet

public void doGet(javax.servlet.http.HttpServletRequest request,
                  javax.servlet.http.HttpServletResponse response)
           throws java.io.IOException
Respond to a GET request for the content served by this servlet.

Overrides:
doGet in class javax.servlet.http.HttpServlet
Parameters:
request - The servlet request we are processing
response - The servlet response we are producing
Throws:
java.io.IOException - if an input/output error occurs

doHead

public void doHead(javax.servlet.http.HttpServletRequest request,
                   javax.servlet.http.HttpServletResponse response)
            throws java.io.IOException
Respond to a HEAD request for the content served by this servlet.

Overrides:
doHead in class javax.servlet.http.HttpServlet
Parameters:
request - The servlet request we are processing
response - The servlet response we are producing
Throws:
java.io.IOException - if an input/output error occurs

getLastModified

public final long getLastModified(javax.servlet.http.HttpServletRequest request)
Get `last-modified' time for the entire bundle. If we can't find out then we return -1L, the default value.

If returning a last-modified value causes difficulty (eg with Tomcat 4.0.1) then we return -1.

Overrides:
getLastModified in class javax.servlet.http.HttpServlet
Parameters:
request - The servlet request we are processing

getDataSource

private static DataSourceBean getDataSource(javax.servlet.ServletConfig config,
                                            javax.servlet.http.HttpServletRequest request)
Get singleton (per-servlet-context) data pipeline/cache instance. The config param must not be null, but for some operations (such as calling destroy()) request can be null.


getBundleExhibitName

private static final Name.ExhibitFull getBundleExhibitName(DataSourceBean dsb)
Get full exhibit name of the latest javadoc bundle; null if none.


getZIPEntryOffsets

private static java.util.SortedMap<java.lang.CharSequence,FileTools.ZE> getZIPEntryOffsets(DataSourceBean dsb)
Get ZIP directory/offsets; null if none. The keys of the returned (immutable) map are valid files/entries in the ZIP.

Each value is the (non-negative) offset from the start of the ZIP file to the start of its entry as can be read with ZipInputStream.

This is cached against the AEP instance for efficiency. (We might have to go back across the network to the master to fetch this if we don't have the entire bundle cached locally, for example, which is slow.)

On successfully cacheing this we read the first byte of the archive to try to trigger (pre)cacheing of at least an enclosing early chunk.


DHD Multimedia Gallery V1.57.21

Copyright (c) 1996-2011, Damon Hart-Davis. All rights reserved.