Java Doc for MonProxyFactory.java in  » Profiler » JAMon » com » jamonapi » proxy » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Profiler » JAMon » com.jamonapi.proxy 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   com.jamonapi.proxy.MonProxyFactory

MonProxyFactory
public class MonProxyFactory (Code)
MonProxyFactory allows developers to monitor ANY interface by simply passing the Object implementing the interface to the monitor method. (note the object passed MUST implement an interface or it will be a runtime error). A great use of this is to monitor jdbc interfaces and to aid in this there are overloaded methods that take Connections, Statements, PreparedStatements, CallableStatements, and ResultSets. These overloaded methods take advantage of knowledege of SQL and track additional statistics. The following capabilities can be acquired by using MonProxyFactory. All can individually be enabled/disabled. 0) Overall monitoring can be enabled/disabled by calling MonProxyFactory.enable(...). This will enable/disable monitors. You can start out by enabling all monitors and disabling the ones you wish or vice versa. 1) All methods of a given interface will have a jamon rows. Any jamon row will have the label (in this case the method signature), hits, avg/min/max execution time, active/avg active/max active, last value and more. By default interface monitoring is on. It can be enabled/disabled by calling MonProxyFactory.enableInterfaceM(...). JDBC classes such as Connections, Statements, PreparedStatemetns, CallableStatements, and ResultsSets will also automatically be monitored if the class returning them was monitored. If you don't wish this to occur then you can use the monitor method that takes an Object. 2) ResultSet interfaces can be monitored however methods like getObject and next are called so much and typically don't cause performance problems, so there is a seperate enable/disable capability for them. Note for ResultSet monitoring to occur interface monitoring must also be enabled. However it can be enabled if interface monitoring is enabled and MonProxyFactory.enabledResultSets(true) is called. ResultSet's are by default not monitored. 3) SQLSummary will add a jamon row for all sql text issued against a PreparedStatement, CallableStatement, or Statement. Argument values are replaced with ? for Statements to ensure the logical queries are matched. PreparedStatements need not be changed to do this, but Statements may look a little different For example: select * from table where name='jeff beck' would become select * from table where name=? This is a powerful monitor as it allows you to see hits, avg/min/max query times for all queries in your application. This is enabled/disabled by calling MonProxyFactory.enableSQLSummary(...). 4) SQLDetail puts the last N (configurable) queries that have been run into a rolling buffer. The SQL buffer will have the actual query in the case of a Statement and the version with ? for PreparedStatements. In addition other stats will be in this buffer such as how long the query took to execute, how many times has the PreparedStatement been reused, the jdbc method that executed the sql, and the exception stack trace if it occured. This can be enabled/disabled by calling MonProxyFactory.enableSQLDetail(...) 5) Exception Summary will add several jamon rows when an exception occurs. Note the Exception buffer is used for any kind of Exception including SQLExceptions. The exceptions added are 1. One containing the method that through the exception as well as the exception. 2. One indicating how many exceptions total have been thrown through proxies, 3) One containing the exception type that was thrown. This can be enabled/disabled by calling MonProxyFactory.enableExceptionSummary(...) 6) ExceptionDetail puts the last N (configurable) exceptions that have occured to any interface that is being monitored into a buffer. The stack trace is in the row as well as when it was thrown and what method threw it. This can be enabled/disabled by calling MonProxyFactory.enableExceptionDetail(...). Sample code: ResultSet rs= MonProxyFactory.monitor(resultSet); Connection conn=MonProxyFactory.monitor(connection); MyInterface my=(MyInterface) MonProxyFactory.monitor(myObject);//myObject implements MyInterface YourInterface your=(YourInterface) MonProxyFactory.monitor(yourObject);//myObject implements MyInterface
author:
   steve souza




Method Summary
public static  voidenable(boolean enable)
     Enables all monitors except ResultSet monitoring.
public static  voidenableAll(boolean enable)
     Enables all monitors.
public static  voidenableExceptionDetail(boolean enable)
    
public static  voidenableExceptionSummary(boolean enable)
    
public static  voidenableInterface(boolean enable)
    
public static  voidenableResultSet(boolean enable)
     Enables/disables whether ResultSet methods are monitored.
public static  voidenableSQLDetail(boolean enable)
    
public static  voidenableSQLSummary(boolean enable)
    
public static  intgetExceptionBufferSize()
     Get the number of Exceptions that can be stored in the buffer before the oldest entries must be removed.
public static  Object[][]getExceptionDetail()
    
public static  String[]getExceptionDetailHeader()
    
public static  Class[]getInterfaces(Class cls)
     For every class in the Object/Interface heirarchy find its implemented interfaces.
public static  ListgetMatchStrings()
     Get a list of the strings to match in the parsed query.
static  ParamsgetParams()
    
