Search in sources :

Example 1 with AccessMethodMatcher

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

the class InstrumentationImpl method instrument.

@Override
public void instrument(String className, String metricPrefix) {
    DefaultClassAndMethodMatcher matcher = new HashSafeClassAndMethodMatcher(new ExactClassMatcher(className), AndMethodMatcher.getMethodMatcher(new AccessMethodMatcher(Opcodes.ACC_PUBLIC), new NotMethodMatcher(GetterSetterMethodMatcher.getGetterSetterMethodMatcher())));
    ServiceFactory.getClassTransformerService().addTraceMatcher(matcher, metricPrefix);
}
Also used : ExactClassMatcher(com.newrelic.agent.instrumentation.classmatchers.ExactClassMatcher) AccessMethodMatcher(com.newrelic.agent.instrumentation.methodmatchers.AccessMethodMatcher) DefaultClassAndMethodMatcher(com.newrelic.agent.instrumentation.classmatchers.DefaultClassAndMethodMatcher) HashSafeClassAndMethodMatcher(com.newrelic.agent.instrumentation.classmatchers.HashSafeClassAndMethodMatcher) NotMethodMatcher(com.newrelic.agent.instrumentation.methodmatchers.NotMethodMatcher)

Example 2 with AccessMethodMatcher

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

the class OptimizedClassMatcherTest method before.

@Before
public void before() {
    initializeServiceManager();
    OptimizedClassMatcherBuilder builder = OptimizedClassMatcherBuilder.newBuilder();
    match1 = new DefaultClassAndMethodMatcher(createInterfaceMatcher(Collection.class), new ExactMethodMatcher("size", "()I"));
    match2 = new DefaultClassAndMethodMatcher(createInterfaceMatcher(List.class), new ExactMethodMatcher("get", "(I)Ljava/lang/Object;"));
    match3 = new DefaultClassAndMethodMatcher(createInterfaceMatcher(InvocationHandler.class), new ExactMethodMatcher("invoke", "(Ljava/lang/Object;Ljava/lang/reflect/Method;[Ljava/lang/Object;)Ljava/lang/Object;"));
    match4 = new DefaultClassAndMethodMatcher(createInterfaceMatcher(Statement.class), new AllMethodsMatcher());
    match5 = new DefaultClassAndMethodMatcher(createInterfaceMatcher(Runnable.class), OrMethodMatcher.getMethodMatcher(new NameMethodMatcher("run"), new ExactMethodMatcher("bogus", "()V")));
    match6 = new DefaultClassAndMethodMatcher(createInterfaceMatcher(Map.class), new AccessMethodMatcher(Opcodes.ACC_PUBLIC));
    match7 = new DefaultClassAndMethodMatcher(createInterfaceMatcher(List.class), new ExactMethodMatcher("add", "(Ljava/lang/Object;)Z"));
    annotationMatch = new DefaultClassAndMethodMatcher(new AllClassesMatcher(), new AnnotationMethodMatcher(Type.getType(MyAnnotation.class)));
    // this is a bogus matcher to attempt to throw off match5
    builder.addClassMethodMatcher(new DefaultClassAndMethodMatcher(createInterfaceMatcher(PreparedStatement.class), new NameMethodMatcher("run")));
    builder.addClassMethodMatcher(match1);
    builder.addClassMethodMatcher(match2);
    builder.addClassMethodMatcher(match3);
    builder.addClassMethodMatcher(match4);
    builder.addClassMethodMatcher(match5);
    builder.addClassMethodMatcher(match6);
    builder.addClassMethodMatcher(match7);
    builder.addClassMethodMatcher(annotationMatch);
    this.matcher = builder.build();
}
Also used : NameMethodMatcher(com.newrelic.agent.instrumentation.methodmatchers.NameMethodMatcher) AccessMethodMatcher(com.newrelic.agent.instrumentation.methodmatchers.AccessMethodMatcher) AnnotationMethodMatcher(com.newrelic.agent.instrumentation.methodmatchers.AnnotationMethodMatcher) ExactMethodMatcher(com.newrelic.agent.instrumentation.methodmatchers.ExactMethodMatcher) AllMethodsMatcher(com.newrelic.agent.instrumentation.methodmatchers.AllMethodsMatcher) Before(org.junit.Before)

Aggregations

AccessMethodMatcher (com.newrelic.agent.instrumentation.methodmatchers.AccessMethodMatcher)2 DefaultClassAndMethodMatcher (com.newrelic.agent.instrumentation.classmatchers.DefaultClassAndMethodMatcher)1 ExactClassMatcher (com.newrelic.agent.instrumentation.classmatchers.ExactClassMatcher)1 HashSafeClassAndMethodMatcher (com.newrelic.agent.instrumentation.classmatchers.HashSafeClassAndMethodMatcher)1 AllMethodsMatcher (com.newrelic.agent.instrumentation.methodmatchers.AllMethodsMatcher)1 AnnotationMethodMatcher (com.newrelic.agent.instrumentation.methodmatchers.AnnotationMethodMatcher)1 ExactMethodMatcher (com.newrelic.agent.instrumentation.methodmatchers.ExactMethodMatcher)1 NameMethodMatcher (com.newrelic.agent.instrumentation.methodmatchers.NameMethodMatcher)1 NotMethodMatcher (com.newrelic.agent.instrumentation.methodmatchers.NotMethodMatcher)1 Before (org.junit.Before)1