use of com.shulie.instrument.simulator.api.instrument.InstrumentMethod in project LinkAgent by shulieTech.
the class ResinPlugin method onActive.
@Override
public boolean onActive() throws Throwable {
enhanceTemplate.enhance(this, "com.caucho.server.http.HttpServletRequestImpl", new EnhanceCallback() {
@Override
public void doEnhance(InstrumentClass target) {
final InstrumentMethod startAsyncMethodEditor = target.getDeclaredMethod("startAsync", "javax.servlet.ServletRequest", "javax.servlet.ServletResponse");
if (startAsyncMethodEditor != null) {
startAsyncMethodEditor.addInterceptor(Listeners.of(HttpServletRequestImplStartAsyncInterceptor.class));
}
}
});
enhanceTemplate.enhance(this, "com.caucho.server.dispatch.ServletInvocation", new EnhanceCallback() {
@Override
public void doEnhance(InstrumentClass target) {
final InstrumentMethod serviceMethodEditorBuilder = target.getDeclaredMethod("service", "javax.servlet.ServletRequest", "javax.servlet.ServletResponse");
if (serviceMethodEditorBuilder != null) {
serviceMethodEditorBuilder.addInterceptor(Listeners.of(ServletInvocationServiceInterceptor.class, "RESIN_REQUEST", ExecutionPolicy.BOUNDARY, Interceptors.SCOPE_CALLBACK));
}
}
});
return true;
}
use of com.shulie.instrument.simulator.api.instrument.InstrumentMethod in project LinkAgent by shulieTech.
the class JettyPlugin method addServerInterceptor.
private boolean addServerInterceptor() {
enhanceTemplate.enhance(this, "org.eclipse.jetty.server.handler.HandlerWrapper", new EnhanceCallback() {
@Override
public void doEnhance(InstrumentClass target) {
// 7.x ~ 9.x
final InstrumentMethod handleMethod = target.getDeclaredMethod("handle", "java.lang.String", "org.eclipse.jetty.server.Request", "javax.servlet.http.HttpServletRequest", "javax.servlet.http.HttpServletResponse");
handleMethod.addInterceptor(Listeners.of(JettyServerHandleInterceptor.class));
}
});
// jetty 6.x
enhanceTemplate.enhance(this, "org.mortbay.jetty.Server", new EnhanceCallback() {
@Override
public void doEnhance(InstrumentClass target) {
InstrumentMethod handleMethod = target.getDeclaredMethod("handle", "java.lang.String", "javax.servlet.http.HttpServletRequest", "javax.servlet.http.HttpServletResponse", "int");
handleMethod.addInterceptor(Listeners.of(Jetty6xServerHandleInterceptor.class));
}
});
enhanceTemplate.enhance(this, "org.eclipse.jetty.server.Request", new EnhanceCallback() {
@Override
public void doEnhance(InstrumentClass target) {
// Add async listener. Servlet 3.0
final InstrumentMethod startAsyncMethod = target.getDeclaredMethod("startAsync");
startAsyncMethod.addInterceptor(Listeners.of(RequestStartAsyncInterceptor.class));
final InstrumentMethod startAsyncMethod0 = target.getDeclaredMethod("startAsync", "javax.servlet.ServletRequest", "javax.servlet.ServletResponse");
startAsyncMethod0.addInterceptor(Listeners.of(RequestStartAsyncInterceptor.class));
}
});
return true;
}
use of com.shulie.instrument.simulator.api.instrument.InstrumentMethod in project LinkAgent by shulieTech.
the class HystrixPlugin method onActive.
@Override
public boolean onActive() throws Throwable {
enhanceTemplate.enhance(this, "com.netflix.hystrix.strategy.concurrency.HystrixContextScheduler$HystrixContextSchedulerWorker", new EnhanceCallback() {
@Override
public void doEnhance(InstrumentClass target) {
InstrumentMethod constructors = target.getConstructors();
constructors.addInterceptor(Listeners.of(ConstructorInterceptor.class));
InstrumentMethod scheduleMethod1 = target.getDeclaredMethod("schedule", "rx.functions.Action0");
scheduleMethod1.addInterceptor(Listeners.of(InvokeInterceptor.class));
InstrumentMethod scheduleMethod2 = target.getDeclaredMethod("schedule", "rx.functions.Action0", "long", "java.util.concurrent.TimeUnit");
scheduleMethod2.addInterceptor(Listeners.of(InvokeInterceptor.class));
}
});
enhanceTemplate.enhance(this, "com.netflix.hystrix.strategy.concurrency.HystrixContexSchedulerAction", new EnhanceCallback() {
@Override
public void doEnhance(InstrumentClass target) {
InstrumentMethod constructor1 = target.getConstructor("com.netflix.hystrix.strategy.concurrency.HystrixConcurrencyStrategy", "rx.functions.Action0");
constructor1.addInterceptor(Listeners.of(ConstructorInterceptor.class));
InstrumentMethod callMethod = target.getDeclaredMethod("call");
callMethod.addInterceptor(Listeners.of(InvokeInterceptor.class));
}
});
enhanceTemplate.enhance(this, "rx.internal.operators.OnSubscribeDefer", new EnhanceCallback() {
@Override
public void doEnhance(InstrumentClass target) {
InstrumentMethod constructors = target.getConstructors();
constructors.addInterceptor(Listeners.of(ConstructorInterceptor.class));
InstrumentMethod callMethod = target.getDeclaredMethod("call", "rx.Subscriber");
callMethod.addInterceptor(Listeners.of(InvokeInterceptor.class));
}
});
return true;
}
use of com.shulie.instrument.simulator.api.instrument.InstrumentMethod in project LinkAgent by shulieTech.
the class JetCachePlugin method onActive.
@Override
public boolean onActive() throws Throwable {
enhanceTemplate.enhance(this, "com.alicp.jetcache.embedded.AbstractEmbeddedCache", new EnhanceCallback() {
@Override
public void doEnhance(InstrumentClass target) {
InstrumentMethod buildKeyMethod = target.getDeclaredMethod("buildKey", "java.lang.Object");
buildKeyMethod.addInterceptor(Listeners.of(EmbeddedCacheBuildKeyInterceptor.class));
}
});
enhanceTemplate.enhance(this, "com.alicp.jetcache.external.AbstractExternalCache", new EnhanceCallback() {
@Override
public void doEnhance(InstrumentClass target) {
InstrumentMethod buildKeyMethod = target.getDeclaredMethod("buildKey", "java.lang.Object");
buildKeyMethod.addInterceptor(Listeners.of(ExternalCacheBuildKeyInterceptor.class));
}
});
return true;
}
use of com.shulie.instrument.simulator.api.instrument.InstrumentMethod in project LinkAgent by shulieTech.
the class GoogleGuavaPlugin method addGuaveInterceptor.
private boolean addGuaveInterceptor() {
final boolean skipTrace = true;
enhanceTemplate.enhance(this, "com.google.common.collect.ImmutableMap", new EnhanceCallback() {
@Override
public void doEnhance(InstrumentClass target) {
InstrumentMethod copyOf = target.getDeclaredMethods("copyOf");
copyOf.addInterceptor(Listeners.of(CacheOperationGetAllResInterceptor.class));
}
});
this.enhanceTemplate.enhance(this, "com.google.common.cache.LocalCache$LoadingValueReference", new EnhanceCallback() {
@Override
public void doEnhance(InstrumentClass target) {
InstrumentMethod load = target.getDeclaredMethods("loadFuture");
load.addInterceptor(Listeners.of(CacheLoaderKeyConvertInterceptor.class));
}
});
final String[] methods = new String[] { "getAllPresent", "invalidateAll", "get", "invalidate", "putAll", "put", "getIfPresent" };
// Cache operation
enhanceTemplate.enhance(this, "com.google.common.cache.LocalCache$LocalManualCache", new EnhanceCallback() {
@Override
public void doEnhance(InstrumentClass target) {
InstrumentMethod build = target.getDeclaredMethods(methods);
build.addInterceptor(Listeners.of(CacheOperationInterceptor.class));
if (!skipTrace) {
InstrumentMethod declaredMethods = target.getDeclaredMethods("*");
declaredMethods.addInterceptor(Listeners.of(CacheOperationTraceInterceptor.class));
}
InstrumentMethod asMap = target.getDeclaredMethods("asMap");
asMap.addInterceptor(Listeners.of(CacheAsMapInterceptor.class));
}
});
enhanceTemplate.enhance(this, "com.google.common.cache.LocalCache$LocalLoadingCache", new EnhanceCallback() {
@Override
public void doEnhance(InstrumentClass target) {
InstrumentMethod build = target.getDeclaredMethods(methods);
build.addInterceptor(Listeners.of(CacheOperationInterceptor.class));
if (!skipTrace) {
InstrumentMethod declaredMethods = target.getDeclaredMethods("*");
declaredMethods.addInterceptor(Listeners.of(CacheOperationTraceInterceptor.class));
}
InstrumentMethod asMap = target.getDeclaredMethods("asMap");
asMap.addInterceptor(Listeners.of(CacheAsMapInterceptor.class));
}
});
enhanceTemplate.enhance(this, "com.google.common.cache.ForwardingCache", new EnhanceCallback() {
@Override
public void doEnhance(InstrumentClass target) {
InstrumentMethod build = target.getDeclaredMethods(methods);
build.addInterceptor(Listeners.of(CacheOperationInterceptor.class));
if (!skipTrace) {
InstrumentMethod declaredMethods = target.getDeclaredMethods("*");
declaredMethods.addInterceptor(Listeners.of(CacheOperationTraceInterceptor.class));
}
InstrumentMethod asMap = target.getDeclaredMethods("asMap");
asMap.addInterceptor(Listeners.of(CacheAsMapInterceptor.class));
}
});
return true;
}
Aggregations