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
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final Map
<Class<? extends Annotation>, Set<Class<?>>> private static final Map
<Class<? extends Annotation>, MethodMonitorFactory> private static final Map
<Class<? extends Annotation>, MethodMonitorFactory> private static final Map
<Class<? extends Annotation>, Set<MethodMonitorFactory>> private static final Map
<Class<?>, Map<Class<? extends Annotation>, SynchronizedHolder<MethodMonitor>>> private static final Map
<Class<?>, List<TimingPointType>> private static final Map
<Class<? extends Annotation>, Set<Class<? extends Annotation>>> private static final Map
<Class<? extends Annotation>, Set<Class<? extends Annotation>>> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static final MethodMonitorGroup
checkAnnotation
(Class<? extends Annotation> annoClass) static void
clear
(Class<? extends Annotation> annot) Remove the MethodMonitorFactory (if any) that is associated with annot.private static void
private static void
dfs
(Class<? extends Annotation> src, Class<? extends Annotation> dest) private static void
private static String
getExternalName
(String name) static int
getMethodIdentifier
(Class<?> cls, String mname) static MethodMonitor
getMethodMonitorForClass
(Class<?> cls, Class<? extends Annotation> annot) Return the current MethodMonitor in use for the given cls and annot.static String
getMethodName
(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 MethodMonitor
merge
(MethodMonitor[] mms) Merges the behaviors of the method monitors together.static void
register
(Class<? extends Annotation> annot, MethodMonitorFactory mmf) Register a particular MethodMonitorFactory against an annotation.static void
registerAnnotationFile
(String fname) static void
registerClass
(Class<?> cls) Register a class with the tracing facility.static void
registerClass
(Class<?> cls, List<String> methodNames, Map<Class<? extends Annotation>, SynchronizedHolder<MethodMonitor>> annoMM) Register a class with the tracing facility.static MethodMonitorFactory
registeredFactory
(Class<? extends Annotation> annot) Return the MethodMonitorFactory registered against the annotation, or null if nothing is registered.private static boolean
scanAnnotation
(Class<? extends Annotation> annoClass, MethodMonitorGroup mmg) private static boolean
scanClassAnnotations
(Class<?> cls) private static void
updateAnnotation
(Class<? extends Annotation> annot) private static void
updateTracedClass
(Class<?> cls)
-
Field Details
-
mmAnnotations
-
classToTimerTypes
-
classToTimerNames
-
classToMNames
-
classToAnnoMM
private static final Map<Class<?>,Map<Class<? extends Annotation>, classToAnnoMMSynchronizedHolder<MethodMonitor>>> -
subgroups
-
subgroupsTC
-
annotationToClasses
-
annotationToMMF
-
annotationToMMFSets
-
annotationToMMFComposition
private static final Map<Class<? extends Annotation>,MethodMonitorFactory> annotationToMMFComposition
-
-
Constructor Details
-
MethodMonitorRegistry
public MethodMonitorRegistry()
-
-
Method Details
-
merge
Merges the behaviors of the method monitors together. -
getMMAnnotations
-
registerAnnotationFile
-
updateTracedClass
-
updateAnnotation
-
doFullUpdate
private static void doFullUpdate() -
scanClassAnnotations
-
scanAnnotation
private static boolean scanAnnotation(Class<? extends Annotation> annoClass, MethodMonitorGroup mmg) -
computeTransitiveClosure
private static void computeTransitiveClosure() -
dfs
-
getExternalName
-
checkAnnotation
-
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
-