private static ExtensionClassAndMethodMatcher createPointCut( final Extension extension, final Extension.Instrumentation.Pointcut cut, final String metricPrefix, final String pName, final Map<String, MethodMapper> classesToMethods, final boolean custom, final InstrumentationType type, final boolean isAttsEnabled) throws XmlException { ClassMatcher classMatcher; if (cut.getMethodAnnotation() != null) { classMatcher = new AllClassesMatcher(); } else { classMatcher = createClassMatcher(cut, pName); } final MethodMatcher methodMatcher = createMethodMatcher(cut, pName, classesToMethods); List<ParameterAttributeName> reportedParams = null; if (!isAttsEnabled) { reportedParams = (List<ParameterAttributeName>) Lists.newArrayList(); } else { reportedParams = getParameterAttributeNames(cut.getMethod()); } return new ExtensionClassAndMethodMatcher( extension, cut, metricPrefix, classMatcher, methodMatcher, custom, reportedParams, type); }
public static String getClassName(final Extension.Instrumentation.Pointcut cut) { if (cut.getClassName() != null) { return cut.getClassName().getValue().trim(); } if (cut.getInterfaceName() != null) { return cut.getInterfaceName().trim(); } return null; }
private static MethodMatcher createMethodMatcher( final Extension.Instrumentation.Pointcut cut, final String pExtName, final Map<String, MethodMapper> classesToMethods) throws XmlException { final List<Extension.Instrumentation.Pointcut.Method> methods = cut.getMethod(); if (methods != null && !methods.isEmpty()) { return MethodMatcherUtility.createMethodMatcher( getClassName(cut), methods, classesToMethods, pExtName); } if (cut.getMethodAnnotation() != null) { return new AnnotationMethodMatcher( Type.getObjectType(cut.getMethodAnnotation().replace('.', '/'))); } throw new XmlException( MessageFormat.format( "At least one method must be specified for each point cut in the extension {0}", pExtName)); }
static ClassMatcher createClassMatcher( final Extension.Instrumentation.Pointcut pointcut, final String pExtName) throws XmlException { final Extension.Instrumentation.Pointcut.ClassName className = pointcut.getClassName(); if (className != null) { if (className.getValue() == null || className.getValue().isEmpty()) { throw new XmlException(""); } if (className.isIncludeSubclasses()) { return new ChildClassMatcher(className.getValue(), false); } return new ExactClassMatcher(className.getValue()); } else { if (pointcut.getInterfaceName() != null) { return new InterfaceMatcher(pointcut.getInterfaceName()); } throw new XmlException( MessageFormat.format( "A class name, interface name, or super class name needs to be specified for every point cut in the extension {0}", pExtName)); } }