Java Doc for CustomizableTraceInterceptor.java in  » J2EE » spring-framework-2.0.6 » org » springframework » aop » interceptor » 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 » J2EE » spring framework 2.0.6 » org.springframework.aop.interceptor 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   org.springframework.aop.interceptor.AbstractTraceInterceptor
      org.springframework.aop.interceptor.CustomizableTraceInterceptor

CustomizableTraceInterceptor
public class CustomizableTraceInterceptor extends AbstractTraceInterceptor (Code)
MethodInterceptor implementation that allows for highly customizable method-level tracing, using placeholders.

Trace messages are written on method entry, and if the method invocation succeeds on method exit. If an invocation results in an exception, then an exception message is written. The contents of these trace messages is fully customizable and special placeholders are available to allow you to include runtime information in your log messages. The placeholders available are:

  • $[methodName] - replaced with the name of the method being invoked
  • $[targetClassName] - replaced with the name of the class that is the target of the invocation
  • $[targetClassShortName] - replaced with the short name of the class that is the target of the invocation
  • $[returnValue] - replaced with the value returned by the invocation
  • $[argumentTypes] - replaced with a comma-separated list of the short class names of the method arguments
  • $[arguments] - replaced with a comma-separated list of the String representation of the method arguments
  • $[exception] - replaced with the String representation of any Throwable raised during the invocation
  • $[invocationTime] - replaced with the time, in milliseconds, taken by the method invocation

There are restrictions on which placeholders can be used in which messages: see the individual message properties for details on the valid placeholders.

NOTE: This class requires JDK 1.4 or later. It uses the java.util.regex package for regular expression matching, which is only available on JDK 1.4+.
author:
   Rob Harrop
since:
   1.2
See Also:   CustomizableTraceInterceptor.setEnterMessage
See Also:   CustomizableTraceInterceptor.setExitMessage
See Also:   CustomizableTraceInterceptor.setExceptionMessage
See Also:   SimpleTraceInterceptor



Field Summary
final public static  StringPLACEHOLDER_ARGUMENTS
     The $[arguments] placeholder. Replaced with a comma separated list of the argument values for the method invocation.
final public static  StringPLACEHOLDER_ARGUMENT_TYPES
     The $[argumentTypes] placeholder. Replaced with a comma-separated list of the argument types for the method invocation.
final public static  StringPLACEHOLDER_EXCEPTION
     The $[exception] placeholder.
final public static  StringPLACEHOLDER_INVOCATION_TIME
     The $[invocationTime] placeholder.
final public static  StringPLACEHOLDER_METHOD_NAME
     The $[methodName] placeholder.
final public static  StringPLACEHOLDER_RETURN_VALUE
     The $[returnValue] placeholder.
final public static  StringPLACEHOLDER_TARGET_CLASS_NAME
     The $[targetClassName] placeholder.
final public static  StringPLACEHOLDER_TARGET_CLASS_SHORT_NAME
     The $[targetClassShortName] placeholder.


Method Summary
protected  ObjectinvokeUnderTrace(MethodInvocation invocation, Log logger)
     Writes a log message before the invocation based on the value of enterMessage. If the invocation succeeds, then a log message is written on exit based on the value exitMessage.
protected  StringreplacePlaceholders(String message, MethodInvocation methodInvocation, Object returnValue, Throwable throwable, long invocationTime)
     Replace the placeholders in the given message with the supplied values, or values derived from those supplied.
Parameters:
  message - the message template containing the placeholders to be replaced
Parameters:
  methodInvocation - the MethodInvocation being logged.Used to derive values for all placeholders except $[exception]and $[returnValue].
Parameters:
  returnValue - any value returned by the invocation.Used to replace the $[returnValue] placeholder.
public  voidsetEnterMessage(String enterMessage)
     Ses the template used for method entry log messages.
public  voidsetExceptionMessage(String exceptionMessage)
     Set the template used for method exception log messages.
public  voidsetExitMessage(String exitMessage)
     Set the template used for method exit log messages.
protected  voidwriteToLog(Log logger, String message)
     Writes the supplied message to the supplied Log instance.
protected  voidwriteToLog(Log logger, String message, Throwable ex)
     Writes the supplied message and Throwable to the supplied Log instance.

Field Detail
PLACEHOLDER_ARGUMENTS
final public static String PLACEHOLDER_ARGUMENTS(Code)
The $[arguments] placeholder. Replaced with a comma separated list of the argument values for the method invocation. Relies on the toString() method of each argument type.



PLACEHOLDER_ARGUMENT_TYPES
final public static String PLACEHOLDER_ARGUMENT_TYPES(Code)
The $[argumentTypes] placeholder. Replaced with a comma-separated list of the argument types for the method invocation. Argument types are written as short class names.



PLACEHOLDER_EXCEPTION
final public static String PLACEHOLDER_EXCEPTION(Code)
The $[exception] placeholder. Replaced with the String representation of any Throwable raised during method invocation.



