Search in sources :

Example 6 with InterfaceInternalNameMatcherOperand

use of com.navercorp.pinpoint.bootstrap.instrument.matcher.operand.InterfaceInternalNameMatcherOperand in project pinpoint by naver.

the class DefaultClassBasedMatcherTest method getMatcherOperandWithClassNameAndAdditional.

@Test
public void getMatcherOperandWithClassNameAndAdditional() {
    InterfaceInternalNameMatcherOperand additional = new InterfaceInternalNameMatcherOperand("java/lang/Runnable", false);
    DefaultClassBasedMatcher matcher = new DefaultClassBasedMatcher("java.lang.String", additional);
    assertEquals("java.lang.String", matcher.getBaseClassName());
    MatcherOperand operand = matcher.getMatcherOperand();
    assertTrue(operand instanceof AndMatcherOperator);
    AndMatcherOperator operator = (AndMatcherOperator) operand;
    assertTrue(operator.getLeftOperand() instanceof ClassInternalNameMatcherOperand);
    assertTrue(operator.getRightOperand() instanceof InterfaceInternalNameMatcherOperand);
}
Also used : InterfaceInternalNameMatcherOperand(com.navercorp.pinpoint.bootstrap.instrument.matcher.operand.InterfaceInternalNameMatcherOperand) MatcherOperand(com.navercorp.pinpoint.bootstrap.instrument.matcher.operand.MatcherOperand) ClassInternalNameMatcherOperand(com.navercorp.pinpoint.bootstrap.instrument.matcher.operand.ClassInternalNameMatcherOperand) InterfaceInternalNameMatcherOperand(com.navercorp.pinpoint.bootstrap.instrument.matcher.operand.InterfaceInternalNameMatcherOperand) AndMatcherOperator(com.navercorp.pinpoint.bootstrap.instrument.matcher.operator.AndMatcherOperator) ClassInternalNameMatcherOperand(com.navercorp.pinpoint.bootstrap.instrument.matcher.operand.ClassInternalNameMatcherOperand) Test(org.junit.Test)

Example 7 with InterfaceInternalNameMatcherOperand

use of com.navercorp.pinpoint.bootstrap.instrument.matcher.operand.InterfaceInternalNameMatcherOperand in project pinpoint by naver.

the class AndMatcherOperatorTest method base.

@Test
public void base() throws Exception {
    AndMatcherOperator operator = new AndMatcherOperator(new ClassInternalNameMatcherOperand("java/lang/String"), new InterfaceInternalNameMatcherOperand("java/lang/Serializable", false));
    assertEquals(2, operator.getPrecedence());
    assertTrue(operator.isOperator());
    assertFalse(operator.isIndex());
    assertTrue(operator.getLeftOperand() instanceof ClassInternalNameMatcherOperand);
    assertTrue(operator.getRightOperand() instanceof InterfaceInternalNameMatcherOperand);
    assertEquals(3, operator.getExecutionCost());
}
Also used : InterfaceInternalNameMatcherOperand(com.navercorp.pinpoint.bootstrap.instrument.matcher.operand.InterfaceInternalNameMatcherOperand) ClassInternalNameMatcherOperand(com.navercorp.pinpoint.bootstrap.instrument.matcher.operand.ClassInternalNameMatcherOperand) Test(org.junit.Test)

Example 8 with InterfaceInternalNameMatcherOperand

use of com.navercorp.pinpoint.bootstrap.instrument.matcher.operand.InterfaceInternalNameMatcherOperand in project pinpoint by naver.

the class OrMatcherOperatorTest method base.

@Test
public void base() throws Exception {
    OrMatcherOperator operator = new OrMatcherOperator(new ClassInternalNameMatcherOperand("java/lang/String"), new InterfaceInternalNameMatcherOperand("java/lang/Serializable", false));
    assertEquals(1, operator.getPrecedence());
    assertNotNull(operator.getLeftOperand());
    assertNotNull(operator.getRightOperand());
    assertFalse(operator.isIndex());
    assertTrue(operator.isOperator());
    assertEquals(3, operator.getExecutionCost());
}
Also used : InterfaceInternalNameMatcherOperand(com.navercorp.pinpoint.bootstrap.instrument.matcher.operand.InterfaceInternalNameMatcherOperand) ClassInternalNameMatcherOperand(com.navercorp.pinpoint.bootstrap.instrument.matcher.operand.ClassInternalNameMatcherOperand) Test(org.junit.Test)

Example 9 with InterfaceInternalNameMatcherOperand

use of com.navercorp.pinpoint.bootstrap.instrument.matcher.operand.InterfaceInternalNameMatcherOperand in project pinpoint by naver.

the class ThreadPlugin method addInterceptor.

private void addInterceptor(String threadMatchPackage, String className, Class<? extends TransformCallback> transformCallback) {
    Matcher matcher = Matchers.newPackageBasedMatcher(threadMatchPackage, new InterfaceInternalNameMatcherOperand(className, true));
    transformTemplate.transform(matcher, transformCallback);
}
Also used : InterfaceInternalNameMatcherOperand(com.navercorp.pinpoint.bootstrap.instrument.matcher.operand.InterfaceInternalNameMatcherOperand) Matcher(com.navercorp.pinpoint.bootstrap.instrument.matcher.Matcher)

