Package org.glassfish.pfl.tf.spi
Class MethodMonitorRegistry
java.lang.Object
org.glassfish.pfl.tf.spi.MethodMonitorRegistry
Main class for registering MethodMonitorFactories against particular
annotation classes that represent method monitor groups. This
- Author:
- ken
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidclear(Class<? extends Annotation> annot) Remove the MethodMonitorFactory (if any) that is associated with annot.static intgetMethodIdentifier(Class<?> cls, String mname) static MethodMonitorgetMethodMonitorForClass(Class<?> cls, Class<? extends Annotation> annot) Return the current MethodMonitor in use for the given cls and annot.static StringgetMethodName(Class<?> cls, int identifier) Provided so that implementation of the MethodMonitor interface can obtain the method name for use in log reports or for other purposes.getMethodNames(Class<?> cls) getTimerNames(Class<?> cls) static List<TimingPointType> getTimerTypes(Class<?> cls) Return a list of all timer types defined for cls.static MethodMonitormerge(MethodMonitor[] mms) Merges the behaviors of the method monitors together.static voidregister(Class<? extends Annotation> annot, MethodMonitorFactory mmf) Register a particular MethodMonitorFactory against an annotation.static voidregisterAnnotationFile(String fname) static voidregisterClass(Class<?> cls) Register a class with the tracing facility.static voidregisterClass(Class<?> cls, List<String> methodNames, Map<Class<? extends Annotation>, SynchronizedHolder<MethodMonitor>> annoMM) Register a class with the tracing facility.static MethodMonitorFactoryregisteredFactory(Class<? extends Annotation> annot) Return the MethodMonitorFactory registered against the annotation, or null if nothing is registered.
-
Constructor Details
-
MethodMonitorRegistry
public MethodMonitorRegistry()
-
-
Method Details
-
merge
Merges the behaviors of the method monitors together. -
getMMAnnotations
-
registerAnnotationFile
-
registerClass
public static void registerClass(Class<?> cls, List<String> methodNames, Map<Class<? extends Annotation>, SynchronizedHolder<MethodMonitor>> annoMM) Register a class with the tracing facility. The class must be an instrumented class that is annotated with an annotation with a meta-annotation of @MethodMonitorGroup. Note that this method should only be called from the enhanced class, not directly by the user.- Parameters:
cls- Class to register, which must have 1 or more MM annotations.methodNames- The list of method names used in the enhanced code. The index of the name is the value used in the method.annoMM- The MM holders for each MM annotation on the class.
-
registerClass
Register a class with the tracing facility. This form assumes that all of the computation for method names and the mapping from annotation name to MM holder is done at registration time, rather than in the bytecode enhancer. This shortens the generated bytecode noticeably.- Parameters:
cls-
-
getMethodNames
-
getMethodName
Provided so that implementation of the MethodMonitor interface can obtain the method name for use in log reports or for other purposes.- Parameters:
cls- The enhanced classidentifier- An Integer representing the method name.- Returns:
- The name of the method corresponding to the identifier.
-
getMethodIdentifier
-
register
Register a particular MethodMonitorFactory against an annotation. Annot must be annotated with the MethodMonitorGroup meta-annotation. Only a single mmf may be registered against an annotation. A subsequent register call overwrites the registered annotation. Annot must not be null.- Parameters:
annot-mmf-
-
clear
Remove the MethodMonitorFactory (if any) that is associated with annot.- Parameters:
annot-
-
registeredFactory
Return the MethodMonitorFactory registered against the annotation, or null if nothing is registered.- Parameters:
annot- A class representing an annotation, which must itself have a MethodMonitorGroup meta-annotation.- Returns:
- The MethodMonitorFactory for annot.
-
getMethodMonitorForClass
public static MethodMonitor getMethodMonitorForClass(Class<?> cls, Class<? extends Annotation> annot) Return the current MethodMonitor in use for the given cls and annot. Returns null if no MethodMonitor is in use. Throws an exception if either cls is not a traced class, or annot is not a tracing annotation on cls.- Parameters:
cls- The Traced class.annot- A trace annotation on cls.- Returns:
- The MethodMonitor, if any.
-
getTimerTypes
Return a list of all timer types defined for cls. This is in the same order as classToMNames.get(cls).- Parameters:
cls- The monitored class to use.- Returns:
- A list of timer types in the same order as the method names.
-
getTimerNames
-