org.glassfish.pfl.tf.spi
Class MethodMonitorRegistry

java.lang.Object
  extended by org.glassfish.pfl.tf.spi.MethodMonitorRegistry

public class MethodMonitorRegistry
extends Object

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

Author:
ken

Constructor Summary
MethodMonitorRegistry()
           
 
Method Summary
static void clear(Class<? extends Annotation> annot)
          Remove the MethodMonitorFactory (if any) that is associated with annot.
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.
static List<String> getMethodNames(Class<?> cls)
           
static Set<String> getMMAnnotations()
           
static List<String> 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>,org.glassfish.pfl.basic.contain.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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MethodMonitorRegistry

public MethodMonitorRegistry()
Method Detail

merge

public static MethodMonitor merge(MethodMonitor[] mms)
Merges the behaviors of the method monitors together.


getMMAnnotations

public static Set<String> getMMAnnotations()

registerAnnotationFile

public static void registerAnnotationFile(String fname)

registerClass

public static void registerClass(Class<?> cls,
                                 List<String> methodNames,
                                 Map<Class<? extends Annotation>,org.glassfish.pfl.basic.contain.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(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 List<String> getMethodNames(Class<?> cls)

getMethodName

public 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.

Parameters:
cls - The enhanced class
identifier - An Integer representing the method name.
Returns:
The name of the method corresponding to the identifier.

getMethodIdentifier

public static int getMethodIdentifier(Class<?> cls,
                                      String mname)

register

public static 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.

Parameters:
annot -
mmf -

clear

public static void clear(Class<? extends Annotation> annot)
Remove the MethodMonitorFactory (if any) that is associated with annot.

Parameters:
annot -

registeredFactory

public static MethodMonitorFactory registeredFactory(Class<? extends 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(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

public static List<TimingPointType> getTimerTypes(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 List<String> getTimerNames(Class<?> cls)


Copyright © 2013 Oracle. All Rights Reserved.