Class MethodMonitorRegistry

java.lang.Object
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
  • Field Details

  • Constructor Details

    • MethodMonitorRegistry

      public MethodMonitorRegistry()
  • Method Details

    • 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)
    • updateTracedClass

      private static void updateTracedClass(Class<?> cls)
    • updateAnnotation

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

      private static void doFullUpdate()
    • scanClassAnnotations

      private static boolean scanClassAnnotations(Class<?> cls)
    • scanAnnotation

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

      private static void computeTransitiveClosure()
    • dfs

      private static void dfs(Class<? extends Annotation> src, Class<? extends Annotation> dest)
    • getExternalName

      private static String getExternalName(String name)
    • checkAnnotation

      private static final MethodMonitorGroup checkAnnotation(Class<? extends Annotation> annoClass)
    • 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

      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)