Package org.glassfish.pfl.tf.spi
Class MethodMonitorRegistry
- java.lang.Object
-
- org.glassfish.pfl.tf.spi.MethodMonitorRegistry
-
public class MethodMonitorRegistry extends java.lang.Object
Main class for registering MethodMonitorFactories against particular annotation classes that represent method monitor groups. This
-
-
Field Summary
Fields Modifier and Type Field Description private static java.util.Map<java.lang.Class<? extends java.lang.annotation.Annotation>,java.util.Set<java.lang.Class<?>>>
annotationToClasses
private static java.util.Map<java.lang.Class<? extends java.lang.annotation.Annotation>,MethodMonitorFactory>
annotationToMMF
private static java.util.Map<java.lang.Class<? extends java.lang.annotation.Annotation>,MethodMonitorFactory>
annotationToMMFComposition
private static java.util.Map<java.lang.Class<? extends java.lang.annotation.Annotation>,java.util.Set<MethodMonitorFactory>>
annotationToMMFSets
private static java.util.Map<java.lang.Class<?>,java.util.Map<java.lang.Class<? extends java.lang.annotation.Annotation>,SynchronizedHolder<MethodMonitor>>>
classToAnnoMM
private static java.util.Map<java.lang.Class<?>,java.util.List<java.lang.String>>
classToMNames
private static java.util.Map<java.lang.Class<?>,java.util.List<java.lang.String>>
classToTimerNames
private static java.util.Map<java.lang.Class<?>,java.util.List<TimingPointType>>
classToTimerTypes
private static java.util.Set<java.lang.String>
mmAnnotations
private static java.util.Map<java.lang.Class<? extends java.lang.annotation.Annotation>,java.util.Set<java.lang.Class<? extends java.lang.annotation.Annotation>>>
subgroups
private static java.util.Map<java.lang.Class<? extends java.lang.annotation.Annotation>,java.util.Set<java.lang.Class<? extends java.lang.annotation.Annotation>>>
subgroupsTC
-
Constructor Summary
Constructors Constructor Description MethodMonitorRegistry()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description private static MethodMonitorGroup
checkAnnotation(java.lang.Class<? extends java.lang.annotation.Annotation> annoClass)
static void
clear(java.lang.Class<? extends java.lang.annotation.Annotation> annot)
Remove the MethodMonitorFactory (if any) that is associated with annot.private static void
computeTransitiveClosure()
private static void
dfs(java.lang.Class<? extends java.lang.annotation.Annotation> src, java.lang.Class<? extends java.lang.annotation.Annotation> dest)
private static void
doFullUpdate()
private static java.lang.String
getExternalName(java.lang.String name)
static int
getMethodIdentifier(java.lang.Class<?> cls, java.lang.String mname)
static MethodMonitor
getMethodMonitorForClass(java.lang.Class<?> cls, java.lang.Class<? extends java.lang.annotation.Annotation> annot)
Return the current MethodMonitor in use for the given cls and annot.static java.lang.String
getMethodName(java.lang.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.static java.util.List<java.lang.String>
getMethodNames(java.lang.Class<?> cls)
static java.util.Set<java.lang.String>
getMMAnnotations()
static java.util.List<java.lang.String>
getTimerNames(java.lang.Class<?> cls)
static java.util.List<TimingPointType>
getTimerTypes(java.lang.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(java.lang.Class<? extends java.lang.annotation.Annotation> annot, MethodMonitorFactory mmf)
Register a particular MethodMonitorFactory against an annotation.static void
registerAnnotationFile(java.lang.String fname)
static void
registerClass(java.lang.Class<?> cls)
Register a class with the tracing facility.static void
registerClass(java.lang.Class<?> cls, java.util.List<java.lang.String> methodNames, java.util.Map<java.lang.Class<? extends java.lang.annotation.Annotation>,SynchronizedHolder<MethodMonitor>> annoMM)
Register a class with the tracing facility.static MethodMonitorFactory
registeredFactory(java.lang.Class<? extends java.lang.annotation.Annotation> annot)
Return the MethodMonitorFactory registered against the annotation, or null if nothing is registered.private static boolean
scanAnnotation(java.lang.Class<? extends java.lang.annotation.Annotation> annoClass, MethodMonitorGroup mmg)
private static boolean
scanClassAnnotations(java.lang.Class<?> cls)
private static void
updateAnnotation(java.lang.Class<? extends java.lang.annotation.Annotation> annot)
private static void
updateTracedClass(java.lang.Class<?> cls)
-
-
-
Field Detail
-
mmAnnotations
private static final java.util.Set<java.lang.String> mmAnnotations
-
classToTimerTypes
private static final java.util.Map<java.lang.Class<?>,java.util.List<TimingPointType>> classToTimerTypes
-
classToTimerNames
private static final java.util.Map<java.lang.Class<?>,java.util.List<java.lang.String>> classToTimerNames
-
classToMNames
private static final java.util.Map<java.lang.Class<?>,java.util.List<java.lang.String>> classToMNames
-
classToAnnoMM
private static final java.util.Map<java.lang.Class<?>,java.util.Map<java.lang.Class<? extends java.lang.annotation.Annotation>,SynchronizedHolder<MethodMonitor>>> classToAnnoMM
-
subgroups
private static final java.util.Map<java.lang.Class<? extends java.lang.annotation.Annotation>,java.util.Set<java.lang.Class<? extends java.lang.annotation.Annotation>>> subgroups
-
subgroupsTC
private static final java.util.Map<java.lang.Class<? extends java.lang.annotation.Annotation>,java.util.Set<java.lang.Class<? extends java.lang.annotation.Annotation>>> subgroupsTC
-
annotationToClasses
private static final java.util.Map<java.lang.Class<? extends java.lang.annotation.Annotation>,java.util.Set<java.lang.Class<?>>> annotationToClasses
-
annotationToMMF
private static final java.util.Map<java.lang.Class<? extends java.lang.annotation.Annotation>,MethodMonitorFactory> annotationToMMF
-
annotationToMMFSets
private static final java.util.Map<java.lang.Class<? extends java.lang.annotation.Annotation>,java.util.Set<MethodMonitorFactory>> annotationToMMFSets
-
annotationToMMFComposition
private static final java.util.Map<java.lang.Class<? extends java.lang.annotation.Annotation>,MethodMonitorFactory> annotationToMMFComposition
-
-
Method Detail
-
merge
public static MethodMonitor merge(MethodMonitor[] mms)
Merges the behaviors of the method monitors together.
-
getMMAnnotations
public static java.util.Set<java.lang.String> getMMAnnotations()
-
registerAnnotationFile
public static void registerAnnotationFile(java.lang.String fname)
-
updateTracedClass
private static void updateTracedClass(java.lang.Class<?> cls)
-
updateAnnotation
private static void updateAnnotation(java.lang.Class<? extends java.lang.annotation.Annotation> annot)
-
doFullUpdate
private static void doFullUpdate()
-
scanClassAnnotations
private static boolean scanClassAnnotations(java.lang.Class<?> cls)
-
scanAnnotation
private static boolean scanAnnotation(java.lang.Class<? extends java.lang.annotation.Annotation> annoClass, MethodMonitorGroup mmg)
-
computeTransitiveClosure
private static void computeTransitiveClosure()
-
dfs
private static void dfs(java.lang.Class<? extends java.lang.annotation.Annotation> src, java.lang.Class<? extends java.lang.annotation.Annotation> dest)
-
getExternalName
private static java.lang.String getExternalName(java.lang.String name)
-
checkAnnotation
private static final MethodMonitorGroup checkAnnotation(java.lang.Class<? extends java.lang.annotation.Annotation> annoClass)
-
registerClass
public static void registerClass(java.lang.Class<?> cls, java.util.List<java.lang.String> methodNames, java.util.Map<java.lang.Class<? extends java.lang.annotation.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
public static void registerClass(java.lang.Class<?> cls)
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
public static java.util.List<java.lang.String> getMethodNames(java.lang.Class<?> cls)
-
getMethodName
public static java.lang.String getMethodName(java.lang.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.- Parameters:
cls
- The enhanced classidentifier
- An Integer representing the method name.- Returns:
- The name of the method corresponding to the identifier.
-
getMethodIdentifier
public static int getMethodIdentifier(java.lang.Class<?> cls, java.lang.String mname)
-
register
public static void register(java.lang.Class<? extends java.lang.annotation.Annotation> annot, MethodMonitorFactory mmf)
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
public static void clear(java.lang.Class<? extends java.lang.annotation.Annotation> annot)
Remove the MethodMonitorFactory (if any) that is associated with annot.- Parameters:
annot
-
-
registeredFactory
public static MethodMonitorFactory registeredFactory(java.lang.Class<? extends java.lang.annotation.Annotation> annot)
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(java.lang.Class<?> cls, java.lang.Class<? extends java.lang.annotation.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
public static java.util.List<TimingPointType> getTimerTypes(java.lang.Class<?> cls)
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
public static java.util.List<java.lang.String> getTimerNames(java.lang.Class<?> cls)
-
-