Search in sources :

Example 1 with ReturnTypeMethodMatcher

use of com.newrelic.agent.instrumentation.methodmatchers.ReturnTypeMethodMatcher in project newrelic-java-agent by newrelic.

the class ExtensionConversionUtility method createMethodMatcher.

/**
 * Creates the method matcher to be used in the point cut.
 *
 * @param cut The xml information about the methods contain in the point cut.
 * @param pExtName The name of this extension.
 * @param classesToMethods The class/method combos which have already appeared.
 * @return The matcher to be used for methods on the point cut.
 * @throws XmlException
 */
private static MethodMatcher createMethodMatcher(final Pointcut cut, final String pExtName, final Map<String, MethodMapper> classesToMethods) throws XmlException {
    List<Method> methods = cut.getMethod();
    List<String> traceReturnTypeDescriptors = cut.getTraceReturnTypeDescriptors();
    if (methods != null && !methods.isEmpty()) {
        return MethodMatcherUtility.createMethodMatcher(getClassName(cut), methods, classesToMethods, pExtName);
    } else if (cut.getMethodAnnotation() != null) {
        return new AnnotationMethodMatcher(Type.getObjectType(cut.getMethodAnnotation().replace('.', '/')));
    } else if (cut.isTraceLambda()) {
        return new LambdaMethodMatcher(cut.getPattern(), cut.getIncludeNonstatic());
    } else if (traceReturnTypeDescriptors != null && !traceReturnTypeDescriptors.isEmpty()) {
        return new ReturnTypeMethodMatcher(traceReturnTypeDescriptors);
    } else {
        throw new XmlException(MessageFormat.format(XmlParsingMessages.NO_METHOD, pExtName));
    }
}
Also used : ReturnTypeMethodMatcher(com.newrelic.agent.instrumentation.methodmatchers.ReturnTypeMethodMatcher) Method(com.newrelic.agent.extension.beans.Extension.Instrumentation.Pointcut.Method) AnnotationMethodMatcher(com.newrelic.agent.instrumentation.methodmatchers.AnnotationMethodMatcher) LambdaMethodMatcher(com.newrelic.agent.instrumentation.methodmatchers.LambdaMethodMatcher)

Aggregations

Method (com.newrelic.agent.extension.beans.Extension.Instrumentation.Pointcut.Method)1 AnnotationMethodMatcher (com.newrelic.agent.instrumentation.methodmatchers.AnnotationMethodMatcher)1 LambdaMethodMatcher (com.newrelic.agent.instrumentation.methodmatchers.LambdaMethodMatcher)1 ReturnTypeMethodMatcher (com.newrelic.agent.instrumentation.methodmatchers.ReturnTypeMethodMatcher)1