Search in sources :

Example 1 with AllClassesMatcher

use of com.newrelic.agent.instrumentation.classmatchers.AllClassesMatcher in project newrelic-java-agent by newrelic.

the class ExtensionConversionUtility method createPointCut.

/**
 * Converts the xml point cut into a java agent point cut.
 *
 * @return The point cut object with the matchers set.
 */
private static ExtensionClassAndMethodMatcher createPointCut(Extension extension, final Pointcut cut, final String metricPrefix, final String pName, final Map<String, MethodMapper> classesToMethods, boolean custom, InstrumentationType type, boolean isAttsEnabled) throws XmlException {
    ClassMatcher classMatcher;
    if (cut.getMethodAnnotation() != null) {
        classMatcher = new AllClassesMatcher();
    } else {
        classMatcher = createClassMatcher(cut, pName);
    }
    MethodMatcher methodMatcher = createMethodMatcher(cut, pName, classesToMethods);
    List<ParameterAttributeName> reportedParams = null;
    if (!isAttsEnabled) {
        // looks like this could be modified later
        reportedParams = new ArrayList<>();
    } else {
        reportedParams = getParameterAttributeNames(cut.getMethod());
    }
    return new ExtensionClassAndMethodMatcher(extension, cut, metricPrefix, classMatcher, methodMatcher, custom, reportedParams, type);
}
Also used : ParameterAttributeName(com.newrelic.agent.instrumentation.tracing.ParameterAttributeName) ClassMatcher(com.newrelic.agent.instrumentation.classmatchers.ClassMatcher) ExactClassMatcher(com.newrelic.agent.instrumentation.classmatchers.ExactClassMatcher) ChildClassMatcher(com.newrelic.agent.instrumentation.classmatchers.ChildClassMatcher) ExtensionClassAndMethodMatcher(com.newrelic.agent.instrumentation.custom.ExtensionClassAndMethodMatcher) AllClassesMatcher(com.newrelic.agent.instrumentation.classmatchers.AllClassesMatcher) AnnotationMethodMatcher(com.newrelic.agent.instrumentation.methodmatchers.AnnotationMethodMatcher) LambdaMethodMatcher(com.newrelic.agent.instrumentation.methodmatchers.LambdaMethodMatcher) ExtensionClassAndMethodMatcher(com.newrelic.agent.instrumentation.custom.ExtensionClassAndMethodMatcher) ReturnTypeMethodMatcher(com.newrelic.agent.instrumentation.methodmatchers.ReturnTypeMethodMatcher) MethodMatcher(com.newrelic.agent.instrumentation.methodmatchers.MethodMatcher)

Example 2 with AllClassesMatcher

use of com.newrelic.agent.instrumentation.classmatchers.AllClassesMatcher in project newrelic-java-agent by newrelic.

the class ClassesMatcherTest method getMatchingClasses_ReturnType.

@Trace
@Test
public void getMatchingClasses_ReturnType() {
    ClassMatchVisitorFactory matcher = OptimizedClassMatcherBuilder.newBuilder().addClassMethodMatcher(new DefaultClassAndMethodMatcher(new AllClassesMatcher(), new ExactReturnTypeMethodMatcher(Type.getType(List.class)))).build();
    Set<Class<?>> matchingClasses = ClassesMatcher.getMatchingClasses(Collections.singletonList(matcher), matcherHelper, Arrays.class, ArrayList.class, HashMap.class, TestClass.class, Proxy.class);
    assertEquals(3, matchingClasses.size());
    assertTrue(matchingClasses.contains(ArrayList.class));
    assertTrue(matchingClasses.contains(TestClass.class));
    assertTrue(matchingClasses.contains(Arrays.class));
}
Also used : ExactReturnTypeMethodMatcher(com.newrelic.agent.instrumentation.methodmatchers.ExactReturnTypeMethodMatcher) DefaultClassAndMethodMatcher(com.newrelic.agent.instrumentation.classmatchers.DefaultClassAndMethodMatcher) AllClassesMatcher(com.newrelic.agent.instrumentation.classmatchers.AllClassesMatcher) Trace(com.newrelic.api.agent.Trace) Test(org.junit.Test)

Example 3 with AllClassesMatcher

use of com.newrelic.agent.instrumentation.classmatchers.AllClassesMatcher in project newrelic-java-agent by newrelic.

the class ClassesMatcherTest method getMatchingClasses_Annotation.

@Trace
@Test
public void getMatchingClasses_Annotation() {
    ClassMatchVisitorFactory matcher = OptimizedClassMatcherBuilder.newBuilder().addClassMethodMatcher(new DefaultClassAndMethodMatcher(new AllClassesMatcher(), new AnnotationMethodMatcher(Type.getType(Trace.class)))).build();
    Set<Class<?>> matchingClasses = ClassesMatcher.getMatchingClasses(Collections.singletonList(matcher), matcherHelper, ClassesMatcherTest.class, ArrayList.class, HashMap.class);
    assertEquals(1, matchingClasses.size());
    assertTrue(matchingClasses.contains(ClassesMatcherTest.class));
}
Also used : DefaultClassAndMethodMatcher(com.newrelic.agent.instrumentation.classmatchers.DefaultClassAndMethodMatcher) AllClassesMatcher(com.newrelic.agent.instrumentation.classmatchers.AllClassesMatcher) AnnotationMethodMatcher(com.newrelic.agent.instrumentation.methodmatchers.AnnotationMethodMatcher) Trace(com.newrelic.api.agent.Trace) Test(org.junit.Test)

Aggregations

AllClassesMatcher (com.newrelic.agent.instrumentation.classmatchers.AllClassesMatcher)3 DefaultClassAndMethodMatcher (com.newrelic.agent.instrumentation.classmatchers.DefaultClassAndMethodMatcher)2 AnnotationMethodMatcher (com.newrelic.agent.instrumentation.methodmatchers.AnnotationMethodMatcher)2 Trace (com.newrelic.api.agent.Trace)2 Test (org.junit.Test)2 ChildClassMatcher (com.newrelic.agent.instrumentation.classmatchers.ChildClassMatcher)1 ClassMatcher (com.newrelic.agent.instrumentation.classmatchers.ClassMatcher)1 ExactClassMatcher (com.newrelic.agent.instrumentation.classmatchers.ExactClassMatcher)1 ExtensionClassAndMethodMatcher (com.newrelic.agent.instrumentation.custom.ExtensionClassAndMethodMatcher)1 ExactReturnTypeMethodMatcher (com.newrelic.agent.instrumentation.methodmatchers.ExactReturnTypeMethodMatcher)1 LambdaMethodMatcher (com.newrelic.agent.instrumentation.methodmatchers.LambdaMethodMatcher)1 MethodMatcher (com.newrelic.agent.instrumentation.methodmatchers.MethodMatcher)1 ReturnTypeMethodMatcher (com.newrelic.agent.instrumentation.methodmatchers.ReturnTypeMethodMatcher)1 ParameterAttributeName (com.newrelic.agent.instrumentation.tracing.ParameterAttributeName)1