com.jamonapi
Class MonitorFactory

java.lang.Object
  |
  +--com.jamonapi.MonitorFactory

public class MonitorFactory
extends java.lang.Object

MonitorFactory - Class that controls monitors including creating, starting, enabling, disabling and resetting them. This class uses the Gang of 4's creational patterns. Monitors returned by MonitorFactory are thread safe.


Constructor Summary
MonitorFactory()
           
 
Method Summary
static MonitorComposite getComposite(java.lang.String locator)
          Returns the composite monitor specified in the argument.
static MonitorFactoryInterface getDebugFactory()
          Returns the factory for creating debug monitors.
static MonitorFactoryInterface getDebugFactory(int _debugPriorityLevel)
          Returns the factory for creating debug monitors.
static java.lang.String getReport()
          Returns all gathered statistics as an HTML table as a String.
static java.lang.String getReport(java.lang.String locator)
          Returns gathered statistics underneath lower in the heirarchy than the locator string.
static MonitorComposite getRootMonitor()
          Returns the topmost Composite Monitor
static void main(java.lang.String[] args)
          Test code for the MonitorFactory class.
static void reset()
          Wipes out all statistics that have been gathered.
static void setDebugEnabled(boolean _debugEnabled)
          Enable or disable the debug factory.
static void setDebugPriorityLevel(int _debugPriorityLevel)
          Enable or disable the priority driven debug factory.
static void setEnabled(boolean _enabled)
          Enable or disable the factory.
static void setJAMonAdminPage(java.lang.String JAMonAdminPage)
          Call this method if you don't want to use the default name or location for JAMonAdmin.jsp that is returned in the JAMon report.
static Monitor start()
          Return a Monitor and begin gathering timing statistics for it.
static Monitor start(java.lang.String locator)
          Return a Monitor and begin gathering timing statistics for it.
static Monitor startPrimary(java.lang.String locator)
          Return a Monitor and begin gathering timing statistics for it.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MonitorFactory

public MonitorFactory()
Method Detail

getComposite

public static MonitorComposite getComposite(java.lang.String locator)
Returns the composite monitor specified in the argument. Composite Monitor's are groups of other monitors (including other composites).

Sample Call: String html=MonitorFactory.getComposite("pages").getReport();

Parameters:
locator - A string that locates the Composite Monitor.
Returns:
MonitorComposite

getDebugFactory

public static MonitorFactoryInterface getDebugFactory()
Returns the factory for creating debug monitors. The debug factory can be disabled independently from the regular factory. Debug monitors are no different than monitors returned by the regular monitor factory. However the debug factory can be used to monitor items in a test environment and disable them in production.

Sample Call: MonitorFactory.getDebugFactory().start();

Returns:
MonitorFactoryInterface

getDebugFactory

public static MonitorFactoryInterface getDebugFactory(int _debugPriorityLevel)
Returns the factory for creating debug monitors. The debug factory can be disabled independently from the regular factory. Debug monitors are no different than monitors returned by the regular monitor factory. However the debug factory can be used to monitor items in a test environment and disable them in production.
This method takes a priority level threshold as an argument. If the passed priority level is greater than or equal to the MonitorFactory debug priority level then a Monitor is returned or else a null Monitor is returned (no statistics will be kept).

Sample Call: MonitorFactory.getDebugFactory(20).start();
if MonitorFactory debug priority level is 10 then a non null Monitor will be returned

Returns:
MonitorFactoryInterface

getReport

public static java.lang.String getReport()
                                  throws java.lang.Exception
Returns all gathered statistics as an HTML table as a String. This can be displayed in a JSP or Servlet.

Sample Call: String html=MonitorFactory.getReport();

java.lang.Exception

getReport

public static java.lang.String getReport(java.lang.String locator)
                                  throws java.lang.Exception
Returns gathered statistics underneath lower in the heirarchy than the locator string. The returned String is as an HTML table as a String. This can be displayed in a JSP or Servlet.

Sample Call: String html=MonitorFactory.getReport("MyApplication.DataAccess");
This would return statistics for MyApplication.DataAccess.open(), MyApplication.DataAccess.close(),...

java.lang.Exception

getRootMonitor

public static MonitorComposite getRootMonitor()
Returns the topmost Composite Monitor


reset

public static void reset()
Wipes out all statistics that have been gathered. Subsequent calls to the start(...) methods will continue to gather statistics.

Sample Call: MonitorFactory.reset();


setDebugEnabled

public static void setDebugEnabled(boolean _debugEnabled)
Enable or disable the debug factory. The debug factory can be enabled/disabled at runtime. Calling this method with a false also disables calls to MonitorFactory.getDebugFactory(int debugPriorityLevel)

Sample Call:
MonitorFactory.setDebugEnabled(false);
MonitorFactory.getDebugFactory().start(); // no stats are gathered.
MonitorFactory.getDebugFactory(20).start(); // no stats are gathered.


setDebugPriorityLevel

public static void setDebugPriorityLevel(int _debugPriorityLevel)
Enable or disable the priority driven debug factory. The debug factory can be enabled/disabled at runtime. Calling this method with a false has no effect on MonitorFactory.getDebugFactory()

Sample Call:
MonitorFactory.setDebugEnabled(false);
MonitorFactory.getDebugFactory(20).start(); // no stats are gathered.


setEnabled

public static void setEnabled(boolean _enabled)
Enable or disable the factory. The factory can be enabled/disabled at runtime. Calling this method with a false also disables calls to both MonitorFactory.getDebugFactory(), and MonitorFactory.getDebugFactory(int debugPriorityLevel)

Sample Call:
MonitorFactory.setEnabled(false);
MonitorFactory.start(); // no stats are gathered.
MonitorFactory.start("MyApp.DataAccess.open()"); // no stats are gathered.
MonitorFactory.getDebugFactory().start(); // no stats are gathered.
MonitorFactory.getDebugFactory(20).start(); // no stats are gathered.


setJAMonAdminPage

public static void setJAMonAdminPage(java.lang.String JAMonAdminPage)
Call this method if you don't want to use the default name or location for JAMonAdmin.jsp that is returned in the JAMon report.


start

public static Monitor start(java.lang.String locator)
Return a Monitor and begin gathering timing statistics for it.

Sample Call:
Monitor mon=MonitorFactory.start("MyApp.DataAccess.open()");
...code being monitored...
System.out.println(mon.stop());


start

public static Monitor start()
Return a Monitor and begin gathering timing statistics for it. Statistics for this start() method will not be returned by MonitorFactory.getReport()

Sample Call:
Monitor mon=MonitorFactory.start();
...code being monitored...
System.out.println(mon.stop());


startPrimary

public static Monitor startPrimary(java.lang.String locator)
Return a Monitor and begin gathering timing statistics for it. See the online JAMon users manual for an explanation of this method.

Sample Call:
Monitor mon=MonitorFactory.startPrimary("MyApp.jsp.HomePage");
...code being monitored...
System.out.println(mon.stop());


main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
Test code for the MonitorFactory class.

java.lang.Exception