ZetaGrid v1.9

zeta.handler.statistic
Class AbstractHandler

java.lang.Object
  |
  +--zeta.handler.statistic.AbstractHandler
All Implemented Interfaces:
GetHandler
Direct Known Subclasses:
ActiveWorkUnitsHandler, CloseZerosHandler, LocationsHandler, OperatingSystemsHandler, StatisticOverviewHandler, TeamMembersHandler, Top1000ProducersHandler, Top100ProducersHandler, TopProducers24HoursHandler, TopProducers7DaysHandler, TopProducersHandler, TopTeamsHandler, WorkLoadTodayHandler, WorkstationsHandler

public abstract class AbstractHandler
extends java.lang.Object
implements GetHandler

Base handler to response a GET request for a specific statistic.


Nested Class Summary
(package private)  class AbstractHandler.InnerPageBuffer
           
 
Field Summary
private  int diffTimeImageUpdate
          Duration in milliseconds when the images should be new created.
private  int diffTimeInnerPageUpdate
          Duration in milliseconds when the HTML page should be new created.
private  int diffTimePageUpdate
          Duration in milliseconds when the HTML page should be new created.
private  java.util.Map imageBuffer
          Buffer containing the created images today.
protected static int imgHeight
          Height of the created images.
protected static int imgWidth
          Width of the created images.
private  java.util.Map lastImageUpdate
          Timestamp when the images are created.
private  long lastInnerPageUpdate
          Timestamp when the inner page is send to a client.
private  long lastPageUpdate
          Timestamp when the page is send to a client.
private  java.lang.String pageBuffer
          Buffer containing the HTML page.
protected  ZetaServlet servlet
          Servlet which owns this handler.
private static java.text.DateFormat timeFormatter
          Format 'MM/dd/yyyy HH:mm:ss' to print current timestamp.
private  long timestampOfPage
          Timestamp when the inner page was generated.
 
Constructor Summary
AbstractHandler(ZetaServlet servlet, int diffTimeInnerPageUpdate, int diffTimePageUpdate, int diffTimeImageUpdate)
           
 
Method Summary
private  void appendMenu(java.lang.StringBuffer buffer)
          Append a menu on the left side of the HTML page.
private  void createCompletePage(javax.servlet.http.HttpServletRequest req)
          Creates HTML page with the content of a specified statistic.
 java.awt.image.BufferedImage createImage(java.sql.Connection con, java.lang.String imageName)
          Creates PNG image for a specified name which is defined in the HTML page.
abstract  java.lang.String createPage(java.sql.Connection con)
          Creates HTML page with the content of a specified statistic.
protected  java.lang.String createPage(javax.servlet.http.HttpServletRequest req, java.sql.Connection con)
          Creates HTML page with the content of a specified statistic.
 void doGet(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse resp)
          Handles a GET request resp for the specified statistic.
 java.lang.String getBufferedPage(javax.servlet.http.HttpServletRequest req)
          Returns the buffered page.
 int getImageHeight(java.lang.String imageName)
          Determines the height of the image in the statistic page.
 int getImageWidth(java.lang.String imageName)
          Determines the width of the image in the statistic page.
 AbstractHandler.InnerPageBuffer getInnerPageBuffer()
          Returns the buffer containing the main inner HTML page (table).
 int getInnerPageExpiredDiffTime()
          Returns time difference when a web inner page expired.
 int getPageExpiredDiffTime()
          Returns time difference when a web page expired.
 void imageUpdateCompleted(java.lang.String imageName)
          Event when a new image was generated.
 boolean isImageExpired(java.lang.String imageName)
          Checks if the image of the web page should be updated.
 boolean isInnerPageExpired()
          Checks if the web inner page (table) should be updated.
 boolean isPageExpired()
          Checks if the web page should be updated.
 void pageUpdateCompleted()
          Event when a new web page was generated.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

servlet

protected ZetaServlet servlet
Servlet which owns this handler.


timeFormatter

private static java.text.DateFormat timeFormatter
Format 'MM/dd/yyyy HH:mm:ss' to print current timestamp.


imgWidth

protected static final int imgWidth
Width of the created images.

See Also:
Constant Field Values

imgHeight

protected static final int imgHeight
Height of the created images.

See Also:
Constant Field Values

imageBuffer

private java.util.Map imageBuffer
Buffer containing the created images today.


lastImageUpdate

private java.util.Map lastImageUpdate
Timestamp when the images are created.


pageBuffer

private java.lang.String pageBuffer
Buffer containing the HTML page.


lastInnerPageUpdate

private long lastInnerPageUpdate
Timestamp when the inner page is send to a client.


lastPageUpdate

private long lastPageUpdate
Timestamp when the page is send to a client.


diffTimeInnerPageUpdate

private int diffTimeInnerPageUpdate
Duration in milliseconds when the HTML page should be new created.


diffTimePageUpdate

private int diffTimePageUpdate
Duration in milliseconds when the HTML page should be new created.