PLACEHOLDER_INVOCATION_TIME
final public static String PLACEHOLDER_INVOCATION_TIME(Code)
The $[invocationTime] placeholder. Replaced with the time taken by the invocation (in milliseconds).



PLACEHOLDER_METHOD_NAME
final public static String PLACEHOLDER_METHOD_NAME(Code)
The $[methodName] placeholder. Replaced with the name of the method being invoked.



PLACEHOLDER_RETURN_VALUE
final public static String PLACEHOLDER_RETURN_VALUE(Code)
The $[returnValue] placeholder. Replaced with the String representation of the value returned by the method invocation.



PLACEHOLDER_TARGET_CLASS_NAME
final public static String PLACEHOLDER_TARGET_CLASS_NAME(Code)
The $[targetClassName] placeholder. Replaced with the fully-qualifed name of the Class of the method invocation target.



PLACEHOLDER_TARGET_CLASS_SHORT_NAME
final public static String PLACEHOLDER_TARGET_CLASS_SHORT_NAME(Code)
The $[targetClassShortName] placeholder. Replaced with the short name of the Class of the method invocation target.





Method Detail
invokeUnderTrace
protected Object invokeUnderTrace(MethodInvocation invocation, Log logger) throws Throwable(Code)
Writes a log message before the invocation based on the value of enterMessage. If the invocation succeeds, then a log message is written on exit based on the value exitMessage. If an exception occurs during invocation, then a message is written based on the value of exceptionMessage.
See Also:   CustomizableTraceInterceptor.setEnterMessage
See Also:   CustomizableTraceInterceptor.setExitMessage
See Also:   CustomizableTraceInterceptor.setExceptionMessage



replacePlaceholders
protected String replacePlaceholders(String message, MethodInvocation methodInvocation, Object returnValue, Throwable throwable, long invocationTime)(Code)
Replace the placeholders in the given message with the supplied values, or values derived from those supplied.
Parameters:
  message - the message template containing the placeholders to be replaced
Parameters:
  methodInvocation - the MethodInvocation being logged.Used to derive values for all placeholders except $[exception]and $[returnValue].
Parameters:
  returnValue - any value returned by the invocation.Used to replace the $[returnValue] placeholder. May be null.
Parameters:
  throwable - any Throwable raised during the invocation.The value of Throwable.toString() is replaced for the$[exception] placeholder. May be null.
Parameters:
  invocationTime - the value to write in place of the$[invocationTime] placeholder the formatted output to write to the log



setEnterMessage
public void setEnterMessage(String enterMessage) throws IllegalArgumentException(Code)
Ses the template used for method entry log messages. This template can contain any of the following placeholders:
  • $[targetClassName]
  • $[targetClassShortName]
  • $[argumentTypes]
  • $[arguments]

throws:
  IllegalArgumentException - if the message template is emptyor contains any invalid placeholders



setExceptionMessage
public void setExceptionMessage(String exceptionMessage)(Code)
Set the template used for method exception log messages. This template can contain any of the following placeholders:
  • $[targetClassName]
  • $[targetClassShortName]
  • $[argumentTypes]
  • $[arguments]
  • $[exception]

throws:
  IllegalArgumentException - if the message template is emptyor contains any invalid placeholders



setExitMessage
public void setExitMessage(String exitMessage)(Code)
Set the template used for method exit log messages. This template can contain any of the following placeholders:
  • $[targetClassName]
  • $[targetClassShortName]
  • $[argumentTypes]
  • $[arguments]
  • $[returnValue]
  • $[invocationTime]

throws:
  IllegalArgumentException - if the message template is emptyor contains any invalid placeholders



writeToLog
protected void writeToLog(Log logger, String message)(Code)
Writes the supplied message to the supplied Log instance.
See Also:   CustomizableTraceInterceptor.writeToLog(org.apache.commons.logging.Log,String,Throwable)



writeToLog
protected void writeToLog(Log logger, String message, Throwable ex)(Code)
Writes the supplied message and Throwable to the supplied Log instance. By default messages are written at TRACE level. Sub-classes can override this method to control which level the message is written at.



Fields inherited from org.springframework.aop.interceptor.AbstractTraceInterceptor
protected transient Log defaultLogger(Code)(Java Doc)

Methods inherited from org.springframework.aop.interceptor.AbstractTraceInterceptor
protected Log getLoggerForInvocation(MethodInvocation invocation)(Code)(Java Doc)
public Object invoke(MethodInvocation invocation) throws Throwable(Code)(Java Doc)
abstract protected Object invokeUnderTrace(MethodInvocation invocation, Log logger) throws Throwable(Code)(Java Doc)
protected boolean isInterceptorEnabled(MethodInvocation invocation, Log logger)(Code)(Java Doc)
protected boolean isLogEnabled(Log logger)(Code)(Java Doc)
public void setHideProxyClassNames(boolean hideProxyClassNames)(Code)(Java Doc)
public void setLoggerName(String loggerName)(Code)(Java Doc)
public void setUseDynamicLogger(boolean useDynamicLogger)(Code)(Java Doc)

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.