Top Description Fields Constructors Methods
org.glassfish.pfl.tf.spi

public Class MethodMonitorRegistry

extends Object
Class Inheritance
Imports
java.lang.annotation.Annotation, java.lang.reflect.Field, java.util.Arrays, .HashMap, .HashSet, .List, .Map, .ResourceBundle, .Set, org.glassfish.pfl.basic.contain.SynchronizedHolder, org.glassfish.pfl.tf.spi.annotation.MethodMonitorGroup

Main class for registering MethodMonitorFactories against particular annotation classes that represent method monitor groups. This
Author
ken

Field Summary

Modifier and TypeField and Description
private 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<String>>
private static final Map<Class<?>, List<String>>
private static final Map<Class<?>, List<TimingPointType>>
private static final Set<String>
private static final Map<Class<? extends Annotation>, Set<Class<? extends Annotation>>>
private static final Map<Class<? extends Annotation>, Set<Class<? extends Annotation>>>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private static final MethodMonitorGroup
checkAnnotation(Class<? extends Annotation> annoClass)

public static synchronized 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
public static synchronized int
public static synchronized MethodMonitor

Returns:

The MethodMonitor, if any.
getMethodMonitorForClass
(final Class<?>
The Traced class.
cls
,
final Class<? extends Annotation>
A trace annotation on cls.
annot
)

Return the current MethodMonitor in use for the given cls and annot.

public static synchronized String

Returns:

The name of the method corresponding to the identifier.
getMethodName
(Class<?>
The enhanced class
cls
,
int
An Integer representing the method name.
identifier
)

Provided so that implementation of the MethodMonitor interface can obtain the method name for use in log reports or for other purposes.

public static synchronized List<String>
public static synchronized Set<String>
public static synchronized List<String>
getTimerNames(final Class<?> cls)

public static synchronized List<TimingPointType>

Returns:

A list of timer types in the same order as the method names.
getTimerTypes
(final Class<?>
The monitored class to use.
cls
)

Return a list of all timer types defined for cls.

public static synchronized MethodMonitor
merge(MethodMonitor[] mms)

Merges the behaviors of the method monitors together.

public static synchronized void
register(Class<? extends Annotation> annot, MethodMonitorFactory mmf)

Register a particular MethodMonitorFactory against an annotation.

public static synchronized void
public static synchronized void
registerClass(final Class<?>
Class to register, which must have 1 or more MM annotations.
cls
,
final List<String>
The list of method names used in the enhanced code. The index of the name is the value used in the method.
methodNames
,
final Map<Class<? extends Annotation>, SynchronizedHolder<MethodMonitor>>
The MM holders for each MM annotation on the class.
annoMM
)

Register a class with the tracing facility.

public static synchronized void
registerClass(final Class<?> cls)

Register a class with the tracing facility.

public static synchronized MethodMonitorFactory

Returns:

The MethodMonitorFactory for annot.
registeredFactory
(Class<? extends Annotation>
A class representing an annotation, which must itself have a MethodMonitorGroup meta-annotation.
annot
)

Return the MethodMonitorFactory registered against the annotation, or null if nothing is registered.

private static boolean
scanAnnotation(final Class<? extends Annotation> annoClass, final MethodMonitorGroup mmg)

private static boolean
private static void
updateAnnotation(Class<? extends Annotation> annot)

private static void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

annotationToClassesback to summary
private static final Map<Class<? extends Annotation>, Set<Class<?>>> annotationToClasses
annotationToMMFback to summary
private static final Map<Class<? extends Annotation>, MethodMonitorFactory> annotationToMMF
annotationToMMFCompositionback to summary
private static final Map<Class<? extends Annotation>, MethodMonitorFactory> annotationToMMFComposition
annotationToMMFSetsback to summary
private static final Map<Class<? extends Annotation>, Set<MethodMonitorFactory>> annotationToMMFSets
classToAnnoMMback to summary
private static final Map<Class<?>, Map<Class<? extends Annotation>, SynchronizedHolder<MethodMonitor>>> classToAnnoMM
classToMNamesback to summary
private static final Map<Class<?>, List<String>> classToMNames
classToTimerNamesback to summary
private static final Map<Class<?>, List<String>> classToTimerNames
classToTimerTypesback to summary
private static final Map<Class<?>, List<TimingPointType>> classToTimerTypes
mmAnnotationsback to summary
private static final Set<String> mmAnnotations
subgroupsback to summary
private static final Map<Class<? extends Annotation>, Set<Class<? extends Annotation>>> subgroups
subgroupsTCback to summary
private static final Map<Class<? extends Annotation>, Set<Class<? extends Annotation>>> subgroupsTC

