Skip to content

Commit

Permalink
[pinpoint-apm#2862] remove annotation
Browse files Browse the repository at this point in the history
dbcp, dbcp2, cxf
  • Loading branch information
koo-taejin committed Apr 27, 2017
1 parent 81115d8 commit d506500
Show file tree
Hide file tree
Showing 12 changed files with 56 additions and 62 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,18 @@
*/
package com.navercorp.pinpoint.plugin.cxf;

import java.security.ProtectionDomain;

import com.navercorp.pinpoint.bootstrap.instrument.InstrumentClass;
import com.navercorp.pinpoint.bootstrap.instrument.InstrumentException;
import com.navercorp.pinpoint.bootstrap.instrument.InstrumentMethod;
import com.navercorp.pinpoint.bootstrap.instrument.Instrumentor;
import com.navercorp.pinpoint.bootstrap.instrument.transformer.TransformCallback;
import com.navercorp.pinpoint.bootstrap.instrument.transformer.TransformTemplate;
import com.navercorp.pinpoint.bootstrap.instrument.transformer.TransformTemplateAware;
import com.navercorp.pinpoint.bootstrap.plugin.ProfilerPlugin;
import com.navercorp.pinpoint.bootstrap.plugin.ProfilerPluginSetupContext;
import com.navercorp.pinpoint.bootstrap.plugin.util.InstrumentUtils;

import java.security.ProtectionDomain;

/**
* @author barney
Expand Down Expand Up @@ -52,8 +54,9 @@ public byte[] doInTransform(Instrumentor instrumentor, ClassLoader classLoader,
throws InstrumentException {
InstrumentClass target = instrumentor.getInstrumentClass(classLoader, className, classfileBuffer);

target.getDeclaredMethod("invokeSync", "java.lang.reflect.Method", "org.apache.cxf.service.model.BindingOperationInfo", "java.lang.Object[]")
.addInterceptor("com.navercorp.pinpoint.plugin.cxf.interceptor.CxfClientInvokeSyncMethodInterceptor");
// invokeSyncMethod
InstrumentMethod invokeSyncMethod = InstrumentUtils.findMethod(target, "invokeSync", new String[]{"java.lang.reflect.Method", "org.apache.cxf.service.model.BindingOperationInfo", "java.lang.Object[]"});
invokeSyncMethod.addScopedInterceptor("com.navercorp.pinpoint.plugin.cxf.interceptor.CxfClientInvokeSyncMethodInterceptor", CxfPluginConstants.CXF_CLIENT_SCOPE);

return target.toBytecode();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,25 @@
*/
package com.navercorp.pinpoint.plugin.cxf.interceptor;

import java.util.Arrays;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import com.navercorp.pinpoint.bootstrap.context.MethodDescriptor;
import com.navercorp.pinpoint.bootstrap.context.SpanEventRecorder;
import com.navercorp.pinpoint.bootstrap.context.Trace;
import com.navercorp.pinpoint.bootstrap.context.TraceContext;
import com.navercorp.pinpoint.bootstrap.context.TraceId;
import com.navercorp.pinpoint.bootstrap.interceptor.AroundInterceptor;
import com.navercorp.pinpoint.bootstrap.interceptor.annotation.Scope;
import com.navercorp.pinpoint.bootstrap.logging.PLogger;
import com.navercorp.pinpoint.bootstrap.logging.PLoggerFactory;
import com.navercorp.pinpoint.plugin.cxf.CxfPluginConfig;
import com.navercorp.pinpoint.plugin.cxf.CxfPluginConstants;

import java.util.Arrays;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
* @author barney
*
*/
@Scope(CxfPluginConstants.CXF_CLIENT_SCOPE)
public class CxfClientInvokeSyncMethodInterceptor implements AroundInterceptor {

private final PLogger logger = PLoggerFactory.getLogger(this.getClass());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import com.navercorp.pinpoint.bootstrap.instrument.InstrumentClass;
import com.navercorp.pinpoint.bootstrap.instrument.InstrumentException;
import com.navercorp.pinpoint.bootstrap.instrument.InstrumentMethod;
import com.navercorp.pinpoint.bootstrap.instrument.Instrumentor;
import com.navercorp.pinpoint.bootstrap.instrument.transformer.TransformCallback;
import com.navercorp.pinpoint.bootstrap.instrument.transformer.TransformTemplate;
Expand All @@ -26,6 +27,7 @@
import com.navercorp.pinpoint.bootstrap.logging.PLoggerFactory;
import com.navercorp.pinpoint.bootstrap.plugin.ProfilerPlugin;
import com.navercorp.pinpoint.bootstrap.plugin.ProfilerPluginSetupContext;
import com.navercorp.pinpoint.bootstrap.plugin.util.InstrumentUtils;

import java.security.ProtectionDomain;

Expand Down Expand Up @@ -60,7 +62,11 @@ private void addPoolGuardConnectionWrapperTransformer() {
@Override
public byte[] doInTransform(Instrumentor instrumentor, ClassLoader loader, String className, Class<?> classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer) throws InstrumentException {
InstrumentClass target = instrumentor.getInstrumentClass(loader, className, classfileBuffer);
target.addInterceptor(CommonsDbcpConstants.INTERCEPTOR_CLOSE_CONNECTION);

// closeMethod
InstrumentMethod closeMethod = InstrumentUtils.findMethod(target, "close");
closeMethod.addScopedInterceptor(CommonsDbcpConstants.INTERCEPTOR_CLOSE_CONNECTION, CommonsDbcpConstants.SCOPE);

return target.toBytecode();
}
});
Expand All @@ -75,11 +81,22 @@ public byte[] doInTransform(Instrumentor instrumentor, ClassLoader loader, Strin

if (isAvailableDataSourceMonitor(target)) {
target.addField(CommonsDbcpConstants.ACCESSOR_DATASOURCE_MONITOR);
target.addInterceptor(CommonsDbcpConstants.INTERCEPTOR_CONSTRUCTOR);
target.addInterceptor(CommonsDbcpConstants.INTERCEPTOR_CLOSE);

// default constructor
InstrumentMethod defaultConstructor = InstrumentUtils.findConstructor(target);
defaultConstructor.addScopedInterceptor(CommonsDbcpConstants.INTERCEPTOR_CONSTRUCTOR, CommonsDbcpConstants.SCOPE);

// closeMethod
InstrumentMethod closeMethod = InstrumentUtils.findMethod(target, "close");
closeMethod.addScopedInterceptor(CommonsDbcpConstants.INTERCEPTOR_CLOSE, CommonsDbcpConstants.SCOPE);
}

target.addInterceptor(CommonsDbcpConstants.INTERCEPTOR_GET_CONNECTION);
// getConnectionMethod
InstrumentMethod getConnectionMethod = InstrumentUtils.findMethod(target, "getConnection");
getConnectionMethod.addScopedInterceptor(CommonsDbcpConstants.INTERCEPTOR_GET_CONNECTION, CommonsDbcpConstants.SCOPE);
getConnectionMethod = InstrumentUtils.findMethod(target, "getConnection", new String[]{"java.lang.String", "java.lang.String"});
getConnectionMethod.addScopedInterceptor(CommonsDbcpConstants.INTERCEPTOR_GET_CONNECTION, CommonsDbcpConstants.SCOPE);

return target.toBytecode();
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,12 @@
import com.navercorp.pinpoint.bootstrap.context.SpanEventRecorder;
import com.navercorp.pinpoint.bootstrap.context.TraceContext;
import com.navercorp.pinpoint.bootstrap.interceptor.SpanEventSimpleAroundInterceptorForPlugin;
import com.navercorp.pinpoint.bootstrap.interceptor.annotation.Scope;
import com.navercorp.pinpoint.bootstrap.interceptor.annotation.TargetMethod;
import com.navercorp.pinpoint.plugin.commons.dbcp.CommonsDbcpConstants;

/**
* Maybe we should trace get of Datasource.
* @author emeroad
*/
@Scope(CommonsDbcpConstants.SCOPE)
@TargetMethod(name="close")
public class DataSourceCloseConnectionInterceptor extends SpanEventSimpleAroundInterceptorForPlugin {

public DataSourceCloseConnectionInterceptor(TraceContext traceContext, MethodDescriptor descriptor) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,13 @@
import com.navercorp.pinpoint.bootstrap.context.MethodDescriptor;
import com.navercorp.pinpoint.bootstrap.context.TraceContext;
import com.navercorp.pinpoint.bootstrap.interceptor.AroundInterceptor;
import com.navercorp.pinpoint.bootstrap.interceptor.annotation.Scope;
import com.navercorp.pinpoint.bootstrap.interceptor.annotation.TargetMethod;
import com.navercorp.pinpoint.bootstrap.plugin.monitor.DataSourceMonitorRegistry;
import com.navercorp.pinpoint.plugin.commons.dbcp.CommonsDbcpConstants;
import com.navercorp.pinpoint.plugin.commons.dbcp.DataSourceMonitorAccessor;
import com.navercorp.pinpoint.plugin.commons.dbcp.DbcpDataSourceMonitor;

/**
* @author Taejin Koo
*/
@Scope(CommonsDbcpConstants.SCOPE)
@TargetMethod(name="close")
public class DataSourceCloseInterceptor implements AroundInterceptor {

private final TraceContext traceContext;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,15 @@
package com.navercorp.pinpoint.plugin.commons.dbcp.interceptor;

import com.navercorp.pinpoint.bootstrap.interceptor.AroundInterceptor;
import com.navercorp.pinpoint.bootstrap.interceptor.annotation.Scope;
import com.navercorp.pinpoint.bootstrap.interceptor.annotation.TargetConstructor;
import com.navercorp.pinpoint.bootstrap.plugin.monitor.DataSourceMonitorRegistry;
import com.navercorp.pinpoint.bootstrap.util.InterceptorUtils;
import com.navercorp.pinpoint.plugin.commons.dbcp.CommonsDbcpConstants;
import com.navercorp.pinpoint.plugin.commons.dbcp.DataSourceMonitorAccessor;
import com.navercorp.pinpoint.plugin.commons.dbcp.DbcpDataSourceMonitor;
import org.apache.commons.dbcp.BasicDataSource;

/**
* @author Taejin Koo
*/
@Scope(CommonsDbcpConstants.SCOPE)
@TargetConstructor
public class DataSourceConstructorInterceptor implements AroundInterceptor {

private final DataSourceMonitorRegistry dataSourceMonitorRegistry;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,12 @@
import com.navercorp.pinpoint.bootstrap.context.SpanEventRecorder;
import com.navercorp.pinpoint.bootstrap.context.TraceContext;
import com.navercorp.pinpoint.bootstrap.interceptor.SpanEventSimpleAroundInterceptorForPlugin;
import com.navercorp.pinpoint.bootstrap.interceptor.annotation.Scope;
import com.navercorp.pinpoint.bootstrap.interceptor.annotation.TargetMethod;
import com.navercorp.pinpoint.bootstrap.interceptor.annotation.TargetMethods;
import com.navercorp.pinpoint.plugin.commons.dbcp.CommonsDbcpConstants;

/**
* Maybe we should trace get of Datasource.
* @author emeroad
*/
@Scope(CommonsDbcpConstants.SCOPE)
@TargetMethods({
@TargetMethod(name="getConnection"),
@TargetMethod(name="getConnection", paramTypes={"java.lang.String", "java.lang.String"})
})
public class DataSourceGetConnectionInterceptor extends SpanEventSimpleAroundInterceptorForPlugin {

public DataSourceGetConnectionInterceptor(TraceContext traceContext, MethodDescriptor descriptor) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import com.navercorp.pinpoint.bootstrap.instrument.InstrumentClass;
import com.navercorp.pinpoint.bootstrap.instrument.InstrumentException;
import com.navercorp.pinpoint.bootstrap.instrument.InstrumentMethod;
import com.navercorp.pinpoint.bootstrap.instrument.Instrumentor;
import com.navercorp.pinpoint.bootstrap.instrument.transformer.TransformCallback;
import com.navercorp.pinpoint.bootstrap.instrument.transformer.TransformTemplate;
Expand All @@ -26,6 +27,7 @@
import com.navercorp.pinpoint.bootstrap.logging.PLoggerFactory;
import com.navercorp.pinpoint.bootstrap.plugin.ProfilerPlugin;
import com.navercorp.pinpoint.bootstrap.plugin.ProfilerPluginSetupContext;
import com.navercorp.pinpoint.bootstrap.plugin.util.InstrumentUtils;

import java.security.ProtectionDomain;

Expand Down Expand Up @@ -57,7 +59,11 @@ private void addPoolGuardConnectionWrapperTransformer() {
@Override
public byte[] doInTransform(Instrumentor instrumentor, ClassLoader loader, String className, Class<?> classBeingRedefined, ProtectionDomain protectionDomain, byte[] classfileBuffer) throws InstrumentException {
InstrumentClass target = instrumentor.getInstrumentClass(loader, className, classfileBuffer);
target.addInterceptor(CommonsDbcp2Constants.INTERCEPTOR_CLOSE_CONNECTION);

// closeMethod
InstrumentMethod closeMethod = InstrumentUtils.findMethod(target, "close");
closeMethod.addScopedInterceptor(CommonsDbcp2Constants.INTERCEPTOR_CLOSE_CONNECTION, CommonsDbcp2Constants.SCOPE);

return target.toBytecode();
}
});
Expand All @@ -72,11 +78,22 @@ public byte[] doInTransform(Instrumentor instrumentor, ClassLoader loader, Strin

if (isAvailableDataSourceMonitor(target)) {
target.addField(CommonsDbcp2Constants.ACCESSOR_DATASOURCE_MONITOR);
target.addInterceptor(CommonsDbcp2Constants.INTERCEPTOR_CONSTRUCTOR);
target.addInterceptor(CommonsDbcp2Constants.INTERCEPTOR_CLOSE);

// closeMethod
InstrumentMethod closeMethod = InstrumentUtils.findMethod(target, "close");
closeMethod.addScopedInterceptor(CommonsDbcp2Constants.INTERCEPTOR_CLOSE, CommonsDbcp2Constants.SCOPE);

// constructor
InstrumentMethod defaultConstructor = InstrumentUtils.findConstructor(target);
defaultConstructor.addScopedInterceptor(CommonsDbcp2Constants.INTERCEPTOR_CONSTRUCTOR, CommonsDbcp2Constants.SCOPE);
}

target.addInterceptor(CommonsDbcp2Constants.INTERCEPTOR_GET_CONNECTION);
// getConnectionMethod
InstrumentMethod getConnectionMethod = InstrumentUtils.findMethod(target, "getConnection");
getConnectionMethod.addScopedInterceptor(CommonsDbcp2Constants.INTERCEPTOR_GET_CONNECTION, CommonsDbcp2Constants.SCOPE);
getConnectionMethod = InstrumentUtils.findMethod(target, "getConnection", new String[]{"java.lang.String", "java.lang.String"});
getConnectionMethod.addScopedInterceptor(CommonsDbcp2Constants.INTERCEPTOR_GET_CONNECTION, CommonsDbcp2Constants.SCOPE);

return target.toBytecode();
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,8 @@
import com.navercorp.pinpoint.bootstrap.context.SpanEventRecorder;
import com.navercorp.pinpoint.bootstrap.context.TraceContext;
import com.navercorp.pinpoint.bootstrap.interceptor.SpanEventSimpleAroundInterceptorForPlugin;
import com.navercorp.pinpoint.bootstrap.interceptor.annotation.Scope;
import com.navercorp.pinpoint.bootstrap.interceptor.annotation.TargetMethod;
import com.navercorp.pinpoint.plugin.commons.dbcp2.CommonsDbcp2Constants;

@Scope(CommonsDbcp2Constants.SCOPE)
@TargetMethod(name="close")
public class DataSourceCloseConnectionInterceptor extends SpanEventSimpleAroundInterceptorForPlugin {

public DataSourceCloseConnectionInterceptor(TraceContext traceContext, MethodDescriptor descriptor) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,13 @@
import com.navercorp.pinpoint.bootstrap.context.MethodDescriptor;
import com.navercorp.pinpoint.bootstrap.context.TraceContext;
import com.navercorp.pinpoint.bootstrap.interceptor.AroundInterceptor;
import com.navercorp.pinpoint.bootstrap.interceptor.annotation.Scope;
import com.navercorp.pinpoint.bootstrap.interceptor.annotation.TargetMethod;
import com.navercorp.pinpoint.bootstrap.plugin.monitor.DataSourceMonitorRegistry;
import com.navercorp.pinpoint.plugin.commons.dbcp2.CommonsDbcp2Constants;
import com.navercorp.pinpoint.plugin.commons.dbcp2.DataSourceMonitorAccessor;
import com.navercorp.pinpoint.plugin.commons.dbcp2.Dbcp2DataSourceMonitor;

/**
* @author Taejin Koo
*/
@Scope(CommonsDbcp2Constants.SCOPE)
@TargetMethod(name="close")
public class DataSourceCloseInterceptor implements AroundInterceptor {

private final TraceContext traceContext;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,15 @@
package com.navercorp.pinpoint.plugin.commons.dbcp2.interceptor;

import com.navercorp.pinpoint.bootstrap.interceptor.AroundInterceptor;
import com.navercorp.pinpoint.bootstrap.interceptor.annotation.Scope;
import com.navercorp.pinpoint.bootstrap.interceptor.annotation.TargetConstructor;
import com.navercorp.pinpoint.bootstrap.plugin.monitor.DataSourceMonitorRegistry;
import com.navercorp.pinpoint.bootstrap.util.InterceptorUtils;
import com.navercorp.pinpoint.plugin.commons.dbcp2.CommonsDbcp2Constants;
import com.navercorp.pinpoint.plugin.commons.dbcp2.DataSourceMonitorAccessor;
import com.navercorp.pinpoint.plugin.commons.dbcp2.Dbcp2DataSourceMonitor;
import org.apache.commons.dbcp2.BasicDataSource;

/**
* @author Taejin Koo
*/
@Scope(CommonsDbcp2Constants.SCOPE)
@TargetConstructor
public class DataSourceConstructorInterceptor implements AroundInterceptor {

private final DataSourceMonitorRegistry dataSourceMonitorRegistry;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,11 @@
import com.navercorp.pinpoint.bootstrap.context.SpanEventRecorder;
import com.navercorp.pinpoint.bootstrap.context.TraceContext;
import com.navercorp.pinpoint.bootstrap.interceptor.SpanEventSimpleAroundInterceptorForPlugin;
import com.navercorp.pinpoint.bootstrap.interceptor.annotation.Scope;
import com.navercorp.pinpoint.bootstrap.interceptor.annotation.TargetMethod;
import com.navercorp.pinpoint.bootstrap.interceptor.annotation.TargetMethods;
import com.navercorp.pinpoint.plugin.commons.dbcp2.CommonsDbcp2Constants;

@Scope(CommonsDbcp2Constants.SCOPE)
@TargetMethods({
@TargetMethod(name="getConnection"),
@TargetMethod(name="getConnection", paramTypes={"java.lang.String", "java.lang.String"})
})
/**
* @author Taejin Koo
*/
public class DataSourceGetConnectionInterceptor extends SpanEventSimpleAroundInterceptorForPlugin {

public DataSourceGetConnectionInterceptor(TraceContext traceContext, MethodDescriptor descriptor) {
Expand Down

0 comments on commit d506500

Please sign in to comment.