[Proxool-cvs] proxool/src/java/org/logicalcobwebs/proxool/admin/servlet AdminServlet.java,1.11,1.12
UNMAINTAINED!
Brought to you by:
billhorsman
From: <bil...@us...> - 2005-10-07 08:23:19
|
Update of /cvsroot/proxool/proxool/src/java/org/logicalcobwebs/proxool/admin/servlet In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15624/src/java/org/logicalcobwebs/proxool/admin/servlet Modified Files: AdminServlet.java Log Message: Doc Index: AdminServlet.java =================================================================== RCS file: /cvsroot/proxool/proxool/src/java/org/logicalcobwebs/proxool/admin/servlet/AdminServlet.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** AdminServlet.java 2 Oct 2005 09:45:49 -0000 1.11 --- AdminServlet.java 7 Oct 2005 08:23:10 -0000 1.12 *************** *** 31,35 **** * servlet., so just configure it within your web app as you see fit. * For example, within web.xml: - * <p/> * <pre> * <servlet> --- 31,34 ---- *************** *** 45,55 **** * </init-param> * </servlet> - * <p/> * <servlet-mapping> * <servlet-name>Admin</servlet-name> ! * <url-pattern>/admin</url-pattern> * </servlet-mapping> * </pre> * * @author bill * @author $Author$ (current maintainer) --- 44,65 ---- * </init-param> * </servlet> * <servlet-mapping> * <servlet-name>Admin</servlet-name> ! * <url-pattern>/proxool</url-pattern> * </servlet-mapping> * </pre> * + * Options: + * <ul> + * <li>output: full|simple. "full" means with HTML header and body tags "simple" means + * just the HTML. Choose "simple" if you are including this servlet within your own + * web page. Note that if you choose simple output then you're probably going to want + * to consider supplying some CSS to make it look nice.</li> + * <li>cssFile: If you choose full output (see above) then some CSS is included, inline, + * in the HTML header. If you specify a URL here then that file is also linked to. It is + * linked after the inline CSS so you only have to override thos styles you want to be + * different.</li> + * </ul> + * * @author bill * @author $Author$ (current maintainer) *************** *** 61,81 **** private static final Log LOG = LogFactory.getLog(AdminServlet.class); private static final String[] STATUS_CLASSES = {"null", "available", "active", "offline"}; ! protected static final String TYPE = "type"; ! protected static final String TYPE_CONNECTIONS = "1"; ! protected static final String TYPE_ACTIVITY_LEVEL = "2"; ! public static final String OUTPUT_FULL = "full"; public static final String OUTPUT_SIMPLE = "simple"; private String output; private String cssFile; private static final String STATISTIC = "statistic"; private static final String CORE_PROPERTY = "core-property"; private static final String STANDARD_PROPERTY = "standard-property"; private static final String DELEGATED_PROPERTY = "delegated-property"; private static final String SNAPSHOT = "snapshot"; --- 71,135 ---- private static final Log LOG = LogFactory.getLog(AdminServlet.class); + /** + * The CSS class for a connection in different states: + * <ul> + * <li>null</li> + * <li>available</li> + * <li>active</li> + * <li>offline</li> + * </ul> + */ private static final String[] STATUS_CLASSES = {"null", "available", "active", "offline"}; ! /** ! * OUtput full HTML including <HTML>, <HEAD> and <BODY> tags. ! * @see #output ! * @see AdminServlet configuration ! */ public static final String OUTPUT_FULL = "full"; + /** + * OUtput simple HTML <em>excluding</em> <HTML>, <HEAD> and <BODY> tags. + * @see #output + * @see AdminServlet configuration + */ public static final String OUTPUT_SIMPLE = "simple"; + /** + * Either {@link #OUTPUT_FULL} (default) or {@link #OUTPUT_SIMPLE} + * @see AdminServlet configuration + */ private String output; + /** + * A valid URLL that can be linked to to override default, inline CSS. + * @see AdminServlet configuration + */ + private String cssFile; + + /** + * Used as part of the CSS class + */ private static final String STATISTIC = "statistic"; + + /** + * Used as part of the CSS class + */ private static final String CORE_PROPERTY = "core-property"; + + /** + * Used as part of the CSS class + */ private static final String STANDARD_PROPERTY = "standard-property"; + + /** + * Used as part of the CSS class + */ private static final String DELEGATED_PROPERTY = "delegated-property"; + + /** + * Used as part of the CSS class + */ private static final String SNAPSHOT = "snapshot"; *************** *** 105,130 **** /** * HH:mm:ss - * * @see #formatMilliseconds */ private static final DateFormat TIME_FORMAT = new SimpleDateFormat("HH:mm:ss"); private static final DateFormat DATE_FORMAT = new SimpleDateFormat("dd-MMM-yyyy HH:mm:ss"); private static final DecimalFormat DECIMAL_FORMAT = new DecimalFormat("0.00"); private static final String DETAIL = "detail"; private static final String DETAIL_MORE = "more"; private static final String DETAIL_LESS = "less"; private static final String TAB = "tab"; private static final String TAB_DEFINITION = "definition"; private static final String TAB_SNAPSHOT = "snapshot"; private static final String TAB_STATISTICS = "statistics"; private static final String ALIAS = "alias"; private static final String CONNECTION_ID = "id"; protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doGet(request, response); } protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { --- 159,224 ---- /** * HH:mm:ss * @see #formatMilliseconds */ private static final DateFormat TIME_FORMAT = new SimpleDateFormat("HH:mm:ss"); + /** + * dd-MMM-yyyy HH:mm:ss + */ private static final DateFormat DATE_FORMAT = new SimpleDateFormat("dd-MMM-yyyy HH:mm:ss"); private static final DecimalFormat DECIMAL_FORMAT = new DecimalFormat("0.00"); + private static final String DETAIL = "detail"; private static final String DETAIL_MORE = "more"; private static final String DETAIL_LESS = "less"; + + /** + * The request parameter name that defines: + * <ol> + * <li>{@link #TAB_DEFINITION} (default)</li> + * <li>{@link #TAB_SNAPSHOT}</li> + * <li>{@link #TAB_STATISTICS}</li> + * </ol> + */ private static final String TAB = "tab"; + + /** + * @see #TAB + */ private static final String TAB_DEFINITION = "definition"; + + /** + * @see #TAB + */ private static final String TAB_SNAPSHOT = "snapshot"; + + /** + * @see #TAB + */ private static final String TAB_STATISTICS = "statistics"; + + /** + * The request parameter name that defines the pool + */ private static final String ALIAS = "alias"; + + /** + * If we are drilling down into a connection (on the {@link #TAB_SNAPSHOT snapshot} tab then + * this points to the {@link org.logicalcobwebs.proxool.ProxyConnection#getId() ID} we are + * getting detailed information for. + */ private static final String CONNECTION_ID = "id"; + /** + * Delegate to {@link #doGet(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)} + */ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doGet(request, response); } + /** + * Show the details for a pool. + */ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { *************** *** 206,209 **** --- 300,312 ---- } + /** + * Output the tabs that we are showing at the top of the page + * @param out where to write the HTNL to + * @param alias the current pool + * @param link the URL to get back to this servlet + * @param tab the active tab + * @param statisticsAvailable whether statistics are available (true if configured and ready) + * @param statisticsComingSoon whether statistics will be available (true if configured but not ready yet) + */ private void doTabs(ServletOutputStream out, String alias, String link, String tab, boolean statisticsAvailable, boolean statisticsComingSoon) throws IOException { out.println("<ul>"); *************** *** 218,221 **** --- 321,330 ---- } + /** + * Output the statistics. If there are more than one set of statistics then show them all. + * @param out where to write HTML to + * @param statisticsArray the statistics we have ready to see + * @param cpd defines the connection + */ private void doStatistics(ServletOutputStream out, StatisticsIF[] statisticsArray, ConnectionPoolDefinitionIF cpd) throws IOException { *************** *** 253,256 **** --- 362,372 ---- } + /** + * We can draw a bar chart simply enough. The two arrays passed as parameters must be of equal length + * @param out where to write the HTML + * @param colours the colur (CSS valid string) for each segment + * @param 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. + */ private void drawBarChart(StringBuffer out, String[] colours, int[] lengths) { out.append("<table style=\"margin: 8px; font-size: 50%;\" width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr>"); *************** *** 277,283 **** --- 393,407 ---- } + /** + * Output the {@link ConnectionPoolDefinitionIF definition} + * @param out where to write the HTML + * @param cpd the definition + */ private void doDefinition(ServletOutputStream out, ConnectionPoolDefinitionIF cpd) throws IOException { openDataTable(out); + /* + TODO: it would be nice to have meta-data in the definition so that this is much easier. + */ printDefinitionEntry(out, ProxoolConstants.ALIAS, cpd.getAlias(), CORE_PROPERTY); printDefinitionEntry(out, ProxoolConstants.DRIVER_URL, cpd.getUrl(), CORE_PROPERTY); *************** *** 318,321 **** --- 442,446 ---- printDefinitionEntry(out, ProxoolConstants.VERBOSE, String.valueOf(cpd.isVerbose()), STANDARD_PROPERTY); printDefinitionEntry(out, ProxoolConstants.TRACE, String.valueOf(cpd.isTrace()), STANDARD_PROPERTY); + // Now all the properties that are forwarded to the delegate driver. Properties p = cpd.getDelegateProperties(); Iterator i = p.keySet().iterator(); *************** *** 323,326 **** --- 448,452 ---- String name = (String) i.next(); String value = p.getProperty(name); + // Better hide the password! if (name.toLowerCase().indexOf("password") > -1 || name.toLowerCase().indexOf("passwd") > -1) { value = "******"; *************** *** 333,336 **** --- 459,470 ---- } + /** + * Output a {@link SnapshotIF snapshot} of the pool. + * @param out where to write the HTML + * @param cpd defines the pool + * @param link the URL back to this servlet + * @param level either {@link #DETAIL_LESS} or {@link #DETAIL_MORE} + * @param connectionId the connection we want to drill into (optional) + */ private void doSnapshot(ServletOutputStream out, ConnectionPoolDefinitionIF cpd, String link, String level, String connectionId) throws IOException, ProxoolException { boolean detail = (level != null && level.equals(DETAIL_MORE)); *************** *** 427,430 **** --- 561,575 ---- } + /** + * If we want a {@link #DETAIL_MORE more} detailed {@link SnapshotIF snapshot} then {@link #doSnapshot(javax.servlet.ServletOutputStream, org.logicalcobwebs.proxool.ConnectionPoolDefinitionIF, String, String, String)} + * calls this too + * @param out where to write the HTML + * @param cpd defines the pool + * @param snapshot snapshot + * @param link the URL back to this servlet + * @param connectionId the connection we want to drill into (optional) + * @param connectionId + * @throws IOException + */ private void doSnapshotDetails(ServletOutputStream out, ConnectionPoolDefinitionIF cpd, SnapshotIF snapshot, String link, String connectionId) throws IOException { *************** *** 534,537 **** --- 679,688 ---- } + /** + * What CSS class to use for a particular connection. + * @param info so we know the {@link org.logicalcobwebs.proxool.ConnectionInfoIF#getStatus()} status + * @return the CSS class + * @see #STATUS_CLASSES + */ private static String getStatusClass(ConnectionInfoIF info) { try { *************** *** 545,553 **** private void doDrillDownConnection(ServletOutputStream out, ConnectionInfoIF drillDownConnection) throws IOException { ! // proxy ! if (drillDownConnection.getLastSqlCall() != null) { out.print("<div class=\"drill-down\">"); out.print("sql = "); ! out.print(drillDownConnection.getLastSqlCall()); out.print("</div>"); } --- 696,706 ---- private void doDrillDownConnection(ServletOutputStream out, ConnectionInfoIF drillDownConnection) throws IOException { ! // sql calls ! String[] sqlCalls = drillDownConnection.getSqlCalls(); ! for (int i = 0; sqlCalls != null && i < sqlCalls.length; i++) { ! String sqlCall = sqlCalls[i]; out.print("<div class=\"drill-down\">"); out.print("sql = "); ! out.print(sqlCall); out.print("</div>"); } *************** *** 634,637 **** --- 787,798 ---- } + /** + * 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) + * @param out where to write the HTML + * @param alias identifies the current pool + * @param tab identifies the tab we are on so that changing pools doesn't change the tab + * @param link the URL back to this servlet + */ private void doList(ServletOutputStream out, String alias, String tab, String link) throws IOException { *************** *** 679,682 **** --- 840,846 ---- Revision history: $Log$ + Revision 1.12 2005/10/07 08:23:10 billhorsman + Doc + Revision 1.11 2005/10/02 09:45:49 billhorsman Layout |