org.glassfish.gmbal.generic
Interface MethodMonitor
public interface MethodMonitor
General interface used to add observability to method execution.
This may be used for many purposes, for example:
- Logging information about method calls.
- Collecting timing information.
- Collecting context information to use in constructing error logs.
Note that tools like DTrace and btrace (and glassfish probes) can
provide most of this capability at less cost in programming. However,
there are some advantages to this approach:
- This approach provides a very fine grained approach that can easily
accommodate very specific semantic knowledge about the code under test.
For example, not every argument should be logged by using toString().
Sometines another method (e.g. name()) should be used instead to identify
a particular argument.
- Placing info call at intermediate points is sometimes
helpful as well, otherwise every significant decision point in the code
must be encapsulated in a single method. While small methods are good,
sometimes a slightly larger method is a reasonable choice.
- This approach can be used to enable a program to reason about its
own behavior, unlike an external tool.
- This approach is very lightweight, unlike typical AOP frameworks.
Obviously there are some disadvantages as well. This includes some runtime
overhead (small if no action is registered), as well as the extra effort
in putting such calls in all of the appropriate points. However, there
are too many cases (IIOP marshalling, portable interceptors, the
Gmbal typelib) where detailed, carefully-controlled logging is the only
effective way to diagnose complex problems.
- Author:
- Ken Cavanaugh
|
Method Summary |
void |
clear()
Clear any accummulated data. |
void |
enter(boolean enabled,
String name,
Object... args)
Make information about the beginning of a method available. |
void |
exit(boolean enabled)
Indicate that the current method has finished with no result. |
void |
exit(boolean enabled,
Object result)
Indicate that the current method has finished with a result. |
void |
info(boolean enabled,
Object... args)
Information to accummulate about the current method. |
enter
void enter(boolean enabled,
String name,
Object... args)
- Make information about the beginning of a method available.
- Parameters:
enabled - Indicates whether or not data collection is enabled.
Some implementations may choose to ignore this.name - The name of the method.args - Some or all of the arguments passed to the method.
info
void info(boolean enabled,
Object... args)
- Information to accummulate about the current method.
- Parameters:
args - The data to accummulate.
exit
void exit(boolean enabled)
- Indicate that the current method has finished with no result.
exit
void exit(boolean enabled,
Object result)
- Indicate that the current method has finished with a result.
- Parameters:
result - The result of this method call.
clear
void clear()
- Clear any accummulated data.
Copyright © 2005-2015 Oracle Corporation. All Rights Reserved.