diffTimeImageUpdate

private int diffTimeImageUpdate
Duration in milliseconds when the images should be new created.


timestampOfPage

private long timestampOfPage
Timestamp when the inner page was generated.

Constructor Detail

AbstractHandler

public AbstractHandler(ZetaServlet servlet,
                       int diffTimeInnerPageUpdate,
                       int diffTimePageUpdate,
                       int diffTimeImageUpdate)
Parameters:
servlet - servlet which owns this handler.
diffTimePageUpdate - duration in milliseconds when the HTML page should be new created.
diffTimeImageUpdate - duration in milliseconds when the images should be new created.
Method Detail

createPage

public abstract java.lang.String createPage(java.sql.Connection con)
                                     throws java.sql.SQLException,
                                            javax.servlet.ServletException
Creates HTML page with the content of a specified statistic.

Parameters:
con - connection to the back-end database
Returns:
HTML page with the content of a specified statistic.
java.sql.SQLException
javax.servlet.ServletException

createPage

protected java.lang.String createPage(javax.servlet.http.HttpServletRequest req,
                                      java.sql.Connection con)
                               throws java.sql.SQLException,
                                      javax.servlet.ServletException
Creates HTML page with the content of a specified statistic.

Parameters:
req - GET request
con - connection to the back-end database
Returns:
HTML page with the content of a specified statistic.
java.sql.SQLException
javax.servlet.ServletException

createImage

public java.awt.image.BufferedImage createImage(java.sql.Connection con,
                                                java.lang.String imageName)
                                         throws java.sql.SQLException,
                                                javax.servlet.ServletException
Creates PNG image for a specified name which is defined in the HTML page. Default is null.

Parameters:
con - connection to the back-end database
imageName - name of the image
Returns:
PNG image for a specified name which is defined in the HTML page.
java.sql.SQLException
javax.servlet.ServletException

isImageExpired

public boolean isImageExpired(java.lang.String imageName)
Checks if the image of the web page should be updated.

Parameters:
imageName - name of the image
Returns:
true if the image of the web page should be updated.

isInnerPageExpired

public boolean isInnerPageExpired()
Checks if the web inner page (table) should be updated.

Returns:
true if the web page should be updated.

isPageExpired

public boolean isPageExpired()
Checks if the web page should be updated.

Returns:
true if the web page should be updated.

getInnerPageExpiredDiffTime

public int getInnerPageExpiredDiffTime()
Returns time difference when a web inner page expired.

Returns:
time difference when a web inner page expired.

getPageExpiredDiffTime

public int getPageExpiredDiffTime()
Returns time difference when a web page expired.

Returns:
time difference when a web page expired.

imageUpdateCompleted

public final void imageUpdateCompleted(java.lang.String imageName)
Event when a new image was generated.

Parameters:
imageName - name of the image

pageUpdateCompleted

public final void pageUpdateCompleted()
Event when a new web page was generated.


getInnerPageBuffer

public AbstractHandler.InnerPageBuffer getInnerPageBuffer()
                                                   throws javax.servlet.ServletException
Returns the buffer containing the main inner HTML page (table). The inner page buffer should be closed if it not used.

Returns:
inner page buffer
javax.servlet.ServletException

getBufferedPage

public java.lang.String getBufferedPage(javax.servlet.http.HttpServletRequest req)
                                 throws javax.servlet.ServletException
Returns the buffered page. Update the buffer if the web page is expired.

Parameters:
req - GET request
Returns:
buffered page
javax.servlet.ServletException

doGet

public final void doGet(javax.servlet.http.HttpServletRequest req,
                        javax.servlet.http.HttpServletResponse resp)
                 throws javax.servlet.ServletException,
                        java.io.IOException
Handles a GET request resp for the specified statistic. The response resp contains either the HTML page or an image.

Specified by:
doGet in interface GetHandler
javax.servlet.ServletException
java.io.IOException

getImageWidth

public int getImageWidth(java.lang.String imageName)
Determines the width of the image in the statistic page.

Parameters:
imageName - name of the image
Returns:
the width of the image in the statistic page.

getImageHeight

public int getImageHeight(java.lang.String imageName)
Determines the height of the image in the statistic page.

Parameters:
imageName - name of the image
Returns:
the height of the image in the statistic page.

createCompletePage

private void createCompletePage(javax.servlet.http.HttpServletRequest req)
                         throws javax.servlet.ServletException
Creates HTML page with the content of a specified statistic.

Parameters:
req - GET request
Returns:
HTML page with the content of a specified statistic.
javax.servlet.ServletException

appendMenu

private void appendMenu(java.lang.StringBuffer buffer)
Append a menu on the left side of the HTML page.

Parameters:
buffer - buffer containing the HTML page.

ZetaGrid v1.9

For further technical papers, see ZetaGrid Technical Documentation.
 
Copyright © 2001,2002 Sebastian Wedeniwski. All Rights Reserved.