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);
}
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());
}
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());
}
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);
}
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();
}
});
}
Aggregations