public static  intgetSQLBufferSize()
     Get the number of SQL statements that can be stored in the buffer before the oldest entries must be removed.
public static  Object[][]getSQLDetail()
    
public static  String[]getSQLDetailHeader()
    
public static  booleanisAllEnabled()
    
public static  booleanisEnabled()
     Returns true if MonProxyFactory is enabled.
public static  booleanisExceptionDetailEnabled()
    
public static  booleanisExceptionSummaryEnabled()
    
public static  booleanisInterfaceEnabled()
    
public static  booleanisResultSetEnabled()
     Indicates whether ResultSet methods are monitored.
public static  booleanisSQLDetailEnabled()
    
public static  booleanisSQLSummaryEnabled()
    
public static  Objectmonitor(Object object)
     By passing any interface to the monitor method, all public method calls and exceptions will be monitored.
public static  Objectmonitor(Object object, Class[] interfaces)
     By passing any interface to the monitor method, and an array of interfaces to implement then all public method calls and exceptions will be monitored.
public static  Objectmonitor(Object object, Class iface)
     By passing any interface to the monitor method, and an interface to implement then all public method calls and exceptions will be monitored.
public static  Connectionmonitor(Connection conn)
     Note if a connection object is monitored any Statements, PreparedStatements, CallableStatements, and optionally ResultSets that it creates will automatically be monitored.
public static  ResultSetmonitor(ResultSet rs)
     Monitor a resultSets methods.
public static  Statementmonitor(Statement statement)
    
public static  PreparedStatementmonitor(PreparedStatement statement)
    
public static  CallableStatementmonitor(CallableStatement statement)
    
static  ObjectmonitorJDBC(Object object)
    
public static  voidresetExceptionDetail()
     Remove all Exceptions from the buffer.
public static  voidresetSQLDetail()
     Remove all SQL from the buffer.
public static  voidsetExceptionBufferSize(int exceptionBufferSize)
     Set the number of Exceptions that can be stored in the buffer before the oldest entries must be removed.
public static  voidsetMatchStrings(List ms)
    
public static  voidsetSQLBufferSize(int sqlBufferSize)
     Set the number of SQL Statements that can be stored in the buffer before the oldest entries must be removed.



Method Detail
enable
public static void enable(boolean enable)(Code)
Enables all monitors except ResultSet monitoring. This overrides all other monitor booleans. It never enables ResultSet monitoring That must be done as a separates step as that is not the enabled monitoring by default. All other monitors will be disabled/enabled when calling this method.



enableAll
public static void enableAll(boolean enable)(Code)
Enables all monitors. This overrides all other monitor booleans. It never enables ResultSet monitoring That must be done as a separates step as that is not the enabled monitoring by default. All other monitors will be disabled/enabled when calling this method.



enableExceptionDetail
public static void enableExceptionDetail(boolean enable)(Code)
Enables/Disables whether exceptions are tracked in a rolling buffer



enableExceptionSummary
public static void enableExceptionSummary(boolean enable)(Code)
Enables/disables jamon summary stats for exceptions



enableInterface
public static void enableInterface(boolean enable)(Code)
Enables/disables whether methods of the interface are monitored or not



enableResultSet
public static void enableResultSet(boolean enable)(Code)
Enables/disables whether ResultSet methods are monitored. Note interface monitoring must also be enabled for ResultSet monitoring to occur



enableSQLDetail
public static void enableSQLDetail(boolean enable)(Code)
Enables/disables whether sql command details (time, sql, stack trace, ...) are kept in a rolling buffer



enableSQLSummary
public static void enableSQLSummary(boolean enable)(Code)
Enables/Disables jamon summary stats for SQL



getExceptionBufferSize
public static int getExceptionBufferSize()(Code)
Get the number of Exceptions that can be stored in the buffer before the oldest entries must be removed.



getExceptionDetail
public static Object[][] getExceptionDetail()(Code)
Get the exception buffer as an array, so it can be displayed



getExceptionDetailHeader
public static String[] getExceptionDetailHeader()(Code)
Get the header that can be used to display the Exceptions buffer



getInterfaces
public static Class[] getInterfaces(Class cls)(Code)
For every class in the Object/Interface heirarchy find its implemented interfaces. All interfaces this class implements are returned. Either the Class of an Object or interfaces Class may be passed to this method. The difference between this method and the method 'Class.getInterfaces()' is that this one returns ALL implemented interfaces whereas that one only returns interfaces that are directly implemented by the Class.



getMatchStrings
public static List getMatchStrings()(Code)
Get a list of the strings to match in the parsed query. This can be used to count tables hits and times of queries that hit them for example



getParams
static Params getParams()(Code)



getSQLBufferSize
public static int getSQLBufferSize()(Code)
Get the number of SQL statements that can be stored in the buffer before the oldest entries must be removed.



