org.logicalcobwebs.proxool.admin.servlet
Class AdminServlet

java.lang.Object
  extended by HttpServlet
      extended by org.logicalcobwebs.proxool.admin.servlet.AdminServlet

public class AdminServlet
extends HttpServlet

Use this to admin each pool within Proxool. It acts like a normal servlet., so just configure it within your web app as you see fit. For example, within web.xml:

   <servlet>
       <servlet-name>Admin</servlet-name>
       <servlet-class>org.logicalcobwebs.proxool.admin.servlet.AdminServlet</servlet-class>
       <init-param>
            <param-name>output</param-name>
            <param-value>full|simple</param-value>
        </init-param>
        <init-param>
            <param-name>cssFile</param-name>
            <param-value>/my_path/my.css</param-value>
        </init-param>
   </servlet>
   <servlet-mapping>
       <servlet-name>Admin</servlet-name>
       <url-pattern>/proxool</url-pattern>
   </servlet-mapping>
 
Options:

Since:
Proxool 0.7
Version:
$Revision: 1.12 $, $Date: 2005/10/07 08:23:10 $
Author:
bill, $Author: billhorsman $ (current maintainer)

Field Summary
private static java.lang.String ALIAS
          The request parameter name that defines the pool
private static java.lang.String CONNECTION_ID
          If we are drilling down into a connection (on the snapshot tab then this points to the ID we are getting detailed information for.
private static java.lang.String CORE_PROPERTY
          Used as part of the CSS class
private  java.lang.String cssFile
          A valid URLL that can be linked to to override default, inline CSS.
private static java.text.DateFormat DATE_FORMAT
          dd-MMM-yyyy HH:mm:ss
private static java.text.DecimalFormat DECIMAL_FORMAT
           
private static java.lang.String DELEGATED_PROPERTY
          Used as part of the CSS class
private static java.lang.String DETAIL
           
private static java.lang.String DETAIL_LESS
           
private static java.lang.String DETAIL_MORE
           
private static Log LOG
           
private  java.lang.String output
          Either OUTPUT_FULL (default) or OUTPUT_SIMPLE
static java.lang.String OUTPUT_FULL
          OUtput full HTML including <HTML>, <HEAD> and <BODY> tags.
static java.lang.String OUTPUT_SIMPLE
          OUtput simple HTML excluding <HTML>, <HEAD> and <BODY> tags.
private static java.lang.String SNAPSHOT
          Used as part of the CSS class
private static java.lang.String STANDARD_PROPERTY
          Used as part of the CSS class
private static java.lang.String STATISTIC
          Used as part of the CSS class
private static java.lang.String[] STATUS_CLASSES
          The CSS class for a connection in different states: null available active offline
private static java.lang.String TAB
          The request parameter name that defines: TAB_DEFINITION (default) TAB_SNAPSHOT TAB_STATISTICS
private static java.lang.String TAB_DEFINITION
           
private static java.lang.String TAB_SNAPSHOT
           
private static java.lang.String TAB_STATISTICS
           
private static java.text.DateFormat TIME_FORMAT
          HH:mm:ss
 
Constructor Summary
AdminServlet()
           
 
Method Summary
private  void closeHtml(ServletOutputStream out)
           
private  void closeTable(ServletOutputStream out)
           
private  void doDefinition(ServletOutputStream out, ConnectionPoolDefinitionIF cpd)
          Output the definition
private  void doDrillDownConnection(ServletOutputStream out, ConnectionInfoIF drillDownConnection)
           
protected  void doGet(HttpServletRequest request, HttpServletResponse response)
          Show the details for a pool.
private  void doList(ServletOutputStream out, java.lang.String alias, java.lang.String tab, java.lang.String link)
          Output the list of available connection pools.
protected  void doPost(HttpServletRequest request, HttpServletResponse response)
          Delegate to #doGet(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
private  void doSnapshot(ServletOutputStream out, ConnectionPoolDefinitionIF cpd, java.lang.String link, java.lang.String level, java.lang.String connectionId)
          Output a snapshot of the pool.
private  void doSnapshotDetails(ServletOutputStream out, ConnectionPoolDefinitionIF cpd, SnapshotIF snapshot, java.lang.String link, java.lang.String connectionId)
          If we want a more detailed snapshot then #doSnapshot(javax.servlet.ServletOutputStream, org.logicalcobwebs.proxool.ConnectionPoolDefinitionIF, String, String, String) calls this too
private  void doStatistics(ServletOutputStream out, StatisticsIF[] statisticsArray, ConnectionPoolDefinitionIF cpd)
          Output the statistics.
private  void doTabs(ServletOutputStream out, java.lang.String alias, java.lang.String link, java.lang.String tab, boolean statisticsAvailable, boolean statisticsComingSoon)
          Output the tabs that we are showing at the top of the page
private  void drawBarChart(java.lang.StringBuffer out, java.lang.String[] colours, int[] lengths)
          We can draw a bar chart simply enough.
private  java.lang.String formatMilliseconds(int time)
          Express time in an easy to read HH:mm:ss format
private static java.lang.String getStatusClass(ConnectionInfoIF info)
          What CSS class to use for a particular connection.
 void init(ServletConfig servletConfig)
           
private  void openDataTable(ServletOutputStream out)
           
private  void openHtml(ServletOutputStream out)
           
private  void printDefinitionEntry(ServletOutputStream out, java.lang.String name, java.lang.String value, java.lang.String type)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG

private static final Log LOG

STATUS_CLASSES

private static final java.lang.String[] STATUS_CLASSES
The CSS class for a connection in different states:


OUTPUT_FULL

public static final java.lang.String OUTPUT_FULL
OUtput full HTML including <HTML>, <HEAD> and <BODY> tags.

See Also:
output, configuration, Constant Field Values

OUTPUT_SIMPLE

public static final java.lang.String OUTPUT_SIMPLE
OUtput simple HTML excluding <HTML>, <HEAD> and <BODY> tags.

See Also:
output, configuration, Constant Field Values

output

private java.lang.String output
Either OUTPUT_FULL (default) or OUTPUT_SIMPLE

See Also:
configuration

cssFile

private java.lang.String cssFile
A valid URLL that can be linked to to override default, inline CSS.

See Also:
configuration

STATISTIC

private static final java.lang.String STATISTIC
Used as part of the CSS class

See Also:
Constant Field Values

CORE_PROPERTY

private static final java.lang.String CORE_PROPERTY
Used as part of the CSS class

See Also:
Constant Field Values

STANDARD_PROPERTY

private static final java.lang.String STANDARD_PROPERTY
Used as part of the CSS class

See Also:
Constant Field Values

DELEGATED_PROPERTY

private static final java.lang.String DELEGATED_PROPERTY
Used as part of the CSS class

See Also:
Constant Field Values

SNAPSHOT

private static final java.lang.String SNAPSHOT
Used as part of the CSS class

See Also:
Constant Field Values

TIME_FORMAT

private static final java.text.DateFormat TIME_FORMAT
HH:mm:ss

See Also:
formatMilliseconds(int)

DATE_FORMAT

private static final java.text.DateFormat DATE_FORMAT
dd-MMM-yyyy HH:mm:ss


DECIMAL_FORMAT

private static final java.text.DecimalFormat DECIMAL_FORMAT

DETAIL

private static final java.lang.String DETAIL
See Also:
Constant Field Values

DETAIL_MORE

private static final java.lang.String DETAIL_MORE
See Also:
Constant Field Values

DETAIL_LESS

private static final java.lang.String DETAIL_LESS
See Also:
Constant Field Values

TAB

private static final java.lang.String TAB
The request parameter name that defines:
  1. TAB_DEFINITION (default)
  2. TAB_SNAPSHOT
  3. TAB_STATISTICS

See Also:
Constant Field Values

TAB_DEFINITION

private static final java.lang.String TAB_DEFINITION
See Also:
TAB, Constant Field Values

TAB_SNAPSHOT

private static final java.lang.String TAB_SNAPSHOT
See Also:
TAB, Constant Field Values

TAB_STATISTICS

private static final java.lang.String TAB_STATISTICS
See Also:
TAB, Constant Field Values

ALIAS

private static final java.lang.String ALIAS
The request parameter name that defines the pool

See Also:
Constant Field Values

CONNECTION_ID

private static final java.lang.String CONNECTION_ID
If we are drilling down into a connection (on the snapshot tab then this points to the ID we are getting detailed information for.

See Also:
Constant Field Values
Constructor Detail

AdminServlet

public AdminServlet()
Method Detail

init

public void init(ServletConfig servletConfig)
          throws ServletException
Throws:
ServletException

doPost

protected void doPost(HttpServletRequest request,
                      HttpServletResponse response)
               throws ServletException,
                      java.io.IOException
Delegate to #doGet(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)

Throws:
ServletException
java.io.IOException

doGet

protected void doGet(HttpServletRequest request,
                     HttpServletResponse response)
              throws ServletException,
                     java.io.IOException
Show the details for a pool.

Throws:
ServletException
java.io.IOException

doTabs

private void doTabs(ServletOutputStream out,
                    java.lang.String alias,
                    java.lang.String link,
                    java.lang.String tab,
                    boolean statisticsAvailable,
                    boolean statisticsComingSoon)
             throws java.io.IOException
Output the tabs that we are showing at the top of the page

Parameters:
out - where to write the HTNL to
alias - the current pool
link - the URL to get back to this servlet
tab - the active tab
statisticsAvailable - whether statistics are available (true if configured and ready)
statisticsComingSoon - whether statistics will be available (true if configured but not ready yet)
Throws:
java.io.IOException

doStatistics

private void doStatistics(ServletOutputStream out,
                          StatisticsIF[] statisticsArray,
                          ConnectionPoolDefinitionIF cpd)
                   throws java.io.IOException
Output the statistics. If there are more than one set of statistics then show them all.

Parameters:
out - where to write HTML to
statisticsArray - the statistics we have ready to see
cpd - defines the connection
Throws:
java.io.IOException

drawBarChart

private void drawBarChart(java.lang.StringBuffer out,
                          java.lang.String[] colours,
                          int[] lengths)
We can draw a bar chart simply enough. The two arrays passed as parameters must be of equal length

Parameters:
out - where to write the HTML
colours - the colur (CSS valid string) for each segment
lengths - the length of each segment. Can be any size since the chart just takes up as much room as possible as uses the relative length of each segment.

doDefinition

private void doDefinition(ServletOutputStream out,
                          ConnectionPoolDefinitionIF cpd)
                   throws java.io.IOException
Output the definition

Parameters:
out - where to write the HTML
cpd - the definition
Throws:
java.io.IOException

doSnapshot

private void doSnapshot(ServletOutputStream out,
                        ConnectionPoolDefinitionIF cpd,
                        java.lang.String link,
                        java.lang.String level,
                        java.lang.String connectionId)
                 throws java.io.IOException,
                        ProxoolException
Output a snapshot of the pool.

Parameters:
out - where to write the HTML
cpd - defines the pool
link - the URL back to this servlet
level - either DETAIL_LESS or DETAIL_MORE
connectionId - the connection we want to drill into (optional)
Throws:
java.io.IOException
ProxoolException

doSnapshotDetails

private void doSnapshotDetails(ServletOutputStream out,
                               ConnectionPoolDefinitionIF cpd,
                               SnapshotIF snapshot,
                               java.lang.String link,
                               java.lang.String connectionId)
                        throws java.io.IOException
If we want a more detailed snapshot then #doSnapshot(javax.servlet.ServletOutputStream, org.logicalcobwebs.proxool.ConnectionPoolDefinitionIF, String, String, String) calls this too

Parameters:
out - where to write the HTML
cpd - defines the pool
snapshot - snapshot
link - the URL back to this servlet
connectionId - the connection we want to drill into (optional)
connectionId -
Throws:
java.io.IOException

getStatusClass

private static java.lang.String getStatusClass(ConnectionInfoIF info)
What CSS class to use for a particular connection.

Parameters:
info - so we know the ConnectionInfoIF.getStatus() status
Returns:
the CSS class
See Also:
STATUS_CLASSES

doDrillDownConnection

private void doDrillDownConnection(ServletOutputStream out,
                                   ConnectionInfoIF drillDownConnection)
                            throws java.io.IOException
Throws:
java.io.IOException

openHtml

private void openHtml(ServletOutputStream out)
               throws java.io.IOException
Throws:
java.io.IOException

closeHtml

private void closeHtml(ServletOutputStream out)
                throws java.io.IOException
Throws:
java.io.IOException

openDataTable

private void openDataTable(ServletOutputStream out)
                    throws java.io.IOException
Throws:
java.io.IOException

closeTable

private void closeTable(ServletOutputStream out)
                 throws java.io.IOException
Throws:
java.io.IOException

printDefinitionEntry

private void printDefinitionEntry(ServletOutputStream out,
                                  java.lang.String name,
                                  java.lang.String value,
                                  java.lang.String type)
                           throws java.io.IOException
Throws:
java.io.IOException

doList

private void doList(ServletOutputStream out,
                    java.lang.String alias,
                    java.lang.String tab,
                    java.lang.String link)
             throws java.io.IOException
Output the list of available connection pools. If there are none then display a message saying that. If there is only one then just display nothing (and the pool will displayed by default)

Parameters:
out - where to write the HTML
alias - identifies the current pool
tab - identifies the tab we are on so that changing pools doesn't change the tab
link - the URL back to this servlet
Throws:
java.io.IOException

formatMilliseconds

private java.lang.String formatMilliseconds(int time)
Express time in an easy to read HH:mm:ss format

Parameters:
time - in milliseconds
Returns:
time (e.g. 180000 = 00:30:00)
See Also:
TIME_FORMAT