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.
author: Steve Souza version: 1.01
isEnabled() Returns the state of the enabled flag.
public static void
main(String[] args) Test code for the MonitorFactory class.
public static void
reset() Wipes out all statistics that have been gathered.
public static void
setDebugEnabled(boolean _debugEnabled) Enable or disable the debug factory.
public static void
setDebugPriorityLevel(int _debugPriorityLevel) Enable or disable the priority driven debug factory.
public static void
setEnabled(boolean _enabled) Enable or disable the factory.
public static void
setJAMonAdminPage(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.
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.
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 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(),...
Sample Call:
if (MonitorFactory.isEnabled())
........// Do something which only makes sence when monitoring is enabled
else
........// Do something which only makes sence when monitoring is disabled
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)(Code)
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)(Code)
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)(Code)
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(String JAMonAdminPage)(Code)
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.