Constructor Detail

MethodMonitorRegistryback to summary
public MethodMonitorRegistry()

Method Detail

checkAnnotationback to summary
private static final MethodMonitorGroup checkAnnotation(Class<? extends Annotation> annoClass)
clearback to summary
public static synchronized void clear(Class<? extends Annotation> annot)

Remove the MethodMonitorFactory (if any) that is associated with annot.

computeTransitiveClosureback to summary
private static void computeTransitiveClosure()
dfsback to summary
private static void dfs(Class<? extends Annotation> src, Class<? extends Annotation> dest)
doFullUpdateback to summary
private static void doFullUpdate()
getExternalNameback to summary
private static String getExternalName(String name)
getMethodIdentifierback to summary
public static synchronized int getMethodIdentifier(Class<?> cls, String mname)
getMethodMonitorForClassback to summary
public static synchronized MethodMonitor getMethodMonitorForClass(final Class<?> cls, final 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:Class<?>

The Traced class.

annot:Class<? extends Annotation>

A trace annotation on cls.

Returns:MethodMonitor

The MethodMonitor, if any.

getMethodNameback to summary
public static synchronized 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.

Parameters
cls:Class<?>

The enhanced class

identifier:int

An Integer representing the method name.

Returns:String

The name of the method corresponding to the identifier.

getMethodNamesback to summary
public static synchronized List<String> getMethodNames(Class<?> cls)
getMMAnnotationsback to summary
public static synchronized Set<String> getMMAnnotations()
getTimerNamesback to summary
public static synchronized List<String> getTimerNames(final Class<?> cls)
getTimerTypesback to summary
public static synchronized List<TimingPointType> getTimerTypes(final Class<?> cls)

Return a list of all timer types defined for cls. This is in the same order as classToMNames.get(cls).

Parameters
cls:Class<?>

The monitored class to use.

Returns:List<TimingPointType>

A list of timer types in the same order as the method names.

mergeback to summary
public static synchronized MethodMonitor merge(MethodMonitor[] mms)

Merges the behaviors of the method monitors together.

registerback to summary
public static synchronized void register(Class<? extends 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.

registerAnnotationFileback to summary
public static synchronized void registerAnnotationFile(final String fname)
registerClassback to summary
public static synchronized void registerClass(final Class<?> cls, final List<String> methodNames, final 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<?>

Class to register, which must have 1 or more MM annotations.

methodNames:List<String>

The list of method names used in the enhanced code. The index of the name is the value used in the method.

annoMM:Map<Class<? extends Annotation>, SynchronizedHolder<MethodMonitor>>

The MM holders for each MM annotation on the class.

registerClassback to summary
public static synchronized void registerClass(final 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.

registeredFactoryback to summary
public static synchronized MethodMonitorFactory registeredFactory(Class<? extends Annotation> annot)

Return the MethodMonitorFactory registered against the annotation, or null if nothing is registered.

Parameters
annot:Class<? extends Annotation>

A class representing an annotation, which must itself have a MethodMonitorGroup meta-annotation.

Returns:MethodMonitorFactory

The MethodMonitorFactory for annot.

scanAnnotationback to summary
private static boolean scanAnnotation(final Class<? extends Annotation> annoClass, final MethodMonitorGroup mmg)
scanClassAnnotationsback to summary
private static boolean scanClassAnnotations(final Class<?> cls)
updateAnnotationback to summary
private static void updateAnnotation(Class<? extends Annotation> annot)
updateTracedClassback to summary
private static void updateTracedClass(Class<?> cls)