Example 10 with InterfaceInternalNameMatcherOperand

use of com.navercorp.pinpoint.bootstrap.instrument.matcher.operand.InterfaceInternalNameMatcherOperand in project pinpoint by naver.

the class VertxPlugin method addHandlerInterceptor.

private void addHandlerInterceptor(final List<String> basePackageNames) {
    // basepackageNames AND io.vertx.core.Handler
    final Matcher matcher = Matchers.newPackageBasedMatcher(basePackageNames, new InterfaceInternalNameMatcherOperand("io.vertx.core.Handler", true));
    transformTemplate.transform(matcher, new TransformCallback() {

        @Override
        public byte[] doInTransform(Instrumentor instrumentor, ClassLoader classLoader, String className, Class<?> classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer) throws InstrumentException {
            final InstrumentClass target = instrumentor.getInstrumentClass(classLoader, className, classfileBuffer);
            if (!target.isInterceptable()) {
                return null;
            }
            target.addField(AsyncContextAccessor.class);
            final InstrumentMethod handleMethod = target.getDeclaredMethod("handle", "java.lang.Object");
            if (handleMethod != null) {
                handleMethod.addInterceptor(HandlerInterceptor.class);
            }
            return target.toBytecode();
        }
    });
}
Also used : InterfaceInternalNameMatcherOperand(com.navercorp.pinpoint.bootstrap.instrument.matcher.operand.InterfaceInternalNameMatcherOperand) ProtectionDomain(java.security.ProtectionDomain) InstrumentException(com.navercorp.pinpoint.bootstrap.instrument.InstrumentException) Matcher(com.navercorp.pinpoint.bootstrap.instrument.matcher.Matcher) Instrumentor(com.navercorp.pinpoint.bootstrap.instrument.Instrumentor) HandlerInterceptor(com.navercorp.pinpoint.plugin.vertx.interceptor.HandlerInterceptor) AsyncContextAccessor(com.navercorp.pinpoint.bootstrap.async.AsyncContextAccessor) TransformCallback(com.navercorp.pinpoint.bootstrap.instrument.transformer.TransformCallback) InstrumentClass(com.navercorp.pinpoint.bootstrap.instrument.InstrumentClass) InstrumentMethod(com.navercorp.pinpoint.bootstrap.instrument.InstrumentMethod)

Aggregations

InterfaceInternalNameMatcherOperand (com.navercorp.pinpoint.bootstrap.instrument.matcher.operand.InterfaceInternalNameMatcherOperand)14 Test (org.junit.Test)9 ClassInternalNameMatcherOperand (com.navercorp.pinpoint.bootstrap.instrument.matcher.operand.ClassInternalNameMatcherOperand)6 Matcher (com.navercorp.pinpoint.bootstrap.instrument.matcher.Matcher)5 MatcherOperand (com.navercorp.pinpoint.bootstrap.instrument.matcher.operand.MatcherOperand)5 SuperClassInternalNameMatcherOperand (com.navercorp.pinpoint.bootstrap.instrument.matcher.operand.SuperClassInternalNameMatcherOperand)5 AnnotationInternalNameMatcherOperand (com.navercorp.pinpoint.bootstrap.instrument.matcher.operand.AnnotationInternalNameMatcherOperand)3 PackageInternalNameMatcherOperand (com.navercorp.pinpoint.bootstrap.instrument.matcher.operand.PackageInternalNameMatcherOperand)3 AndMatcherOperator (com.navercorp.pinpoint.bootstrap.instrument.matcher.operator.AndMatcherOperator)3 InternalClassMetadata (com.navercorp.pinpoint.profiler.instrument.classreading.InternalClassMetadata)2 DefaultInstrumentMatcherCacheConfig (com.navercorp.pinpoint.profiler.instrument.config.DefaultInstrumentMatcherCacheConfig)2 InstrumentMatcherCacheConfig (com.navercorp.pinpoint.profiler.instrument.config.InstrumentMatcherCacheConfig)2 AsyncContextAccessor (com.navercorp.pinpoint.bootstrap.async.AsyncContextAccessor)1 InstrumentClass (com.navercorp.pinpoint.bootstrap.instrument.InstrumentClass)1 InstrumentException (com.navercorp.pinpoint.bootstrap.instrument.InstrumentException)1 InstrumentMethod (com.navercorp.pinpoint.bootstrap.instrument.InstrumentMethod)1 Instrumentor (com.navercorp.pinpoint.bootstrap.instrument.Instrumentor)1 OrMatcherOperator (com.navercorp.pinpoint.bootstrap.instrument.matcher.operator.OrMatcherOperator)1 TransformCallback (com.navercorp.pinpoint.bootstrap.instrument.transformer.TransformCallback)1 HandlerInterceptor (com.navercorp.pinpoint.plugin.vertx.interceptor.HandlerInterceptor)1