getSQLDetail
public static Object[][] getSQLDetail()(Code)
Get the sql buffer as an array, so it can be displayed



getSQLDetailHeader
public static String[] getSQLDetailHeader()(Code)
Get the header that can be used to display the SQL buffer



isAllEnabled
public static boolean isAllEnabled()(Code)



isEnabled
public static boolean isEnabled()(Code)
Returns true if MonProxyFactory is enabled.



isExceptionDetailEnabled
public static boolean isExceptionDetailEnabled()(Code)
Indicates whether exceptions are tracked in a rolling buffer



isExceptionSummaryEnabled
public static boolean isExceptionSummaryEnabled()(Code)
Indicates whether jamon summary stats are kept for exceptions



isInterfaceEnabled
public static boolean isInterfaceEnabled()(Code)
Inidicates whether methods of the interface are monitored or not



isResultSetEnabled
public static boolean isResultSetEnabled()(Code)
Indicates whether ResultSet methods are monitored. Note interface monitoring must also be enabled for ResultSet monitoring to occur



isSQLDetailEnabled
public static boolean isSQLDetailEnabled()(Code)
Indicates whether sql command details (time, sql, stack trace, ...) are kept in a rolling buffer



isSQLSummaryEnabled
public static boolean isSQLSummaryEnabled()(Code)
Indicates whether jamon summary stats are kept for SQL



monitor
public static Object monitor(Object object)(Code)
By passing any interface to the monitor method, all public method calls and exceptions will be monitored. It will be a runtime error if the Object passed does not implement an interface. Note that only interfaces implemented directly by the passed in Object are monitored. Should you want to cast to an interface implemented by a base class to the passed in Object you should call one of the more explicit monitor(..) methods Sample call: MyInterface myProxyObject=(MyInterface) MonProxyFactory.monitor(myObject);



monitor
public static Object monitor(Object object, Class[] interfaces)(Code)
By passing any interface to the monitor method, and an array of interfaces to implement then all public method calls and exceptions will be monitored. It will be a runtime error if the Object passed does not implement an interface. Sample call: MyInterface myProxyObject=(MyInterface) MonProxyFactory.monitor(myObject, ineterfaces);



monitor
public static Object monitor(Object object, Class iface)(Code)
By passing any interface to the monitor method, and an interface to implement then all public method calls and exceptions will be monitored. It will be a runtime error if the Object passed does not implement an interface. Sample call: MyInterface myProxyObject=(MyInterface) MonProxyFactory.monitor(myObject, com.mypackage.MyInterface.class);



monitor
public static Connection monitor(Connection conn)(Code)
Note if a connection object is monitored any Statements, PreparedStatements, CallableStatements, and optionally ResultSets that it creates will automatically be monitored. So for jdbc interfaces usually it will be sufficient to simply monitor the connection. You could also call MonProxyFactory.monitor((Object)conn); and the connection would be monitored however other child objects wouldn't be and recently executed sql would not be put in a buffer. The same applies to the other overloaded sql monitor(...) method calls below. For sql monitored objects to be monitored both the overall monitoring must be enabled. Monitoring rules apply as discussed in the top of this document.



monitor
public static ResultSet monitor(ResultSet rs)(Code)
Monitor a resultSets methods. Note the version that takes an explicit class is used for when the class is a proxy



monitor
public static Statement monitor(Statement statement)(Code)
Monitor a Statements methods, as well as any ResultSets it returns (assuming the proper monitoring options are enabled)



monitor
public static PreparedStatement monitor(PreparedStatement statement)(Code)
Monitor a PreparedStatements methods, as well as any ResultSets it returns (assuming the proper monitoring options are enabled)



monitor
public static CallableStatement monitor(CallableStatement statement)(Code)
Monitor a CallableStatements methods, as well as any ResultSets it returns (assuming the proper monitoring options are enabled)



monitorJDBC
static Object monitorJDBC(Object object)(Code)



resetExceptionDetail
public static void resetExceptionDetail()(Code)
Remove all Exceptions from the buffer.



resetSQLDetail
public static void resetSQLDetail()(Code)
Remove all SQL from the buffer.



setExceptionBufferSize
public static void setExceptionBufferSize(int exceptionBufferSize)(Code)
Set the number of Exceptions that can be stored in the buffer before the oldest entries must be removed. A value of 0 will disable collecting of Exceptions in the buffer.



setMatchStrings
public static void setMatchStrings(List ms)(Code)
Set the strings to match



setSQLBufferSize
public static void setSQLBufferSize(int sqlBufferSize)(Code)
Set the number of SQL Statements that can be stored in the buffer before the oldest entries must be removed. A value of 0 will disable the collection of Exceptions in the buffer. Note if monitoring is disabled exceptions will also not be put in the buffer.



Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.