diff --git a/apm-sniffer/apm-sdk-plugin/h2-1.x-plugin/pom.xml b/apm-sniffer/apm-sdk-plugin/h2-1.x-plugin/pom.xml
new file mode 100755
index 0000000000000000000000000000000000000000..6ff404b59bf41dced1a64257a95e29862e837a0b
--- /dev/null
+++ b/apm-sniffer/apm-sdk-plugin/h2-1.x-plugin/pom.xml
@@ -0,0 +1,75 @@
+
+
+
+
+ apm-sdk-plugin
+ org.skywalking
+ 3.2.3-2017
+
+ 4.0.0
+
+ apm-h2-1.x-plugin
+ jar
+
+ h2-1.x-plugin
+ http://maven.apache.org
+
+
+ UTF-8
+
+
+
+
+ com.h2database
+ h2
+ 1.4.192
+ provided
+
+
+ org.skywalking
+ apm-jdbc-commons
+ ${project.version}
+ provided
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-deploy-plugin
+
+
+
+ org.apache.maven.plugins
+ maven-source-plugin
+
+
+
+ attach-sources
+
+ jar
+
+
+
+
+
+
+
diff --git a/apm-sniffer/apm-sdk-plugin/h2-1.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/h2/define/ConnectionInstrumentation.java b/apm-sniffer/apm-sdk-plugin/h2-1.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/h2/define/ConnectionInstrumentation.java
new file mode 100644
index 0000000000000000000000000000000000000000..d35f768fb6bd1dbe3d21f0c8a4cb1d1cae9efbc1
--- /dev/null
+++ b/apm-sniffer/apm-sdk-plugin/h2-1.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/h2/define/ConnectionInstrumentation.java
@@ -0,0 +1,148 @@
+/*
+ * Copyright 2017, OpenSkywalking Organization All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Project repository: https://github.com/OpenSkywalking/skywalking
+ */
+
+package org.skywalking.apm.plugin.jdbc.h2.define;
+
+import net.bytebuddy.description.method.MethodDescription;
+import net.bytebuddy.matcher.ElementMatcher;
+import org.skywalking.apm.agent.core.plugin.interceptor.ConstructorInterceptPoint;
+import org.skywalking.apm.agent.core.plugin.interceptor.InstanceMethodsInterceptPoint;
+import org.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine;
+import org.skywalking.apm.agent.core.plugin.match.ClassMatch;
+
+import static net.bytebuddy.matcher.ElementMatchers.named;
+import static net.bytebuddy.matcher.ElementMatchers.takesArguments;
+import static org.skywalking.apm.agent.core.plugin.match.NameMatch.byName;
+import static org.skywalking.apm.plugin.jdbc.define.Constants.CLOSE_METHOD_NAME;
+import static org.skywalking.apm.plugin.jdbc.define.Constants.COMMIT_METHOD_NAME;
+import static org.skywalking.apm.plugin.jdbc.define.Constants.CREATE_STATEMENT_INTERCEPT_CLASS;
+import static org.skywalking.apm.plugin.jdbc.define.Constants.CREATE_STATEMENT_METHOD_NAME;
+import static org.skywalking.apm.plugin.jdbc.define.Constants.PREPARE_CALL_INTERCEPT_CLASS;
+import static org.skywalking.apm.plugin.jdbc.define.Constants.PREPARE_CALL_METHOD_NAME;
+import static org.skywalking.apm.plugin.jdbc.define.Constants.PREPARE_STATEMENT_INTERCEPT_CLASS;
+import static org.skywalking.apm.plugin.jdbc.define.Constants.PREPARE_STATEMENT_METHOD_NAME;
+import static org.skywalking.apm.plugin.jdbc.define.Constants.RELEASE_SAVE_POINT_METHOD_NAME;
+import static org.skywalking.apm.plugin.jdbc.define.Constants.ROLLBACK_METHOD_NAME;
+import static org.skywalking.apm.plugin.jdbc.define.Constants.SERVICE_METHOD_INTERCEPT_CLASS;
+
+/**
+ * {@link ConnectionInstrumentation} intercept the following methods that the class which extend {@link
+ * org.h2.jdbc.JdbcConnection}.
+ *
+ * 1. Enhance prepareStatement
by org.skywalking.apm.plugin.jdbc.define.JDBCPrepareStatementInterceptor
+ * 3. Enhance prepareCall
by org.skywalking.apm.plugin.jdbc.define.JDBCPrepareCallInterceptor
+ * 4. Enhance createStatement
by org.skywalking.apm.plugin.jdbc.define.JDBCStatementInterceptor
+ * 5. Enhance commit, rollback, close, releaseSavepoint
by org.skywalking.apm.plugin.jdbc.define.ConnectionServiceMethodInterceptor
+ *
+ * @author zhangxin
+ */
+public class ConnectionInstrumentation extends ClassInstanceMethodsEnhancePluginDefine {
+
+ public static final String ENHANCE_CLASS = "org.h2.jdbc.JdbcConnection";
+
+ @Override protected ConstructorInterceptPoint[] getConstructorsInterceptPoints() {
+ return new ConstructorInterceptPoint[0];
+ }
+
+ @Override protected InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() {
+ return new InstanceMethodsInterceptPoint[] {
+ new InstanceMethodsInterceptPoint() {
+ @Override public ElementMatcher getMethodsMatcher() {
+ return named(PREPARE_STATEMENT_METHOD_NAME).and(takesArguments(1));
+ }
+
+ @Override public String getMethodsInterceptor() {
+ return PREPARE_STATEMENT_INTERCEPT_CLASS;
+ }
+
+ @Override public boolean isOverrideArgs() {
+ return false;
+ }
+ },
+ new InstanceMethodsInterceptPoint() {
+ @Override public ElementMatcher getMethodsMatcher() {
+ return named(PREPARE_STATEMENT_METHOD_NAME).and(takesArguments(3));
+ }
+
+ @Override public String getMethodsInterceptor() {
+ return PREPARE_STATEMENT_INTERCEPT_CLASS;
+ }
+
+ @Override public boolean isOverrideArgs() {
+ return false;
+ }
+ },
+ new InstanceMethodsInterceptPoint() {
+ @Override public ElementMatcher getMethodsMatcher() {
+ return named(PREPARE_STATEMENT_METHOD_NAME).and(takesArguments(4));
+ }
+
+ @Override public String getMethodsInterceptor() {
+ return PREPARE_STATEMENT_INTERCEPT_CLASS;
+ }
+
+ @Override public boolean isOverrideArgs() {
+ return false;
+ }
+ },
+ new InstanceMethodsInterceptPoint() {
+ @Override public ElementMatcher getMethodsMatcher() {
+ return named(PREPARE_CALL_METHOD_NAME);
+ }
+
+ @Override public String getMethodsInterceptor() {
+ return PREPARE_CALL_INTERCEPT_CLASS;
+ }
+
+ @Override public boolean isOverrideArgs() {
+ return false;
+ }
+ },
+ new InstanceMethodsInterceptPoint() {
+ @Override public ElementMatcher getMethodsMatcher() {
+ return named(CREATE_STATEMENT_METHOD_NAME);
+ }
+
+ @Override public String getMethodsInterceptor() {
+ return CREATE_STATEMENT_INTERCEPT_CLASS;
+ }
+
+ @Override public boolean isOverrideArgs() {
+ return false;
+ }
+ },
+ new InstanceMethodsInterceptPoint() {
+ @Override public ElementMatcher getMethodsMatcher() {
+ return named(COMMIT_METHOD_NAME).or(named(ROLLBACK_METHOD_NAME)).or(named(CLOSE_METHOD_NAME)).or(named(RELEASE_SAVE_POINT_METHOD_NAME));
+ }
+
+ @Override public String getMethodsInterceptor() {
+ return SERVICE_METHOD_INTERCEPT_CLASS;
+ }
+
+ @Override public boolean isOverrideArgs() {
+ return false;
+ }
+ }
+ };
+ }
+
+ @Override protected ClassMatch enhanceClass() {
+ return byName(ENHANCE_CLASS);
+ }
+}
diff --git a/apm-sniffer/apm-sdk-plugin/jdbc-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/define/H2Instrumentation.java b/apm-sniffer/apm-sdk-plugin/h2-1.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/h2/define/DriverInstrumentation.java
similarity index 78%
rename from apm-sniffer/apm-sdk-plugin/jdbc-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/define/H2Instrumentation.java
rename to apm-sniffer/apm-sdk-plugin/h2-1.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/h2/define/DriverInstrumentation.java
index bec3bb8b96f4d494e07bc586488f953fe69f2ce5..1ef501c52ef643d2da06fa557a309b5a42289c19 100644
--- a/apm-sniffer/apm-sdk-plugin/jdbc-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/define/H2Instrumentation.java
+++ b/apm-sniffer/apm-sdk-plugin/h2-1.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/h2/define/DriverInstrumentation.java
@@ -16,19 +16,19 @@
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
-package org.skywalking.apm.plugin.jdbc.define;
+package org.skywalking.apm.plugin.jdbc.h2.define;
import org.skywalking.apm.agent.core.plugin.match.ClassMatch;
+import org.skywalking.apm.plugin.jdbc.define.AbstractDriverInstrumentation;
import static org.skywalking.apm.agent.core.plugin.match.NameMatch.byName;
/**
- * {@link H2Instrumentation} presents that skywalking intercepts {@link org.h2.Driver}.
+ * {@link DriverInstrumentation} presents that skywalking intercepts {@link org.h2.Driver}.
*
* @author zhangxin
*/
-public class H2Instrumentation extends AbstractDatabaseInstrumentation {
-
+public class DriverInstrumentation extends AbstractDriverInstrumentation {
private static final String CLASS_OF_INTERCEPT_H2_DRIVER = "org.h2.Driver";
@Override
diff --git a/apm-sniffer/apm-sdk-plugin/h2-1.x-plugin/src/main/resources/skywalking-plugin.def b/apm-sniffer/apm-sdk-plugin/h2-1.x-plugin/src/main/resources/skywalking-plugin.def
new file mode 100644
index 0000000000000000000000000000000000000000..1e45a917f574783bb325cd378649fbbb002823b1
--- /dev/null
+++ b/apm-sniffer/apm-sdk-plugin/h2-1.x-plugin/src/main/resources/skywalking-plugin.def
@@ -0,0 +1,2 @@
+h2-1.x=org.skywalking.apm.plugin.jdbc.h2.define.DriverInstrumentation
+h2-1.x=org.skywalking.apm.plugin.jdbc.h2.define.ConnectionInstrumentation
diff --git a/apm-sniffer/apm-sdk-plugin/jdbc-commons/pom.xml b/apm-sniffer/apm-sdk-plugin/jdbc-commons/pom.xml
new file mode 100755
index 0000000000000000000000000000000000000000..6b0de026234a4ce72a7d104251fd4d1ac3e15328
--- /dev/null
+++ b/apm-sniffer/apm-sdk-plugin/jdbc-commons/pom.xml
@@ -0,0 +1,69 @@
+
+
+
+
+ apm-sdk-plugin
+ org.skywalking
+ 3.2.3-2017
+
+ 4.0.0
+
+ apm-jdbc-commons
+ jar
+
+ jdbc-commons
+ http://maven.apache.org
+
+
+ UTF-8
+
+
+
+
+ mysql
+ mysql-connector-java
+ [2.0.14,6.0.6]
+ test
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-deploy-plugin
+
+
+
+ org.apache.maven.plugins
+ maven-source-plugin
+
+
+
+ attach-sources
+
+ jar
+
+
+
+
+
+
+
diff --git a/apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/skywalking/apm/plugin/jdbc/ConnectionServiceMethodInterceptor.java b/apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/skywalking/apm/plugin/jdbc/ConnectionServiceMethodInterceptor.java
new file mode 100644
index 0000000000000000000000000000000000000000..0ae91f465c9b6edeb4bcaedefed0b45d2bf1278a
--- /dev/null
+++ b/apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/skywalking/apm/plugin/jdbc/ConnectionServiceMethodInterceptor.java
@@ -0,0 +1,75 @@
+/*
+ * Copyright 2017, OpenSkywalking Organization All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Project repository: https://github.com/OpenSkywalking/skywalking
+ */
+
+package org.skywalking.apm.plugin.jdbc;
+
+import java.lang.reflect.Method;
+import org.skywalking.apm.agent.core.context.ContextManager;
+import org.skywalking.apm.agent.core.context.tag.Tags;
+import org.skywalking.apm.agent.core.context.trace.AbstractSpan;
+import org.skywalking.apm.agent.core.context.trace.SpanLayer;
+import org.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
+import org.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
+import org.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult;
+import org.skywalking.apm.plugin.jdbc.trace.ConnectionInfo;
+import org.skywalking.apm.util.StringUtil;
+
+/**
+ * {@link ConnectionServiceMethodInterceptor} create an exit span when the client call the following methods in the class
+ * that extend {@link java.sql.Connection}.
+ * 1. close
+ * 2. rollback
+ * 3. releaseSavepoint
+ * 4. commit
+ * @author zhangxin
+ */
+public class ConnectionServiceMethodInterceptor implements InstanceMethodsAroundInterceptor {
+
+ @Override
+ public final void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments,
+ Class>[] argumentsTypes,
+ MethodInterceptResult result) throws Throwable {
+ ConnectionInfo connectInfo = (ConnectionInfo)objInst.getSkyWalkingDynamicField();
+ String remotePeer;
+ if (!StringUtil.isEmpty(connectInfo.getHosts())) {
+ remotePeer = connectInfo.getHosts();
+ } else {
+ remotePeer = connectInfo.getHost() + ":" + connectInfo.getPort();
+ }
+ AbstractSpan span = ContextManager.createExitSpan(connectInfo.getDBType() + "/JDBI/Connection/" + method.getName(), remotePeer);
+ Tags.DB_TYPE.set(span, "sql");
+ Tags.DB_INSTANCE.set(span, connectInfo.getDatabaseName());
+ Tags.DB_STATEMENT.set(span, "");
+ span.setComponent(connectInfo.getComponent());
+ SpanLayer.asDB(span);
+ }
+
+ @Override
+ public final Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments,
+ Class>[] argumentsTypes,
+ Object ret) throws Throwable {
+ ContextManager.stopSpan();
+ return ret;
+ }
+
+ @Override public final void handleMethodException(EnhancedInstance objInst, Method method, Object[] allArguments,
+ Class>[] argumentsTypes, Throwable t) {
+ ContextManager.activeSpan().errorOccurred().log(t);
+ }
+
+}
diff --git a/apm-sniffer/apm-sdk-plugin/jdbc-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/define/JDBCDriverInterceptor.java b/apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/skywalking/apm/plugin/jdbc/JDBCDriverInterceptor.java
similarity index 80%
rename from apm-sniffer/apm-sdk-plugin/jdbc-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/define/JDBCDriverInterceptor.java
rename to apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/skywalking/apm/plugin/jdbc/JDBCDriverInterceptor.java
index 073fe66105a8dac8840871904899e64b2b0e434f..acdccbe51637fe862f9013a78048b0ecaae73623 100644
--- a/apm-sniffer/apm-sdk-plugin/jdbc-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/define/JDBCDriverInterceptor.java
+++ b/apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/skywalking/apm/plugin/jdbc/JDBCDriverInterceptor.java
@@ -16,19 +16,18 @@
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
-package org.skywalking.apm.plugin.jdbc.define;
+package org.skywalking.apm.plugin.jdbc;
import java.lang.reflect.Method;
import java.sql.Connection;
-import java.util.Properties;
import org.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
import org.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
import org.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult;
-import org.skywalking.apm.plugin.jdbc.SWConnection;
+import org.skywalking.apm.plugin.jdbc.connectionurl.parser.URLParser;
/**
- * {@link JDBCDriverInterceptor} return {@link SWConnection} when {@link java.sql.Driver} to create connection,
- * instead of the {@link Connection} instance.
+ * {@link JDBCDriverInterceptor} set ConnectionInfo
to {@link Connection} object when {@link
+ * java.sql.Driver} to create connection, instead of the {@link Connection} instance.
*
* @author zhangxin
*/
@@ -42,8 +41,7 @@ public class JDBCDriverInterceptor implements InstanceMethodsAroundInterceptor {
@Override public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments,
Class>[] argumentsTypes, Object ret) throws Throwable {
if (ret != null) {
- return new SWConnection((String)allArguments[0],
- (Properties)allArguments[1], (Connection)ret);
+ ((EnhancedInstance)ret).setSkyWalkingDynamicField(URLParser.parser((String)allArguments[0]));
}
return ret;
diff --git a/apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/skywalking/apm/plugin/jdbc/JDBCPrepareCallInterceptor.java b/apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/skywalking/apm/plugin/jdbc/JDBCPrepareCallInterceptor.java
new file mode 100644
index 0000000000000000000000000000000000000000..0d89b5f91cd3d890de3ad9e2994a958c50bb3cef
--- /dev/null
+++ b/apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/skywalking/apm/plugin/jdbc/JDBCPrepareCallInterceptor.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2017, OpenSkywalking Organization All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Project repository: https://github.com/OpenSkywalking/skywalking
+ */
+
+package org.skywalking.apm.plugin.jdbc;
+
+import java.lang.reflect.Method;
+import java.sql.CallableStatement;
+import java.sql.Connection;
+import org.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
+import org.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
+import org.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult;
+import org.skywalking.apm.plugin.jdbc.trace.ConnectionInfo;
+import org.skywalking.apm.plugin.jdbc.trace.SWCallableStatement;
+
+/**
+ * {@link JDBCPrepareCallInterceptor} return {@link SWCallableStatement} instance that wrapper the real CallStatement
+ * instance when the client call prepareCall
method.
+ *
+ * @author zhangxin
+ */
+public class JDBCPrepareCallInterceptor implements InstanceMethodsAroundInterceptor {
+ @Override
+ public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class>[] argumentsTypes,
+ MethodInterceptResult result) throws Throwable {
+
+ }
+
+ @Override
+ public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class>[] argumentsTypes,
+ Object ret) throws Throwable {
+ if (objInst.getSkyWalkingDynamicField() == null) {
+ return ret;
+ }
+ return new SWCallableStatement((Connection)objInst, (CallableStatement)ret, (ConnectionInfo)objInst.getSkyWalkingDynamicField(), (String)allArguments[0]);
+ }
+
+ @Override public void handleMethodException(EnhancedInstance objInst, Method method, Object[] allArguments,
+ Class>[] argumentsTypes, Throwable t) {
+
+ }
+}
diff --git a/apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/skywalking/apm/plugin/jdbc/JDBCPrepareStatementInterceptor.java b/apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/skywalking/apm/plugin/jdbc/JDBCPrepareStatementInterceptor.java
new file mode 100644
index 0000000000000000000000000000000000000000..4b7a8a0bb51943eda0ed1f70352831250c8efb9d
--- /dev/null
+++ b/apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/skywalking/apm/plugin/jdbc/JDBCPrepareStatementInterceptor.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2017, OpenSkywalking Organization All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Project repository: https://github.com/OpenSkywalking/skywalking
+ */
+
+package org.skywalking.apm.plugin.jdbc;
+
+import java.lang.reflect.Method;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import org.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
+import org.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
+import org.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult;
+import org.skywalking.apm.plugin.jdbc.trace.ConnectionInfo;
+import org.skywalking.apm.plugin.jdbc.trace.SWPreparedStatement;
+
+/**
+ * {@link JDBCPrepareStatementInterceptor} return {@link SWPreparedStatement} instance that wrapper the real
+ * PreparedStatement instance when the client call prepareStatement
method.
+ *
+ * @author zhangxin
+ */
+public class JDBCPrepareStatementInterceptor implements InstanceMethodsAroundInterceptor {
+ @Override
+ public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class>[] argumentsTypes,
+ MethodInterceptResult result) throws Throwable {
+
+ }
+
+ @Override
+ public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class>[] argumentsTypes,
+ Object ret) throws Throwable {
+ if (objInst.getSkyWalkingDynamicField() == null) {
+ return ret;
+ }
+ return new SWPreparedStatement((Connection)objInst, (PreparedStatement)ret, (ConnectionInfo)objInst.getSkyWalkingDynamicField(), (String)allArguments[0]);
+ }
+
+ @Override public void handleMethodException(EnhancedInstance objInst, Method method, Object[] allArguments,
+ Class>[] argumentsTypes, Throwable t) {
+
+ }
+}
diff --git a/apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/skywalking/apm/plugin/jdbc/JDBCStatementInterceptor.java b/apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/skywalking/apm/plugin/jdbc/JDBCStatementInterceptor.java
new file mode 100644
index 0000000000000000000000000000000000000000..a11fce7efae94556d2d06ac4507c850dc9cc616c
--- /dev/null
+++ b/apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/skywalking/apm/plugin/jdbc/JDBCStatementInterceptor.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2017, OpenSkywalking Organization All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Project repository: https://github.com/OpenSkywalking/skywalking
+ */
+
+package org.skywalking.apm.plugin.jdbc;
+
+import java.lang.reflect.Method;
+import java.sql.Connection;
+import org.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
+import org.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
+import org.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult;
+import org.skywalking.apm.plugin.jdbc.trace.ConnectionInfo;
+import org.skywalking.apm.plugin.jdbc.trace.SWStatement;
+
+/**
+ * {@link JDBCStatementInterceptor} return {@link SWStatement} instance that wrapper the real Statement instance when
+ * the client call createStatement
method.
+ *
+ * @author zhangxin
+ */
+public class JDBCStatementInterceptor implements InstanceMethodsAroundInterceptor {
+ @Override
+ public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class>[] argumentsTypes,
+ MethodInterceptResult result) throws Throwable {
+
+ }
+
+ @Override
+ public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class>[] argumentsTypes,
+ Object ret) throws Throwable {
+ if (objInst.getSkyWalkingDynamicField() == null) {
+ return ret;
+ }
+ return new SWStatement((Connection)objInst, (java.sql.Statement)ret, (ConnectionInfo)objInst.getSkyWalkingDynamicField());
+ }
+
+ @Override public void handleMethodException(EnhancedInstance objInst, Method method, Object[] allArguments,
+ Class>[] argumentsTypes, Throwable t) {
+
+ }
+}
diff --git a/apm-sniffer/apm-sdk-plugin/jdbc-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/connectionurl/parser/AbstractURLParser.java b/apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/skywalking/apm/plugin/jdbc/connectionurl/parser/AbstractURLParser.java
similarity index 100%
rename from apm-sniffer/apm-sdk-plugin/jdbc-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/connectionurl/parser/AbstractURLParser.java
rename to apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/skywalking/apm/plugin/jdbc/connectionurl/parser/AbstractURLParser.java
diff --git a/apm-sniffer/apm-sdk-plugin/jdbc-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/connectionurl/parser/ConnectionURLParser.java b/apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/skywalking/apm/plugin/jdbc/connectionurl/parser/ConnectionURLParser.java
similarity index 94%
rename from apm-sniffer/apm-sdk-plugin/jdbc-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/connectionurl/parser/ConnectionURLParser.java
rename to apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/skywalking/apm/plugin/jdbc/connectionurl/parser/ConnectionURLParser.java
index cfed35cb866d84c206fa6bcb75a0030a585fa5e6..bd2b7c3b7c1fdd052490abd1f671a1f065534ba8 100644
--- a/apm-sniffer/apm-sdk-plugin/jdbc-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/connectionurl/parser/ConnectionURLParser.java
+++ b/apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/skywalking/apm/plugin/jdbc/connectionurl/parser/ConnectionURLParser.java
@@ -18,7 +18,7 @@
package org.skywalking.apm.plugin.jdbc.connectionurl.parser;
-import org.skywalking.apm.plugin.jdbc.ConnectionInfo;
+import org.skywalking.apm.plugin.jdbc.trace.ConnectionInfo;
public interface ConnectionURLParser {
/**
diff --git a/apm-sniffer/apm-sdk-plugin/jdbc-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/connectionurl/parser/H2URLParser.java b/apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/skywalking/apm/plugin/jdbc/connectionurl/parser/H2URLParser.java
similarity index 98%
rename from apm-sniffer/apm-sdk-plugin/jdbc-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/connectionurl/parser/H2URLParser.java
rename to apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/skywalking/apm/plugin/jdbc/connectionurl/parser/H2URLParser.java
index b53e5f1450a194266a40fa4a62aefce813828520..416b486984a9f13221e0c75e3f435653170973d0 100644
--- a/apm-sniffer/apm-sdk-plugin/jdbc-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/connectionurl/parser/H2URLParser.java
+++ b/apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/skywalking/apm/plugin/jdbc/connectionurl/parser/H2URLParser.java
@@ -19,7 +19,7 @@
package org.skywalking.apm.plugin.jdbc.connectionurl.parser;
import org.skywalking.apm.network.trace.component.ComponentsDefine;
-import org.skywalking.apm.plugin.jdbc.ConnectionInfo;
+import org.skywalking.apm.plugin.jdbc.trace.ConnectionInfo;
/**
* {@link H2URLParser} presents that skywalking how to parse the connection url of H2 database.
diff --git a/apm-sniffer/apm-sdk-plugin/jdbc-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/connectionurl/parser/MysqlURLParser.java b/apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/skywalking/apm/plugin/jdbc/connectionurl/parser/MysqlURLParser.java
similarity index 98%
rename from apm-sniffer/apm-sdk-plugin/jdbc-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/connectionurl/parser/MysqlURLParser.java
rename to apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/skywalking/apm/plugin/jdbc/connectionurl/parser/MysqlURLParser.java
index 8fbebba043b30779ed88285fc50209d6f9d4e556..0f71dd8c56a814a7d94256986e91b1b07f11e0ef 100644
--- a/apm-sniffer/apm-sdk-plugin/jdbc-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/connectionurl/parser/MysqlURLParser.java
+++ b/apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/skywalking/apm/plugin/jdbc/connectionurl/parser/MysqlURLParser.java
@@ -19,7 +19,7 @@
package org.skywalking.apm.plugin.jdbc.connectionurl.parser;
import org.skywalking.apm.network.trace.component.ComponentsDefine;
-import org.skywalking.apm.plugin.jdbc.ConnectionInfo;
+import org.skywalking.apm.plugin.jdbc.trace.ConnectionInfo;
/**
* {@link MysqlURLParser} parse connection url of mysql.
diff --git a/apm-sniffer/apm-sdk-plugin/jdbc-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/connectionurl/parser/OracleURLParser.java b/apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/skywalking/apm/plugin/jdbc/connectionurl/parser/OracleURLParser.java
similarity index 97%
rename from apm-sniffer/apm-sdk-plugin/jdbc-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/connectionurl/parser/OracleURLParser.java
rename to apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/skywalking/apm/plugin/jdbc/connectionurl/parser/OracleURLParser.java
index 0d84d2a2414deb47fd3b62e14fea12eedf090679..78523dab4a801e18c355c5ce6f97c608884975f3 100644
--- a/apm-sniffer/apm-sdk-plugin/jdbc-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/connectionurl/parser/OracleURLParser.java
+++ b/apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/skywalking/apm/plugin/jdbc/connectionurl/parser/OracleURLParser.java
@@ -19,7 +19,7 @@
package org.skywalking.apm.plugin.jdbc.connectionurl.parser;
import org.skywalking.apm.network.trace.component.ComponentsDefine;
-import org.skywalking.apm.plugin.jdbc.ConnectionInfo;
+import org.skywalking.apm.plugin.jdbc.trace.ConnectionInfo;
/**
* {@link OracleURLParser} presents that how to parse oracle connection url.
diff --git a/apm-sniffer/apm-sdk-plugin/jdbc-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/connectionurl/parser/PostgreSQLURLParser.java b/apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/skywalking/apm/plugin/jdbc/connectionurl/parser/PostgreSQLURLParser.java
similarity index 98%
rename from apm-sniffer/apm-sdk-plugin/jdbc-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/connectionurl/parser/PostgreSQLURLParser.java
rename to apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/skywalking/apm/plugin/jdbc/connectionurl/parser/PostgreSQLURLParser.java
index 3ce8604232e614209504fac3566905d5b1fadb66..2b2451aecd2ec6e388c7058d871a9eabb8f02efa 100644
--- a/apm-sniffer/apm-sdk-plugin/jdbc-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/connectionurl/parser/PostgreSQLURLParser.java
+++ b/apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/skywalking/apm/plugin/jdbc/connectionurl/parser/PostgreSQLURLParser.java
@@ -19,7 +19,7 @@
package org.skywalking.apm.plugin.jdbc.connectionurl.parser;
import org.skywalking.apm.network.trace.component.ComponentsDefine;
-import org.skywalking.apm.plugin.jdbc.ConnectionInfo;
+import org.skywalking.apm.plugin.jdbc.trace.ConnectionInfo;
/**
* {@link PostgreSQLURLParser} parse connection url of mysql.
diff --git a/apm-sniffer/apm-sdk-plugin/jdbc-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/connectionurl/parser/URLParser.java b/apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/skywalking/apm/plugin/jdbc/connectionurl/parser/URLParser.java
similarity index 96%
rename from apm-sniffer/apm-sdk-plugin/jdbc-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/connectionurl/parser/URLParser.java
rename to apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/skywalking/apm/plugin/jdbc/connectionurl/parser/URLParser.java
index ffc5ac051028368aa2f5056652c4a9348c25e5bc..6e2570a227eb2097deb21607722d6b4aa04800e0 100644
--- a/apm-sniffer/apm-sdk-plugin/jdbc-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/connectionurl/parser/URLParser.java
+++ b/apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/skywalking/apm/plugin/jdbc/connectionurl/parser/URLParser.java
@@ -18,7 +18,7 @@
package org.skywalking.apm.plugin.jdbc.connectionurl.parser;
-import org.skywalking.apm.plugin.jdbc.ConnectionInfo;
+import org.skywalking.apm.plugin.jdbc.trace.ConnectionInfo;
/**
* {@link URLParser#parser(String)} support parse the connection url, such as Mysql, Oracle, H2 Database. But there are
diff --git a/apm-sniffer/apm-sdk-plugin/jdbc-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/define/AbstractDatabaseInstrumentation.java b/apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/skywalking/apm/plugin/jdbc/define/AbstractDriverInstrumentation.java
similarity index 71%
rename from apm-sniffer/apm-sdk-plugin/jdbc-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/define/AbstractDatabaseInstrumentation.java
rename to apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/skywalking/apm/plugin/jdbc/define/AbstractDriverInstrumentation.java
index cb133f9ffc59de5c17a06d8bdc170777ecdacf27..e45b21033bba1b261389fb1746788fb42c4ae692 100644
--- a/apm-sniffer/apm-sdk-plugin/jdbc-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/define/AbstractDatabaseInstrumentation.java
+++ b/apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/skywalking/apm/plugin/jdbc/define/AbstractDriverInstrumentation.java
@@ -23,29 +23,26 @@ import net.bytebuddy.matcher.ElementMatcher;
import org.skywalking.apm.agent.core.plugin.interceptor.ConstructorInterceptPoint;
import org.skywalking.apm.agent.core.plugin.interceptor.InstanceMethodsInterceptPoint;
import org.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine;
-import org.skywalking.apm.plugin.jdbc.SWConnection;
+import org.skywalking.apm.plugin.jdbc.JDBCDriverInterceptor;
import static net.bytebuddy.matcher.ElementMatchers.named;
/**
- * JDBC plugin using {@link JDBCDriverInterceptor} to intercept all the class that it has extend {@link
- * java.sql.Driver#connect(String, java.util.Properties)}, and change the return object to {@link
- * SWConnection}, All the method of {@link SWConnection}
- * is delegate to the real JDBC Driver Connection object.
+ * JDBC plugin using {@link JDBCDriverInterceptor} to intercept the connect
method of all driver class.
*
* @author zhangxin
*/
-public abstract class AbstractDatabaseInstrumentation extends ClassInstanceMethodsEnhancePluginDefine {
+public abstract class AbstractDriverInstrumentation extends ClassInstanceMethodsEnhancePluginDefine {
- private static final String INTERCEPT_CLASS = "org.skywalking.apm.plugin.jdbc.define.JDBCDriverInterceptor";
+ private static final String DRIVER_INTERCEPT_CLASS = "org.skywalking.apm.plugin.jdbc.define.JDBCDriverInterceptor";
@Override
- protected ConstructorInterceptPoint[] getConstructorsInterceptPoints() {
- return null;
+ protected final ConstructorInterceptPoint[] getConstructorsInterceptPoints() {
+ return new ConstructorInterceptPoint[0];
}
@Override
- protected InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() {
+ protected final InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() {
return new InstanceMethodsInterceptPoint[] {
new InstanceMethodsInterceptPoint() {
@Override
@@ -55,7 +52,7 @@ public abstract class AbstractDatabaseInstrumentation extends ClassInstanceMetho
@Override
public String getMethodsInterceptor() {
- return INTERCEPT_CLASS;
+ return DRIVER_INTERCEPT_CLASS;
}
@Override public boolean isOverrideArgs() {
diff --git a/apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/skywalking/apm/plugin/jdbc/define/Constants.java b/apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/skywalking/apm/plugin/jdbc/define/Constants.java
new file mode 100644
index 0000000000000000000000000000000000000000..504a48151d5c947d495b1d93b8fc3619227df11b
--- /dev/null
+++ b/apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/skywalking/apm/plugin/jdbc/define/Constants.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2017, OpenSkywalking Organization All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Project repository: https://github.com/OpenSkywalking/skywalking
+ */
+
+package org.skywalking.apm.plugin.jdbc.define;
+
+public class Constants {
+ public static final String CREATE_STATEMENT_INTERCEPT_CLASS = "org.skywalking.apm.plugin.jdbc.define.JDBCStatementInterceptor";
+
+ public static final String PREPARE_STATEMENT_INTERCEPT_CLASS = "org.skywalking.apm.plugin.jdbc.define.JDBCPrepareStatementInterceptor";
+
+ public static final String PREPARE_CALL_INTERCEPT_CLASS = "org.skywalking.apm.plugin.jdbc.define.JDBCPrepareCallInterceptor";
+
+ public static final String SERVICE_METHOD_INTERCEPT_CLASS = "org.skywalking.apm.plugin.jdbc.define.ConnectionServiceMethodInterceptor";
+
+ public static final String PREPARE_STATEMENT_METHOD_NAME = "prepareStatement";
+
+ public static final String PREPARE_CALL_METHOD_NAME = "prepareCall";
+
+ public static final String CREATE_STATEMENT_METHOD_NAME = "createStatement";
+
+ public static final String COMMIT_METHOD_NAME = "commit";
+
+ public static final String ROLLBACK_METHOD_NAME = "rollback";
+
+ public static final String CLOSE_METHOD_NAME = "close";
+
+ public static final String RELEASE_SAVE_POINT_METHOD_NAME = "releaseSavepoint";
+
+}
diff --git a/apm-sniffer/apm-sdk-plugin/jdbc-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/CallableStatementTracing.java b/apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/skywalking/apm/plugin/jdbc/trace/CallableStatementTracing.java
similarity index 91%
rename from apm-sniffer/apm-sdk-plugin/jdbc-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/CallableStatementTracing.java
rename to apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/skywalking/apm/plugin/jdbc/trace/CallableStatementTracing.java
index 348ffdb1eafdd4353680477192f34801e30ac21b..d0b25cc94ffa470a1c67357e9b71c7f7b17ca3b8 100644
--- a/apm-sniffer/apm-sdk-plugin/jdbc-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/CallableStatementTracing.java
+++ b/apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/skywalking/apm/plugin/jdbc/trace/CallableStatementTracing.java
@@ -16,7 +16,7 @@
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
-package org.skywalking.apm.plugin.jdbc;
+package org.skywalking.apm.plugin.jdbc.trace;
import java.sql.SQLException;
import org.skywalking.apm.agent.core.context.ContextManager;
@@ -25,6 +25,12 @@ import org.skywalking.apm.agent.core.context.trace.AbstractSpan;
import org.skywalking.apm.agent.core.context.trace.SpanLayer;
import org.skywalking.apm.util.StringUtil;
+/**
+ * {@link CallableStatementTracing} create an exit span when the client call the method in the class that extend {@link
+ * java.sql.CallableStatement}.
+ *
+ * @author zhangxin
+ */
public class CallableStatementTracing {
public static R execute(java.sql.CallableStatement realStatement,
diff --git a/apm-sniffer/apm-sdk-plugin/jdbc-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/ConnectionInfo.java b/apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/skywalking/apm/plugin/jdbc/trace/ConnectionInfo.java
similarity index 98%
rename from apm-sniffer/apm-sdk-plugin/jdbc-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/ConnectionInfo.java
rename to apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/skywalking/apm/plugin/jdbc/trace/ConnectionInfo.java
index 67ba05d136470939d7a20903f251c8b0b77f353b..a9ab5e5c41fdd7ee5165192c2d69783fcf3eabca 100644
--- a/apm-sniffer/apm-sdk-plugin/jdbc-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/ConnectionInfo.java
+++ b/apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/skywalking/apm/plugin/jdbc/trace/ConnectionInfo.java
@@ -16,7 +16,7 @@
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
-package org.skywalking.apm.plugin.jdbc;
+package org.skywalking.apm.plugin.jdbc.trace;
import org.skywalking.apm.network.trace.component.OfficialComponent;
diff --git a/apm-sniffer/apm-sdk-plugin/jdbc-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/PreparedStatementTracing.java b/apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/skywalking/apm/plugin/jdbc/trace/PreparedStatementTracing.java
similarity index 91%
rename from apm-sniffer/apm-sdk-plugin/jdbc-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/PreparedStatementTracing.java
rename to apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/skywalking/apm/plugin/jdbc/trace/PreparedStatementTracing.java
index 5146d9d1428869f2e6ed64631770e7d7d500f4ca..66d0f9f168f77450dbcdc2d748394699013cb84c 100644
--- a/apm-sniffer/apm-sdk-plugin/jdbc-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/PreparedStatementTracing.java
+++ b/apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/skywalking/apm/plugin/jdbc/trace/PreparedStatementTracing.java
@@ -16,7 +16,7 @@
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
-package org.skywalking.apm.plugin.jdbc;
+package org.skywalking.apm.plugin.jdbc.trace;
import java.sql.SQLException;
import org.skywalking.apm.agent.core.context.ContextManager;
@@ -25,6 +25,12 @@ import org.skywalking.apm.agent.core.context.trace.AbstractSpan;
import org.skywalking.apm.agent.core.context.trace.SpanLayer;
import org.skywalking.apm.util.StringUtil;
+/**
+ * {@link PreparedStatementTracing} create an exit span when the client call the method in the class that extend {@link
+ * java.sql.PreparedStatement}.
+ *
+ * @author zhangxin
+ */
public class PreparedStatementTracing {
public static R execute(java.sql.PreparedStatement realStatement,
diff --git a/apm-sniffer/apm-sdk-plugin/jdbc-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/SWCallableStatement.java b/apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/skywalking/apm/plugin/jdbc/trace/SWCallableStatement.java
similarity index 97%
rename from apm-sniffer/apm-sdk-plugin/jdbc-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/SWCallableStatement.java
rename to apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/skywalking/apm/plugin/jdbc/trace/SWCallableStatement.java
index 6e99972cf6aaf68f44dd3ddd40722a5fb5f62d79..5827cf00d79f0b31c465bc030cb2272b32859f55 100644
--- a/apm-sniffer/apm-sdk-plugin/jdbc-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/SWCallableStatement.java
+++ b/apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/skywalking/apm/plugin/jdbc/trace/SWCallableStatement.java
@@ -16,7 +16,7 @@
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
-package org.skywalking.apm.plugin.jdbc;
+package org.skywalking.apm.plugin.jdbc.trace;
import java.io.InputStream;
import java.io.Reader;
@@ -42,13 +42,33 @@ import java.sql.Timestamp;
import java.util.Calendar;
import java.util.Map;
+/**
+ * {@link SWCallableStatement} wrapper the {@link CallableStatement} created by client. and it will interceptor the
+ * following methods for trace.
+ * 1. {@link #execute()}
+ * 2. {@link #execute(String)}
+ * 3. {@link #execute(String, int[])}
+ * 4. {@link #execute(String, String[])}
+ * 5. {@link #execute(String, int)}
+ * 6. {@link #executeQuery()}
+ * 7. {@link #executeQuery(String)}
+ * 8. {@link #executeUpdate()}
+ * 9. {@link #executeUpdate(String)}
+ * 10. {@link #executeUpdate(String, int[])}
+ * 11. {@link #executeUpdate(String, String[])}
+ * 12. {@link #executeUpdate(String, int)}
+ * 13. {@link #addBatch()}
+ * 14. {@link #addBatch(String)} ()}
+ *
+ * @author zhangxin
+ */
public class SWCallableStatement implements CallableStatement {
private Connection realConnection;
private CallableStatement realStatement;
private ConnectionInfo connectInfo;
private String sql;
- SWCallableStatement(Connection realConnection,
+ public SWCallableStatement(Connection realConnection,
CallableStatement realStatement, ConnectionInfo connectInfo,
String sql) {
this.realConnection = realConnection;
diff --git a/apm-sniffer/apm-sdk-plugin/jdbc-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/SWPreparedStatement.java b/apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/skywalking/apm/plugin/jdbc/trace/SWPreparedStatement.java
similarity index 96%
rename from apm-sniffer/apm-sdk-plugin/jdbc-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/SWPreparedStatement.java
rename to apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/skywalking/apm/plugin/jdbc/trace/SWPreparedStatement.java
index c472b2c42ade808a2994bc89b23df4d0e1a0c33f..b3c135c8406804c239cf23962077f2a7643152ff 100644
--- a/apm-sniffer/apm-sdk-plugin/jdbc-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/SWPreparedStatement.java
+++ b/apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/skywalking/apm/plugin/jdbc/trace/SWPreparedStatement.java
@@ -16,7 +16,7 @@
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
-package org.skywalking.apm.plugin.jdbc;
+package org.skywalking.apm.plugin.jdbc.trace;
import java.io.InputStream;
import java.io.Reader;
@@ -41,13 +41,33 @@ import java.sql.Time;
import java.sql.Timestamp;
import java.util.Calendar;
+/**
+ * {@link SWPreparedStatement} wrapper the {@link PreparedStatement} created by client. and it will interceptor the
+ * following methods for trace.
+ * 1. {@link #execute()}
+ * 2. {@link #execute(String)}
+ * 3. {@link #execute(String, int[])}
+ * 4. {@link #execute(String, String[])}
+ * 5. {@link #execute(String, int)}
+ * 6. {@link #executeQuery()}
+ * 7. {@link #executeQuery(String)}
+ * 8. {@link #executeUpdate()}
+ * 9. {@link #executeUpdate(String)}
+ * 10. {@link #executeUpdate(String, int[])}
+ * 11. {@link #executeUpdate(String, String[])}
+ * 12. {@link #executeUpdate(String, int)}
+ * 13. {@link #addBatch()}
+ * 14. {@link #addBatch(String)} ()}
+ *
+ * @author zhangxin
+ */
public class SWPreparedStatement implements PreparedStatement {
private Connection realConnection;
private PreparedStatement realStatement;
private ConnectionInfo connectInfo;
private String sql;
- SWPreparedStatement(Connection realConnection,
+ public SWPreparedStatement(Connection realConnection,
PreparedStatement realStatement, ConnectionInfo connectInfo,
String sql) {
this.realConnection = realConnection;
diff --git a/apm-sniffer/apm-sdk-plugin/jdbc-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/SWStatement.java b/apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/skywalking/apm/plugin/jdbc/trace/SWStatement.java
similarity index 92%
rename from apm-sniffer/apm-sdk-plugin/jdbc-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/SWStatement.java
rename to apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/skywalking/apm/plugin/jdbc/trace/SWStatement.java
index b3a5c7e6792a463627e6c1c489c240176472b3e0..850be702f412b157854308089ffd7ec0c15e9f8e 100644
--- a/apm-sniffer/apm-sdk-plugin/jdbc-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/SWStatement.java
+++ b/apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/skywalking/apm/plugin/jdbc/trace/SWStatement.java
@@ -16,19 +16,36 @@
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
-package org.skywalking.apm.plugin.jdbc;
+package org.skywalking.apm.plugin.jdbc.trace;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.SQLWarning;
+/**
+ * {@link SWStatement} wrapper the {@link java.sql.Statement} created by client. and it will interceptor the
+ * following methods for trace.
+ * 1. {@link #execute(String)}
+ * 2. {@link #execute(String, int[])}
+ * 3. {@link #execute(String, String[])}
+ * 4. {@link #execute(String, int)}
+ * 5. {@link #executeQuery(String)}
+ * 6. {@link #executeUpdate(String)}
+ * 7. {@link #executeUpdate(String, int[])}
+ * 8. {@link #executeUpdate(String, String[])}
+ * 9. {@link #executeUpdate(String, int)}
+ * 10. {@link #addBatch(String)} ()}
+ *
+ * @author zhangxin
+ */
+
public class SWStatement implements java.sql.Statement {
private Connection realConnection;
private java.sql.Statement realStatement;
private ConnectionInfo connectInfo;
- SWStatement(Connection realConnection, java.sql.Statement realStatement, ConnectionInfo connectInfo) {
+ public SWStatement(Connection realConnection, java.sql.Statement realStatement, ConnectionInfo connectInfo) {
this.realConnection = realConnection;
this.realStatement = realStatement;
this.connectInfo = connectInfo;
diff --git a/apm-sniffer/apm-sdk-plugin/jdbc-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/StatementTracing.java b/apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/skywalking/apm/plugin/jdbc/trace/StatementTracing.java
similarity index 91%
rename from apm-sniffer/apm-sdk-plugin/jdbc-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/StatementTracing.java
rename to apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/skywalking/apm/plugin/jdbc/trace/StatementTracing.java
index 28c4021092a2259f1589cc9dd9ff7400f09ea277..20e44032b1fa0787c9831c0218d4f59d95283c87 100644
--- a/apm-sniffer/apm-sdk-plugin/jdbc-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/StatementTracing.java
+++ b/apm-sniffer/apm-sdk-plugin/jdbc-commons/src/main/java/org/skywalking/apm/plugin/jdbc/trace/StatementTracing.java
@@ -16,7 +16,7 @@
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
-package org.skywalking.apm.plugin.jdbc;
+package org.skywalking.apm.plugin.jdbc.trace;
import java.sql.SQLException;
import org.skywalking.apm.agent.core.context.ContextManager;
@@ -25,6 +25,12 @@ import org.skywalking.apm.agent.core.context.trace.AbstractSpan;
import org.skywalking.apm.agent.core.context.trace.SpanLayer;
import org.skywalking.apm.util.StringUtil;
+/**
+ * {@link PreparedStatementTracing} create an exit span when the client call the method in the class that extend {@link
+ * java.sql.Statement}.
+ *
+ * @author zhangxin
+ */
public class StatementTracing {
public static R execute(java.sql.Statement realStatement,
ConnectionInfo connectInfo, String method, String sql, Executable exec)
diff --git a/apm-sniffer/apm-sdk-plugin/jdbc-plugin/src/test/java/org/skywalking/apm/plugin/jdbc/AbstractStatementTest.java b/apm-sniffer/apm-sdk-plugin/jdbc-commons/src/test/java/org/skywalking/apm/plugin/jdbc/AbstractStatementTest.java
similarity index 100%
rename from apm-sniffer/apm-sdk-plugin/jdbc-plugin/src/test/java/org/skywalking/apm/plugin/jdbc/AbstractStatementTest.java
rename to apm-sniffer/apm-sdk-plugin/jdbc-commons/src/test/java/org/skywalking/apm/plugin/jdbc/AbstractStatementTest.java
diff --git a/apm-sniffer/apm-sdk-plugin/jdbc-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/ConnectionTracing.java b/apm-sniffer/apm-sdk-plugin/jdbc-commons/src/test/java/org/skywalking/apm/plugin/jdbc/ConnectionTracing.java
similarity index 97%
rename from apm-sniffer/apm-sdk-plugin/jdbc-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/ConnectionTracing.java
rename to apm-sniffer/apm-sdk-plugin/jdbc-commons/src/test/java/org/skywalking/apm/plugin/jdbc/ConnectionTracing.java
index 2adc0c7b3f340f2352c8ebc7306fb0e8b3ede999..8432fd9144ed4a6217af74a1d9ea658ce4f2840b 100755
--- a/apm-sniffer/apm-sdk-plugin/jdbc-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/ConnectionTracing.java
+++ b/apm-sniffer/apm-sdk-plugin/jdbc-commons/src/test/java/org/skywalking/apm/plugin/jdbc/ConnectionTracing.java
@@ -23,6 +23,7 @@ import org.skywalking.apm.agent.core.context.ContextManager;
import org.skywalking.apm.agent.core.context.tag.Tags;
import org.skywalking.apm.agent.core.context.trace.AbstractSpan;
import org.skywalking.apm.agent.core.context.trace.SpanLayer;
+import org.skywalking.apm.plugin.jdbc.trace.ConnectionInfo;
import org.skywalking.apm.util.StringUtil;
public class ConnectionTracing {
diff --git a/apm-sniffer/apm-sdk-plugin/jdbc-plugin/src/test/java/org/skywalking/apm/plugin/jdbc/SWCallableStatementTest.java b/apm-sniffer/apm-sdk-plugin/jdbc-commons/src/test/java/org/skywalking/apm/plugin/jdbc/SWCallableStatementTest.java
similarity index 97%
rename from apm-sniffer/apm-sdk-plugin/jdbc-plugin/src/test/java/org/skywalking/apm/plugin/jdbc/SWCallableStatementTest.java
rename to apm-sniffer/apm-sdk-plugin/jdbc-commons/src/test/java/org/skywalking/apm/plugin/jdbc/SWCallableStatementTest.java
index 0d81f1258640b4d5ba884b23515e13b378d71ab0..62e416fd500e3b427f26201a530a40761695ed30 100644
--- a/apm-sniffer/apm-sdk-plugin/jdbc-plugin/src/test/java/org/skywalking/apm/plugin/jdbc/SWCallableStatementTest.java
+++ b/apm-sniffer/apm-sdk-plugin/jdbc-commons/src/test/java/org/skywalking/apm/plugin/jdbc/SWCallableStatementTest.java
@@ -124,11 +124,11 @@ public class SWCallableStatementTest extends AbstractStatementTest {
@Test
public void testSetParam() throws SQLException, MalformedURLException {
- CallableStatement callableStatement = multiHostConnection.prepareCall("SELECT * FROM test WHERE a = ? or b = ? or c=? or d = ? or e = ?" +
- " or e = ? or f = ? or g = ? or h = ? or i = ? or j = ? or k = ? or l = ? or m = ? or n = ? or o = ? or p = ? " +
- " or r = ? or s = ? or t = ? or u = ? or v = ? or w = ? or x = ? or y = ? or z = ? or a1 = ? or a2 = ? or a3 = ?" +
- " or a4 = ? or a5 = ? or a6 = ? or a7 = ? or a8 = ? or a9 = ? or b1 = ? or b2 = ? or b3 = ? or b4 = ? or b5 = ?" +
- " or b6 = ? or b7 = ? or b8 = ? or b9 = ? or c1 = ? or c2 = ? or c3 = ?");
+ CallableStatement callableStatement = multiHostConnection.prepareCall("SELECT * FROM test WHERE a = ? OR b = ? OR c=? OR d = ? OR e = ?" +
+ " OR e = ? OR f = ? OR g = ? OR h = ? OR i = ? OR j = ? OR k = ? OR l = ? OR m = ? OR n = ? OR o = ? OR p = ? " +
+ " OR r = ? OR s = ? OR t = ? OR u = ? OR v = ? OR w = ? OR x = ? OR y = ? OR z = ? OR a1 = ? OR a2 = ? OR a3 = ?" +
+ " OR a4 = ? OR a5 = ? OR a6 = ? OR a7 = ? OR a8 = ? OR a9 = ? OR b1 = ? OR b2 = ? OR b3 = ? OR b4 = ? OR b5 = ?" +
+ " OR b6 = ? OR b7 = ? OR b8 = ? OR b9 = ? OR c1 = ? OR c2 = ? OR c3 = ?");
callableStatement.clearParameters();
callableStatement.setAsciiStream(1, inputStream);
callableStatement.setAsciiStream(2, inputStream, 10);
@@ -666,7 +666,7 @@ public class SWCallableStatementTest extends AbstractStatementTest {
@Test
public void testQueryWithMultiHost() throws SQLException {
- CallableStatement preparedStatement = multiHostConnection.prepareCall("SELECT * FROM test WHERE a = ? or b = ? or c=? or d = ?", 1, 1);
+ CallableStatement preparedStatement = multiHostConnection.prepareCall("SELECT * FROM test WHERE a = ? OR b = ? OR c=? OR d = ?", 1, 1);
preparedStatement.setAsciiStream(1, inputStream);
preparedStatement.setAsciiStream(2, inputStream, 10);
preparedStatement.setAsciiStream(3, inputStream, 1000000L);
@@ -683,7 +683,7 @@ public class SWCallableStatementTest extends AbstractStatementTest {
public void testMultiHostWithException() throws SQLException {
when(mysqlCallableStatement.executeQuery()).thenThrow(new SQLException());
try {
- CallableStatement preparedStatement = multiHostConnection.prepareCall("SELECT * FROM test WHERE a = ? or b = ? or c=? or d = ? or e=?");
+ CallableStatement preparedStatement = multiHostConnection.prepareCall("SELECT * FROM test WHERE a = ? OR b = ? OR c=? OR d = ? OR e=?");
preparedStatement.setBigDecimal(1, new BigDecimal(10000));
preparedStatement.setBlob(2, inputStream);
preparedStatement.setBlob(3, inputStream, 1000000L);
@@ -705,7 +705,7 @@ public class SWCallableStatementTest extends AbstractStatementTest {
TraceSegment traceSegment = segmentStorage.getTraceSegments().get(0);
List spans = SegmentHelper.getSpans(traceSegment);
assertThat(spans.size(), is(1));
- assertDBSpan(spans.get(0), "Mysql/JDBI/CallableStatement/executeQuery", "SELECT * FROM test WHERE a = ? or b = ? or c=? or d = ? or e=?");
+ assertDBSpan(spans.get(0), "Mysql/JDBI/CallableStatement/executeQuery", "SELECT * FROM test WHERE a = ? OR b = ? OR c=? OR d = ? OR e=?");
List logs = SpanHelper.getLogs(spans.get(0));
Assert.assertThat(logs.size(), is(1));
assertDBSpanLog(logs.get(0));
diff --git a/apm-sniffer/apm-sdk-plugin/jdbc-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/SWConnection.java b/apm-sniffer/apm-sdk-plugin/jdbc-commons/src/test/java/org/skywalking/apm/plugin/jdbc/SWConnection.java
old mode 100755
new mode 100644
similarity index 97%
rename from apm-sniffer/apm-sdk-plugin/jdbc-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/SWConnection.java
rename to apm-sniffer/apm-sdk-plugin/jdbc-commons/src/test/java/org/skywalking/apm/plugin/jdbc/SWConnection.java
index 9c7f355ac90571a9ba993a41a87b76a8c5c2f2ed..2e685a4b153234bdc6b0ac1ef20af14f32770683
--- a/apm-sniffer/apm-sdk-plugin/jdbc-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/SWConnection.java
+++ b/apm-sniffer/apm-sdk-plugin/jdbc-commons/src/test/java/org/skywalking/apm/plugin/jdbc/SWConnection.java
@@ -37,6 +37,10 @@ import java.util.Map;
import java.util.Properties;
import java.util.concurrent.Executor;
import org.skywalking.apm.plugin.jdbc.connectionurl.parser.URLParser;
+import org.skywalking.apm.plugin.jdbc.trace.ConnectionInfo;
+import org.skywalking.apm.plugin.jdbc.trace.SWCallableStatement;
+import org.skywalking.apm.plugin.jdbc.trace.SWPreparedStatement;
+import org.skywalking.apm.plugin.jdbc.trace.SWStatement;
public class SWConnection implements Connection {
private ConnectionInfo connectInfo;
diff --git a/apm-sniffer/apm-sdk-plugin/jdbc-plugin/src/test/java/org/skywalking/apm/plugin/jdbc/SWConnectionTest.java b/apm-sniffer/apm-sdk-plugin/jdbc-commons/src/test/java/org/skywalking/apm/plugin/jdbc/SWConnectionTest.java
similarity index 100%
rename from apm-sniffer/apm-sdk-plugin/jdbc-plugin/src/test/java/org/skywalking/apm/plugin/jdbc/SWConnectionTest.java
rename to apm-sniffer/apm-sdk-plugin/jdbc-commons/src/test/java/org/skywalking/apm/plugin/jdbc/SWConnectionTest.java
diff --git a/apm-sniffer/apm-sdk-plugin/jdbc-plugin/src/test/java/org/skywalking/apm/plugin/jdbc/SWStatementTest.java b/apm-sniffer/apm-sdk-plugin/jdbc-commons/src/test/java/org/skywalking/apm/plugin/jdbc/SWStatementTest.java
similarity index 100%
rename from apm-sniffer/apm-sdk-plugin/jdbc-plugin/src/test/java/org/skywalking/apm/plugin/jdbc/SWStatementTest.java
rename to apm-sniffer/apm-sdk-plugin/jdbc-commons/src/test/java/org/skywalking/apm/plugin/jdbc/SWStatementTest.java
diff --git a/apm-sniffer/apm-sdk-plugin/jdbc-plugin/src/test/java/org/skywalking/apm/plugin/jdbc/SwPreparedStatementTest.java b/apm-sniffer/apm-sdk-plugin/jdbc-commons/src/test/java/org/skywalking/apm/plugin/jdbc/SwPreparedStatementTest.java
similarity index 100%
rename from apm-sniffer/apm-sdk-plugin/jdbc-plugin/src/test/java/org/skywalking/apm/plugin/jdbc/SwPreparedStatementTest.java
rename to apm-sniffer/apm-sdk-plugin/jdbc-commons/src/test/java/org/skywalking/apm/plugin/jdbc/SwPreparedStatementTest.java
diff --git a/apm-sniffer/apm-sdk-plugin/jdbc-plugin/src/test/java/org/skywalking/apm/plugin/jdbc/connectionurl/parser/URLParserTest.java b/apm-sniffer/apm-sdk-plugin/jdbc-commons/src/test/java/org/skywalking/apm/plugin/jdbc/connectionurl/parser/URLParserTest.java
similarity index 98%
rename from apm-sniffer/apm-sdk-plugin/jdbc-plugin/src/test/java/org/skywalking/apm/plugin/jdbc/connectionurl/parser/URLParserTest.java
rename to apm-sniffer/apm-sdk-plugin/jdbc-commons/src/test/java/org/skywalking/apm/plugin/jdbc/connectionurl/parser/URLParserTest.java
index 7b4158bf2b69cf890b1e9086dfb940b1b1cb90ce..6d24e76aa04140608b12996fcb5afe2e7c02f068 100644
--- a/apm-sniffer/apm-sdk-plugin/jdbc-plugin/src/test/java/org/skywalking/apm/plugin/jdbc/connectionurl/parser/URLParserTest.java
+++ b/apm-sniffer/apm-sdk-plugin/jdbc-commons/src/test/java/org/skywalking/apm/plugin/jdbc/connectionurl/parser/URLParserTest.java
@@ -19,7 +19,7 @@
package org.skywalking.apm.plugin.jdbc.connectionurl.parser;
import org.junit.Test;
-import org.skywalking.apm.plugin.jdbc.ConnectionInfo;
+import org.skywalking.apm.plugin.jdbc.trace.ConnectionInfo;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
@@ -121,4 +121,4 @@ public class URLParserTest {
assertThat(connectionInfo.getHost(), is("localhost"));
assertThat(connectionInfo.getPort(), is(8084));
}
-}
\ No newline at end of file
+}
diff --git a/apm-sniffer/apm-sdk-plugin/jdbc-plugin/src/main/resources/skywalking-plugin.def b/apm-sniffer/apm-sdk-plugin/jdbc-plugin/src/main/resources/skywalking-plugin.def
deleted file mode 100644
index a28a6c03dab0588174ea364ba15413abdd791517..0000000000000000000000000000000000000000
--- a/apm-sniffer/apm-sdk-plugin/jdbc-plugin/src/main/resources/skywalking-plugin.def
+++ /dev/null
@@ -1,4 +0,0 @@
-jdbc=org.skywalking.apm.plugin.jdbc.define.H2Instrumentation
-jdbc=org.skywalking.apm.plugin.jdbc.define.MysqlInstrumentation
-jdbc=org.skywalking.apm.plugin.jdbc.define.OracleInstrumentation
-jdbc=org.skywalking.apm.plugin.jdbc.define.PostgreSQLInstrumentation
diff --git a/apm-sniffer/apm-sdk-plugin/jdbc-plugin/pom.xml b/apm-sniffer/apm-sdk-plugin/mysql-2.x-plugin/pom.xml
similarity index 81%
rename from apm-sniffer/apm-sdk-plugin/jdbc-plugin/pom.xml
rename to apm-sniffer/apm-sdk-plugin/mysql-2.x-plugin/pom.xml
index c271e7fa74fa42fbc3efd24e2e45d66ed311849a..efcbfa22fee0cd4fabbbedbc411dc8574f390bb7 100755
--- a/apm-sniffer/apm-sdk-plugin/jdbc-plugin/pom.xml
+++ b/apm-sniffer/apm-sdk-plugin/mysql-2.x-plugin/pom.xml
@@ -25,10 +25,10 @@
4.0.0
- apm-jdbc-plugin
+ apm-mysql-2.x-plugin
jar
- jdbc-plugin
+ mysql-2.x-plugin
http://maven.apache.org
@@ -42,18 +42,6 @@
5.1.36
test
-
- com.oracle
- ojdbc14
- 10.2.0.4.0
- test
-
-
- com.h2database
- h2
- 1.4.192
- provided
-
mysql
mysql-connector-java
@@ -61,9 +49,9 @@
provided
- org.postgresql
- postgresql
- 42.0.0
+ org.skywalking
+ apm-jdbc-commons
+ ${project.version}
provided
diff --git a/apm-sniffer/apm-sdk-plugin/mysql-2.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/mysql/define/ConnectionInstrumentation.java b/apm-sniffer/apm-sdk-plugin/mysql-2.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/mysql/define/ConnectionInstrumentation.java
new file mode 100644
index 0000000000000000000000000000000000000000..2a952a55db9ee7383e1d343d4efab2214fd1226b
--- /dev/null
+++ b/apm-sniffer/apm-sdk-plugin/mysql-2.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/mysql/define/ConnectionInstrumentation.java
@@ -0,0 +1,123 @@
+/*
+ * Copyright 2017, OpenSkywalking Organization All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Project repository: https://github.com/OpenSkywalking/skywalking
+ */
+
+package org.skywalking.apm.plugin.jdbc.mysql.define;
+
+import net.bytebuddy.description.method.MethodDescription;
+import net.bytebuddy.matcher.ElementMatcher;
+import org.skywalking.apm.agent.core.plugin.interceptor.ConstructorInterceptPoint;
+import org.skywalking.apm.agent.core.plugin.interceptor.InstanceMethodsInterceptPoint;
+import org.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine;
+import org.skywalking.apm.agent.core.plugin.match.ClassMatch;
+
+import static net.bytebuddy.matcher.ElementMatchers.named;
+import static net.bytebuddy.matcher.ElementMatchers.takesArguments;
+import static org.skywalking.apm.agent.core.plugin.match.NameMatch.byName;
+import static org.skywalking.apm.plugin.jdbc.define.Constants.CLOSE_METHOD_NAME;
+import static org.skywalking.apm.plugin.jdbc.define.Constants.COMMIT_METHOD_NAME;
+import static org.skywalking.apm.plugin.jdbc.define.Constants.CREATE_STATEMENT_INTERCEPT_CLASS;
+import static org.skywalking.apm.plugin.jdbc.define.Constants.CREATE_STATEMENT_METHOD_NAME;
+import static org.skywalking.apm.plugin.jdbc.define.Constants.PREPARE_CALL_INTERCEPT_CLASS;
+import static org.skywalking.apm.plugin.jdbc.define.Constants.PREPARE_CALL_METHOD_NAME;
+import static org.skywalking.apm.plugin.jdbc.define.Constants.PREPARE_STATEMENT_INTERCEPT_CLASS;
+import static org.skywalking.apm.plugin.jdbc.define.Constants.PREPARE_STATEMENT_METHOD_NAME;
+import static org.skywalking.apm.plugin.jdbc.define.Constants.RELEASE_SAVE_POINT_METHOD_NAME;
+import static org.skywalking.apm.plugin.jdbc.define.Constants.ROLLBACK_METHOD_NAME;
+import static org.skywalking.apm.plugin.jdbc.define.Constants.SERVICE_METHOD_INTERCEPT_CLASS;
+
+/**
+ * {@link ConnectionInstrumentation} intercept the following methods that the class which extend {@link
+ * com.mysql.jdbc.ConnectionImpl}.
+ *
+ * 1. Enhance prepareStatement
by org.skywalking.apm.plugin.jdbc.define.JDBCPrepareStatementInterceptor
+ * 2. Enhance prepareCall
by org.skywalking.apm.plugin.jdbc.define.JDBCPrepareCallInterceptor
+ * 3. Enhance createStatement
by org.skywalking.apm.plugin.jdbc.define.JDBCStatementInterceptor
+ * 4. Enhance commit, rollback, close, releaseSavepoint
by org.skywalking.apm.plugin.jdbc.define.ConnectionServiceMethodInterceptor
+ *
+ * @author zhangxin
+ */
+public class ConnectionInstrumentation extends ClassInstanceMethodsEnhancePluginDefine {
+
+ public static final String ENHANCE_CLASS = "com.mysql.jdbc.ConnectionImpl";
+
+ @Override protected ConstructorInterceptPoint[] getConstructorsInterceptPoints() {
+ return new ConstructorInterceptPoint[0];
+ }
+
+ @Override protected InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() {
+ return new InstanceMethodsInterceptPoint[] {
+ new InstanceMethodsInterceptPoint() {
+ @Override public ElementMatcher getMethodsMatcher() {
+ return named(PREPARE_STATEMENT_METHOD_NAME);
+ }
+
+ @Override public String getMethodsInterceptor() {
+ return PREPARE_STATEMENT_INTERCEPT_CLASS;
+ }
+
+ @Override public boolean isOverrideArgs() {
+ return false;
+ }
+ },
+ new InstanceMethodsInterceptPoint() {
+ @Override public ElementMatcher getMethodsMatcher() {
+ return named(PREPARE_CALL_METHOD_NAME);
+ }
+
+ @Override public String getMethodsInterceptor() {
+ return PREPARE_CALL_INTERCEPT_CLASS;
+ }
+
+ @Override public boolean isOverrideArgs() {
+ return false;
+ }
+ },
+ new InstanceMethodsInterceptPoint() {
+ @Override public ElementMatcher getMethodsMatcher() {
+ return named(CREATE_STATEMENT_METHOD_NAME).and(takesArguments(2));
+ }
+
+ @Override public String getMethodsInterceptor() {
+ return CREATE_STATEMENT_INTERCEPT_CLASS;
+ }
+
+ @Override public boolean isOverrideArgs() {
+ return false;
+ }
+ },
+ new InstanceMethodsInterceptPoint() {
+ @Override public ElementMatcher getMethodsMatcher() {
+ return named(COMMIT_METHOD_NAME).or(named(ROLLBACK_METHOD_NAME)).or(named(CLOSE_METHOD_NAME)).or(named(RELEASE_SAVE_POINT_METHOD_NAME));
+ }
+
+ @Override public String getMethodsInterceptor() {
+ return SERVICE_METHOD_INTERCEPT_CLASS;
+ }
+
+ @Override public boolean isOverrideArgs() {
+ return false;
+ }
+ }
+ };
+
+ }
+
+ @Override protected ClassMatch enhanceClass() {
+ return byName(ENHANCE_CLASS);
+ }
+}
diff --git a/apm-sniffer/apm-sdk-plugin/jdbc-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/define/MysqlInstrumentation.java b/apm-sniffer/apm-sdk-plugin/mysql-2.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/mysql/define/DriverInstrumentation.java
similarity index 76%
rename from apm-sniffer/apm-sdk-plugin/jdbc-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/define/MysqlInstrumentation.java
rename to apm-sniffer/apm-sdk-plugin/mysql-2.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/mysql/define/DriverInstrumentation.java
index 1f3c0e3274760b793d1d8abda6a33cc46f505ac4..daa0413c135ea7f9e9998dee44e0b9e85021fbd6 100644
--- a/apm-sniffer/apm-sdk-plugin/jdbc-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/define/MysqlInstrumentation.java
+++ b/apm-sniffer/apm-sdk-plugin/mysql-2.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/mysql/define/DriverInstrumentation.java
@@ -16,18 +16,19 @@
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
-package org.skywalking.apm.plugin.jdbc.define;
+package org.skywalking.apm.plugin.jdbc.mysql.define;
import org.skywalking.apm.agent.core.plugin.match.ClassMatch;
+import org.skywalking.apm.plugin.jdbc.define.AbstractDriverInstrumentation;
import static org.skywalking.apm.agent.core.plugin.match.NameMatch.byName;
/**
- * {@link MysqlInstrumentation} presents that skywalking intercepts {@link com.mysql.jdbc.Driver}.
+ * {@link DriverInstrumentation} presents that skywalking intercepts {@link com.mysql.jdbc.Driver}.
*
* @author zhangxin
*/
-public class MysqlInstrumentation extends AbstractDatabaseInstrumentation {
+public class DriverInstrumentation extends AbstractDriverInstrumentation {
@Override
protected ClassMatch enhanceClass() {
return byName("com.mysql.jdbc.Driver");
diff --git a/apm-sniffer/apm-sdk-plugin/mysql-2.x-plugin/src/main/resources/skywalking-plugin.def b/apm-sniffer/apm-sdk-plugin/mysql-2.x-plugin/src/main/resources/skywalking-plugin.def
new file mode 100644
index 0000000000000000000000000000000000000000..db4e41ef3b690e9ac8d9da106e3279319c8e1229
--- /dev/null
+++ b/apm-sniffer/apm-sdk-plugin/mysql-2.x-plugin/src/main/resources/skywalking-plugin.def
@@ -0,0 +1,2 @@
+mysql=org.skywalking.apm.plugin.jdbc.mysql.define.DriverInstrumentation
+mysql=org.skywalking.apm.plugin.jdbc.mysql.define.ConnectionInstrumentation
diff --git a/apm-sniffer/apm-sdk-plugin/oracle-10.x-plugin/pom.xml b/apm-sniffer/apm-sdk-plugin/oracle-10.x-plugin/pom.xml
new file mode 100755
index 0000000000000000000000000000000000000000..bb2242af67ef00625bfb3067f786268f5e007955
--- /dev/null
+++ b/apm-sniffer/apm-sdk-plugin/oracle-10.x-plugin/pom.xml
@@ -0,0 +1,75 @@
+
+
+
+
+ apm-sdk-plugin
+ org.skywalking
+ 3.2.3-2017
+
+ 4.0.0
+
+ apm-oracle-10.x-plugin
+ jar
+
+ oracle-10.x-plugin
+ http://maven.apache.org
+
+
+ UTF-8
+
+
+
+
+ com.oracle
+ ojdbc14
+ 10.2.0.4.0
+ provided
+
+
+ org.skywalking
+ apm-jdbc-commons
+ ${project.version}
+ provided
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-deploy-plugin
+
+
+
+ org.apache.maven.plugins
+ maven-source-plugin
+
+
+
+ attach-sources
+
+ jar
+
+
+
+
+
+
+
diff --git a/apm-sniffer/apm-sdk-plugin/oracle-10.x-plugin/src/main/java/oracle/jdbc/driver/JDBCPrepareStatementWithArrayInterceptor.java b/apm-sniffer/apm-sdk-plugin/oracle-10.x-plugin/src/main/java/oracle/jdbc/driver/JDBCPrepareStatementWithArrayInterceptor.java
new file mode 100644
index 0000000000000000000000000000000000000000..e9228cd485b250643ff5b769b47837e5c5fa3c2f
--- /dev/null
+++ b/apm-sniffer/apm-sdk-plugin/oracle-10.x-plugin/src/main/java/oracle/jdbc/driver/JDBCPrepareStatementWithArrayInterceptor.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2017, OpenSkywalking Organization All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Project repository: https://github.com/OpenSkywalking/skywalking
+ */
+
+package oracle.jdbc.driver;
+
+import java.lang.reflect.Method;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import org.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
+import org.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
+import org.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult;
+import org.skywalking.apm.plugin.jdbc.trace.ConnectionInfo;
+import org.skywalking.apm.plugin.jdbc.trace.SWPreparedStatement;
+
+/**
+ * {@link JDBCPrepareStatementWithArrayInterceptor} return {@link SWPreparedStatement} instance that wrapper the real
+ * preparedStatement instance when the client call oracle.jdbc.driver.PhysicalConnection#prepareStatement(String,
+ * int[])
method or oracle.jdbc.driver.PhysicalConnection#prepareStatement(String, String[])
+ * method.
+ *
+ * @author zhangxin
+ */
+public class JDBCPrepareStatementWithArrayInterceptor implements InstanceMethodsAroundInterceptor {
+ @Override
+ public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class>[] argumentsTypes,
+ MethodInterceptResult result) throws Throwable {
+
+ }
+
+ @Override
+ public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class>[] argumentsTypes,
+ Object ret) throws Throwable {
+ /**
+ * To prevent the org.postgresql.jdbc.prepareStatement(String sql)
method from repeating
+ * interceptor, Because PGConnection call org.postgresql.jdbc.prepareStatement(String sql)
method when
+ * the second argument is empty.
+ *
+ * @see oracle.jdbc.driver.PhysicalConnection#prepareStatement(String, int[])
+ * @see oracle.jdbc.driver.PhysicalConnection#prepareStatement(String, String[])
+ **/
+ String sql = (String)allArguments[0];
+ if (!AutoKeyInfo.isInsertSqlStmt(sql)) {
+ return ret;
+ }
+ return new SWPreparedStatement((Connection)objInst, (PreparedStatement)ret, (ConnectionInfo)objInst.getSkyWalkingDynamicField(), (String)allArguments[0]);
+ }
+
+ @Override public void handleMethodException(EnhancedInstance objInst, Method method, Object[] allArguments,
+ Class>[] argumentsTypes, Throwable t) {
+
+ }
+}
diff --git a/apm-sniffer/apm-sdk-plugin/oracle-10.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/oracle/define/ConnectionInstrumentation.java b/apm-sniffer/apm-sdk-plugin/oracle-10.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/oracle/define/ConnectionInstrumentation.java
new file mode 100644
index 0000000000000000000000000000000000000000..b0665512f7bd9164baf219dcc92a47b2bb265cc8
--- /dev/null
+++ b/apm-sniffer/apm-sdk-plugin/oracle-10.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/oracle/define/ConnectionInstrumentation.java
@@ -0,0 +1,158 @@
+/*
+ * Copyright 2017, OpenSkywalking Organization All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Project repository: https://github.com/OpenSkywalking/skywalking
+ */
+
+package org.skywalking.apm.plugin.jdbc.oracle.define;
+
+import net.bytebuddy.description.method.MethodDescription;
+import net.bytebuddy.matcher.ElementMatcher;
+import org.skywalking.apm.agent.core.plugin.interceptor.ConstructorInterceptPoint;
+import org.skywalking.apm.agent.core.plugin.interceptor.InstanceMethodsInterceptPoint;
+import org.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine;
+import org.skywalking.apm.agent.core.plugin.match.ClassMatch;
+
+import static net.bytebuddy.matcher.ElementMatchers.named;
+import static net.bytebuddy.matcher.ElementMatchers.takesArguments;
+import static org.skywalking.apm.agent.core.plugin.bytebuddy.ArgumentTypeNameMatch.takesArgumentWithType;
+import static org.skywalking.apm.agent.core.plugin.match.NameMatch.byName;
+import static org.skywalking.apm.plugin.jdbc.define.Constants.CLOSE_METHOD_NAME;
+import static org.skywalking.apm.plugin.jdbc.define.Constants.COMMIT_METHOD_NAME;
+import static org.skywalking.apm.plugin.jdbc.define.Constants.CREATE_STATEMENT_INTERCEPT_CLASS;
+import static org.skywalking.apm.plugin.jdbc.define.Constants.CREATE_STATEMENT_METHOD_NAME;
+import static org.skywalking.apm.plugin.jdbc.define.Constants.PREPARE_CALL_INTERCEPT_CLASS;
+import static org.skywalking.apm.plugin.jdbc.define.Constants.PREPARE_CALL_METHOD_NAME;
+import static org.skywalking.apm.plugin.jdbc.define.Constants.PREPARE_STATEMENT_INTERCEPT_CLASS;
+import static org.skywalking.apm.plugin.jdbc.define.Constants.PREPARE_STATEMENT_METHOD_NAME;
+import static org.skywalking.apm.plugin.jdbc.define.Constants.RELEASE_SAVE_POINT_METHOD_NAME;
+import static org.skywalking.apm.plugin.jdbc.define.Constants.ROLLBACK_METHOD_NAME;
+import static org.skywalking.apm.plugin.jdbc.define.Constants.SERVICE_METHOD_INTERCEPT_CLASS;
+
+/**
+ * {@link ConnectionInstrumentation} intercept the following methods that the class which extend {@link
+ * oracle.jdbc.driver.PhysicalConnection}.
+ *
+ * 1. Enhance prepareStatement
by org.skywalking.apm.plugin.jdbc.define.JDBCPrepareStatementInterceptor
+ * 2. Enhance prepareStatement
that the seconds argument type is java.lang.String[]
by
+ * oracle.jdbc.driver.JDBCPrepareStatementWithArrayInterceptor
+ * 3. Enhance prepareStatement
that the seconds argument type is int[]
by
+ * oracle.jdbc.driver.JDBCPrepareStatementWithArrayInterceptor
+ * 4. Enhance prepareCall
by
+ * org.skywalking.apm.plugin.jdbc.define.JDBCPrepareCallInterceptor
+ * 5. Enhance createStatement
+ * by org.skywalking.apm.plugin.jdbc.define.JDBCStatementInterceptor
+ * 6. Enhance commit, rollback, close, releaseSavepoint
by org.skywalking.apm.plugin.jdbc.define.ConnectionServiceMethodInterceptor
+ *
+ * @author zhangxin
+ */
+public class ConnectionInstrumentation extends ClassInstanceMethodsEnhancePluginDefine {
+
+ private static final String PREPARE_STATEMENT_METHOD_WITH_ARRAY_INTERCEPTOR_CLASS = "oracle.jdbc.driver.JDBCPrepareStatementWithArrayInterceptor";
+ public static final String ENHANCE_CLASS = "oracle.jdbc.driver.PhysicalConnection";
+ public static final String STRING_ARRAY_ARGUMENT_TYPE = "java.lang.String[]";
+ public static final String INT_ARRAY_ARGUMENT_TYPE = "int[]";
+
+ @Override protected ConstructorInterceptPoint[] getConstructorsInterceptPoints() {
+ return new ConstructorInterceptPoint[0];
+ }
+
+ @Override protected InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() {
+ return new InstanceMethodsInterceptPoint[] {
+ new InstanceMethodsInterceptPoint() {
+ @Override public ElementMatcher getMethodsMatcher() {
+ return named(PREPARE_STATEMENT_METHOD_NAME).and(takesArguments(3));
+ }
+
+ @Override public String getMethodsInterceptor() {
+ return PREPARE_STATEMENT_INTERCEPT_CLASS;
+ }
+
+ @Override public boolean isOverrideArgs() {
+ return false;
+ }
+ },
+ new InstanceMethodsInterceptPoint() {
+ @Override public ElementMatcher getMethodsMatcher() {
+ return named(PREPARE_STATEMENT_METHOD_NAME).and(takesArgumentWithType(1, STRING_ARRAY_ARGUMENT_TYPE));
+ }
+
+ @Override public String getMethodsInterceptor() {
+ return PREPARE_STATEMENT_METHOD_WITH_ARRAY_INTERCEPTOR_CLASS;
+ }
+
+ @Override public boolean isOverrideArgs() {
+ return false;
+ }
+ },
+ new InstanceMethodsInterceptPoint() {
+ @Override public ElementMatcher getMethodsMatcher() {
+ return named(PREPARE_STATEMENT_METHOD_NAME).and(takesArgumentWithType(1, INT_ARRAY_ARGUMENT_TYPE));
+ }
+
+ @Override public String getMethodsInterceptor() {
+ return PREPARE_STATEMENT_METHOD_WITH_ARRAY_INTERCEPTOR_CLASS;
+ }
+
+ @Override public boolean isOverrideArgs() {
+ return false;
+ }
+ },
+ new InstanceMethodsInterceptPoint() {
+ @Override public ElementMatcher getMethodsMatcher() {
+ return named(PREPARE_CALL_METHOD_NAME).and(takesArguments(3));
+ }
+
+ @Override public String getMethodsInterceptor() {
+ return PREPARE_CALL_INTERCEPT_CLASS;
+ }
+
+ @Override public boolean isOverrideArgs() {
+ return false;
+ }
+ },
+ new InstanceMethodsInterceptPoint() {
+ @Override public ElementMatcher getMethodsMatcher() {
+ return named(CREATE_STATEMENT_METHOD_NAME).and(takesArguments(2));
+ }
+
+ @Override public String getMethodsInterceptor() {
+ return CREATE_STATEMENT_INTERCEPT_CLASS;
+ }
+
+ @Override public boolean isOverrideArgs() {
+ return false;
+ }
+ },
+ new InstanceMethodsInterceptPoint() {
+ @Override public ElementMatcher getMethodsMatcher() {
+ return named(COMMIT_METHOD_NAME).or(named(ROLLBACK_METHOD_NAME)).or(named(CLOSE_METHOD_NAME)).or(named(RELEASE_SAVE_POINT_METHOD_NAME));
+ }
+
+ @Override public String getMethodsInterceptor() {
+ return SERVICE_METHOD_INTERCEPT_CLASS;
+ }
+
+ @Override public boolean isOverrideArgs() {
+ return false;
+ }
+ }
+ };
+ }
+
+ @Override protected ClassMatch enhanceClass() {
+ return byName(ENHANCE_CLASS);
+ }
+}
diff --git a/apm-sniffer/apm-sdk-plugin/jdbc-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/define/OracleInstrumentation.java b/apm-sniffer/apm-sdk-plugin/oracle-10.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/oracle/define/DriverInstrumentation.java
similarity index 75%
rename from apm-sniffer/apm-sdk-plugin/jdbc-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/define/OracleInstrumentation.java
rename to apm-sniffer/apm-sdk-plugin/oracle-10.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/oracle/define/DriverInstrumentation.java
index a8414654db5f8a4ff0361714dc7038b9cba37d28..1a6a394bc5899ccc65d6dbcf7b204d0ff64cf89f 100644
--- a/apm-sniffer/apm-sdk-plugin/jdbc-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/define/OracleInstrumentation.java
+++ b/apm-sniffer/apm-sdk-plugin/oracle-10.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/oracle/define/DriverInstrumentation.java
@@ -16,19 +16,20 @@
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
-package org.skywalking.apm.plugin.jdbc.define;
+package org.skywalking.apm.plugin.jdbc.oracle.define;
import org.skywalking.apm.agent.core.plugin.match.ClassMatch;
+import org.skywalking.apm.plugin.jdbc.define.AbstractDriverInstrumentation;
import static org.skywalking.apm.agent.core.plugin.match.NameMatch.byName;
/**
- * {@link OracleInstrumentation} presents that skywalking intercepts the class oracle.jdbc.OracleDriver
- *
.
+ * {@link DriverInstrumentation} presents that skywalking intercepts {@link oracle.jdbc.driver.OracleDriver}.
*
* @author zhangxin
*/
-public class OracleInstrumentation extends AbstractDatabaseInstrumentation {
+public class DriverInstrumentation extends AbstractDriverInstrumentation {
+
@Override
protected ClassMatch enhanceClass() {
return byName("oracle.jdbc.driver.OracleDriver");
diff --git a/apm-sniffer/apm-sdk-plugin/oracle-10.x-plugin/src/main/resources/skywalking-plugin.def b/apm-sniffer/apm-sdk-plugin/oracle-10.x-plugin/src/main/resources/skywalking-plugin.def
new file mode 100644
index 0000000000000000000000000000000000000000..26a5ba53156a6d6ce2a0bd7924ab6f4b7e05d64d
--- /dev/null
+++ b/apm-sniffer/apm-sdk-plugin/oracle-10.x-plugin/src/main/resources/skywalking-plugin.def
@@ -0,0 +1,2 @@
+oracle-10.x=org.skywalking.apm.plugin.jdbc.oracle.define.DriverInstrumentation
+oracle-10.x=org.skywalking.apm.plugin.jdbc.oracle.define.ConnectionInstrumentation
diff --git a/apm-sniffer/apm-sdk-plugin/pom.xml b/apm-sniffer/apm-sdk-plugin/pom.xml
index 2ed3c2e88d1ce9d19eb87089669655474eb44848..187cddb8fd6973f375b9ea0239940222845273c6 100644
--- a/apm-sniffer/apm-sdk-plugin/pom.xml
+++ b/apm-sniffer/apm-sdk-plugin/pom.xml
@@ -30,7 +30,7 @@
apm-sdk-plugin
dubbo-plugin
- jdbc-plugin
+ jdbc-commons
httpClient-4.x-plugin
jedis-2.x-plugin
tomcat-7.x-8.x-plugin
@@ -48,6 +48,10 @@
sharding-jdbc-1.5.x-plugin
xmemcached-2.x-plugin
grpc-1.x-plugin
+ mysql-2.x-plugin
+ h2-1.x-plugin
+ postgresql-8.x-plugin
+ oracle-10.x-plugin
pom
diff --git a/apm-sniffer/apm-sdk-plugin/postgresql-8.x-plugin/pom.xml b/apm-sniffer/apm-sdk-plugin/postgresql-8.x-plugin/pom.xml
new file mode 100755
index 0000000000000000000000000000000000000000..1ea9f8a4dda5669de22804498102b8a259adc9e8
--- /dev/null
+++ b/apm-sniffer/apm-sdk-plugin/postgresql-8.x-plugin/pom.xml
@@ -0,0 +1,75 @@
+
+
+
+
+ apm-sdk-plugin
+ org.skywalking
+ 3.2.3-2017
+
+ 4.0.0
+
+ apm-postgresql-8.x-plugin
+ jar
+
+ postgresql-8.x-plugin
+ http://maven.apache.org
+
+
+ UTF-8
+
+
+
+
+ org.postgresql
+ postgresql
+ 42.0.0
+ provided
+
+
+ org.skywalking
+ apm-jdbc-commons
+ ${project.version}
+ provided
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-deploy-plugin
+
+
+
+ org.apache.maven.plugins
+ maven-source-plugin
+
+
+
+ attach-sources
+
+ jar
+
+
+
+
+
+
+
diff --git a/apm-sniffer/apm-sdk-plugin/postgresql-8.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/postgresql/JDBCPrepareStatementWithStringArrayInterceptor.java b/apm-sniffer/apm-sdk-plugin/postgresql-8.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/postgresql/JDBCPrepareStatementWithStringArrayInterceptor.java
new file mode 100644
index 0000000000000000000000000000000000000000..bd1671ccb9e69aa044dc2d91630afeb0ad5e764b
--- /dev/null
+++ b/apm-sniffer/apm-sdk-plugin/postgresql-8.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/postgresql/JDBCPrepareStatementWithStringArrayInterceptor.java
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2017, OpenSkywalking Organization All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Project repository: https://github.com/OpenSkywalking/skywalking
+ */
+
+package org.skywalking.apm.plugin.jdbc.postgresql;
+
+import java.lang.reflect.Method;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import org.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
+import org.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
+import org.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult;
+import org.skywalking.apm.plugin.jdbc.trace.ConnectionInfo;
+import org.skywalking.apm.plugin.jdbc.trace.SWPreparedStatement;
+
+/**
+ * {@link JDBCPrepareStatementWithStringArrayInterceptor} return {@link SWPreparedStatement} instance that wrapper the
+ * real preparedStatement instance when the client call org.postgresql.jdbc.PgConnection#prepareStatement(String,
+ * String[])
method. method.
+ *
+ * @author zhangxin
+ */
+public class JDBCPrepareStatementWithStringArrayInterceptor implements InstanceMethodsAroundInterceptor {
+ @Override
+ public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class>[] argumentsTypes,
+ MethodInterceptResult result) throws Throwable {
+
+ }
+
+ @Override
+ public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class>[] argumentsTypes,
+ Object ret) throws Throwable {
+ /**
+ * To prevent the org.postgresql.jdbc.prepareStatement(String sql)
method from repeating
+ * interceptor, Because PGConnection call org.postgresql.jdbc.prepareStatement(String sql)
method when
+ * the second argument is empty.
+ *
+ * @see org.postgresql.jdbc.PgConnection#prepareStatement(String, String[])
+ **/
+ String[] columnNames = (String[])allArguments[1];
+ if (columnNames != null && columnNames.length == 0) {
+ return ret;
+ }
+ return new SWPreparedStatement((Connection)objInst, (PreparedStatement)ret, (ConnectionInfo)objInst.getSkyWalkingDynamicField(), (String)allArguments[0]);
+ }
+
+ @Override public void handleMethodException(EnhancedInstance objInst, Method method, Object[] allArguments,
+ Class>[] argumentsTypes, Throwable t) {
+
+ }
+}
diff --git a/apm-sniffer/apm-sdk-plugin/postgresql-8.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/postgresql/define/ConnectionInstrumentation.java b/apm-sniffer/apm-sdk-plugin/postgresql-8.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/postgresql/define/ConnectionInstrumentation.java
new file mode 100644
index 0000000000000000000000000000000000000000..df520a9e8d64f11d8c994e63b8dc8f3ecf478722
--- /dev/null
+++ b/apm-sniffer/apm-sdk-plugin/postgresql-8.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/postgresql/define/ConnectionInstrumentation.java
@@ -0,0 +1,142 @@
+/*
+ * Copyright 2017, OpenSkywalking Organization All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Project repository: https://github.com/OpenSkywalking/skywalking
+ */
+
+package org.skywalking.apm.plugin.jdbc.postgresql.define;
+
+import net.bytebuddy.description.method.MethodDescription;
+import net.bytebuddy.matcher.ElementMatcher;
+import org.skywalking.apm.agent.core.plugin.interceptor.ConstructorInterceptPoint;
+import org.skywalking.apm.agent.core.plugin.interceptor.InstanceMethodsInterceptPoint;
+import org.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine;
+import org.skywalking.apm.agent.core.plugin.match.ClassMatch;
+
+import static net.bytebuddy.matcher.ElementMatchers.named;
+import static net.bytebuddy.matcher.ElementMatchers.takesArguments;
+import static org.skywalking.apm.agent.core.plugin.bytebuddy.ArgumentTypeNameMatch.takesArgumentWithType;
+import static org.skywalking.apm.agent.core.plugin.match.NameMatch.byName;
+import static org.skywalking.apm.plugin.jdbc.define.Constants.CLOSE_METHOD_NAME;
+import static org.skywalking.apm.plugin.jdbc.define.Constants.COMMIT_METHOD_NAME;
+import static org.skywalking.apm.plugin.jdbc.define.Constants.CREATE_STATEMENT_INTERCEPT_CLASS;
+import static org.skywalking.apm.plugin.jdbc.define.Constants.CREATE_STATEMENT_METHOD_NAME;
+import static org.skywalking.apm.plugin.jdbc.define.Constants.PREPARE_CALL_INTERCEPT_CLASS;
+import static org.skywalking.apm.plugin.jdbc.define.Constants.PREPARE_CALL_METHOD_NAME;
+import static org.skywalking.apm.plugin.jdbc.define.Constants.PREPARE_STATEMENT_INTERCEPT_CLASS;
+import static org.skywalking.apm.plugin.jdbc.define.Constants.PREPARE_STATEMENT_METHOD_NAME;
+import static org.skywalking.apm.plugin.jdbc.define.Constants.RELEASE_SAVE_POINT_METHOD_NAME;
+import static org.skywalking.apm.plugin.jdbc.define.Constants.ROLLBACK_METHOD_NAME;
+import static org.skywalking.apm.plugin.jdbc.define.Constants.SERVICE_METHOD_INTERCEPT_CLASS;
+
+/**
+ * {@link ConnectionInstrumentation} intercept the following methods that the class which extend {@link
+ * org.postgresql.jdbc.PgConnection}.
+ *
+ * 1. Enhance prepareStatement
by org.skywalking.apm.plugin.jdbc.define.JDBCPrepareStatementInterceptor
+ * 2. Enhance prepareStatement
that the seconds argument type is java.lang.String[]
by
+ * org.skywalking.apm.plugin.jdbc.postgresql.JDBCPrepareStatementWithStringArrayInterceptor
+ * 3. Enhance prepareCall
by
+ * org.skywalking.apm.plugin.jdbc.define.JDBCPrepareCallInterceptor
+ * 4. Enhance createStatement
+ * by org.skywalking.apm.plugin.jdbc.define.JDBCStatementInterceptor
+ * 5. Enhance commit, rollback, close, releaseSavepoint
by org.skywalking.apm.plugin.jdbc.define.ConnectionServiceMethodInterceptor
+ *
+ * @author zhangxin
+ */
+public class ConnectionInstrumentation extends ClassInstanceMethodsEnhancePluginDefine {
+
+ private static final String PREPARE_STATEMENT_METHOD_WITH_STRING_ARRAY_INTERCEPTOR_CLASS = "org.skywalking.apm.plugin.jdbc.postgresql.JDBCPrepareStatementWithStringArrayInterceptor";
+ public static final String ENHANCE_CLASS = "org.postgresql.jdbc.PgConnection";
+ public static final String STRING_ARRAY_ARGUMENT_TYPE = "java.lang.String[]";
+
+ @Override protected ConstructorInterceptPoint[] getConstructorsInterceptPoints() {
+ return new ConstructorInterceptPoint[0];
+ }
+
+ @Override protected InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() {
+ return new InstanceMethodsInterceptPoint[] {
+ new InstanceMethodsInterceptPoint() {
+ @Override public ElementMatcher getMethodsMatcher() {
+ return named(PREPARE_STATEMENT_METHOD_NAME).and(takesArguments(4));
+ }
+
+ @Override public String getMethodsInterceptor() {
+ return PREPARE_STATEMENT_INTERCEPT_CLASS;
+ }
+
+ @Override public boolean isOverrideArgs() {
+ return false;
+ }
+ },
+ new InstanceMethodsInterceptPoint() {
+ @Override public ElementMatcher getMethodsMatcher() {
+ return named(PREPARE_STATEMENT_METHOD_NAME).and(takesArgumentWithType(1, STRING_ARRAY_ARGUMENT_TYPE));
+ }
+
+ @Override public String getMethodsInterceptor() {
+ return PREPARE_STATEMENT_METHOD_WITH_STRING_ARRAY_INTERCEPTOR_CLASS;
+ }
+
+ @Override public boolean isOverrideArgs() {
+ return false;
+ }
+ },
+ new InstanceMethodsInterceptPoint() {
+ @Override public ElementMatcher getMethodsMatcher() {
+ return named(PREPARE_CALL_METHOD_NAME).and(takesArguments(4));
+ }
+
+ @Override public String getMethodsInterceptor() {
+ return PREPARE_CALL_INTERCEPT_CLASS;
+ }
+
+ @Override public boolean isOverrideArgs() {
+ return false;
+ }
+ },
+ new InstanceMethodsInterceptPoint() {
+ @Override public ElementMatcher getMethodsMatcher() {
+ return named(CREATE_STATEMENT_METHOD_NAME).and(takesArguments(3));
+ }
+
+ @Override public String getMethodsInterceptor() {
+ return CREATE_STATEMENT_INTERCEPT_CLASS;
+ }
+
+ @Override public boolean isOverrideArgs() {
+ return false;
+ }
+ },
+ new InstanceMethodsInterceptPoint() {
+ @Override public ElementMatcher getMethodsMatcher() {
+ return named(COMMIT_METHOD_NAME).or(named(ROLLBACK_METHOD_NAME)).or(named(CLOSE_METHOD_NAME)).or(named(RELEASE_SAVE_POINT_METHOD_NAME));
+ }
+
+ @Override public String getMethodsInterceptor() {
+ return SERVICE_METHOD_INTERCEPT_CLASS;
+ }
+
+ @Override public boolean isOverrideArgs() {
+ return false;
+ }
+ }
+ };
+ }
+
+ @Override protected ClassMatch enhanceClass() {
+ return byName(ENHANCE_CLASS);
+ }
+}
diff --git a/apm-sniffer/apm-sdk-plugin/jdbc-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/define/PostgreSQLInstrumentation.java b/apm-sniffer/apm-sdk-plugin/postgresql-8.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/postgresql/define/DriverInstrumentation.java
similarity index 76%
rename from apm-sniffer/apm-sdk-plugin/jdbc-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/define/PostgreSQLInstrumentation.java
rename to apm-sniffer/apm-sdk-plugin/postgresql-8.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/postgresql/define/DriverInstrumentation.java
index 99e249a64f416c008535662638da94af57de125c..e318ec5fe6843bcac5c4ce0ca251854b789ae508 100644
--- a/apm-sniffer/apm-sdk-plugin/jdbc-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/define/PostgreSQLInstrumentation.java
+++ b/apm-sniffer/apm-sdk-plugin/postgresql-8.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/postgresql/define/DriverInstrumentation.java
@@ -16,18 +16,20 @@
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
-package org.skywalking.apm.plugin.jdbc.define;
+package org.skywalking.apm.plugin.jdbc.postgresql.define;
import org.skywalking.apm.agent.core.plugin.match.ClassMatch;
+import org.skywalking.apm.plugin.jdbc.define.AbstractDriverInstrumentation;
import static org.skywalking.apm.agent.core.plugin.match.NameMatch.byName;
/**
- * {@link PostgreSQLInstrumentation} presents that skywalking intercepts {@link org.postgresql.Driver}.
+ * {@link DriverInstrumentation} presents that skywalking intercepts {@link org.postgresql.Driver}.
*
* @author zhangxin
*/
-public class PostgreSQLInstrumentation extends AbstractDatabaseInstrumentation {
+public class DriverInstrumentation extends AbstractDriverInstrumentation {
+
@Override
protected ClassMatch enhanceClass() {
return byName("org.postgresql.Driver");
diff --git a/apm-sniffer/apm-sdk-plugin/postgresql-8.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/postgresql/define/Jdbc3ConnectionInstrumentation.java b/apm-sniffer/apm-sdk-plugin/postgresql-8.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/postgresql/define/Jdbc3ConnectionInstrumentation.java
new file mode 100644
index 0000000000000000000000000000000000000000..54c8cc4856e480efdfa127543f2dd8bcc7c1f28b
--- /dev/null
+++ b/apm-sniffer/apm-sdk-plugin/postgresql-8.x-plugin/src/main/java/org/skywalking/apm/plugin/jdbc/postgresql/define/Jdbc3ConnectionInstrumentation.java
@@ -0,0 +1,124 @@
+/*
+ * Copyright 2017, OpenSkywalking Organization All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Project repository: https://github.com/OpenSkywalking/skywalking
+ */
+
+package org.skywalking.apm.plugin.jdbc.postgresql.define;
+
+import net.bytebuddy.description.method.MethodDescription;
+import net.bytebuddy.matcher.ElementMatcher;
+import org.skywalking.apm.agent.core.plugin.interceptor.ConstructorInterceptPoint;
+import org.skywalking.apm.agent.core.plugin.interceptor.InstanceMethodsInterceptPoint;
+import org.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine;
+import org.skywalking.apm.agent.core.plugin.match.ClassMatch;
+
+import static net.bytebuddy.matcher.ElementMatchers.named;
+import static net.bytebuddy.matcher.ElementMatchers.takesArguments;
+import static org.skywalking.apm.agent.core.plugin.match.NameMatch.byName;
+import static org.skywalking.apm.plugin.jdbc.define.Constants.CLOSE_METHOD_NAME;
+import static org.skywalking.apm.plugin.jdbc.define.Constants.COMMIT_METHOD_NAME;
+import static org.skywalking.apm.plugin.jdbc.define.Constants.CREATE_STATEMENT_INTERCEPT_CLASS;
+import static org.skywalking.apm.plugin.jdbc.define.Constants.CREATE_STATEMENT_METHOD_NAME;
+import static org.skywalking.apm.plugin.jdbc.define.Constants.PREPARE_CALL_INTERCEPT_CLASS;
+import static org.skywalking.apm.plugin.jdbc.define.Constants.PREPARE_CALL_METHOD_NAME;
+import static org.skywalking.apm.plugin.jdbc.define.Constants.PREPARE_STATEMENT_INTERCEPT_CLASS;
+import static org.skywalking.apm.plugin.jdbc.define.Constants.PREPARE_STATEMENT_METHOD_NAME;
+import static org.skywalking.apm.plugin.jdbc.define.Constants.RELEASE_SAVE_POINT_METHOD_NAME;
+import static org.skywalking.apm.plugin.jdbc.define.Constants.ROLLBACK_METHOD_NAME;
+import static org.skywalking.apm.plugin.jdbc.define.Constants.SERVICE_METHOD_INTERCEPT_CLASS;
+
+/**
+ * {@link ConnectionInstrumentation} intercept the following methods that the class which extend {@link
+ * org.postgresql.jdbc.PgConnection}.
+ *
+ * 1. Enhance prepareStatement
by org.skywalking.apm.plugin.jdbc.define.JDBCPrepareStatementInterceptor
+ * 2. Enhance prepareCall
by
+ * org.skywalking.apm.plugin.jdbc.define.JDBCPrepareCallInterceptor
+ * 3. Enhance createStatement
+ * by org.skywalking.apm.plugin.jdbc.define.JDBCStatementInterceptor
+ * 4. Enhance commit, rollback, close, releaseSavepoint
by org.skywalking.apm.plugin.jdbc.define.ConnectionServiceMethodInterceptor
+ *
+ * @author zhangxin
+ */
+public class Jdbc3ConnectionInstrumentation extends ClassInstanceMethodsEnhancePluginDefine {
+
+ public static final String ENHANCE_CLASS = "org.postgresql.jdbc3.Jdbc3Connection";
+
+ @Override protected ConstructorInterceptPoint[] getConstructorsInterceptPoints() {
+ return new ConstructorInterceptPoint[0];
+ }
+
+ @Override protected InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() {
+ return new InstanceMethodsInterceptPoint[] {
+ new InstanceMethodsInterceptPoint() {
+ @Override public ElementMatcher getMethodsMatcher() {
+ return named(PREPARE_STATEMENT_METHOD_NAME).and(takesArguments(4));
+ }
+
+ @Override public String getMethodsInterceptor() {
+ return PREPARE_STATEMENT_INTERCEPT_CLASS;
+ }
+
+ @Override public boolean isOverrideArgs() {
+ return false;
+ }
+ },
+ new InstanceMethodsInterceptPoint() {
+ @Override public ElementMatcher getMethodsMatcher() {
+ return named(PREPARE_CALL_METHOD_NAME).and(takesArguments(4));
+ }
+
+ @Override public String getMethodsInterceptor() {
+ return PREPARE_CALL_INTERCEPT_CLASS;
+ }
+
+ @Override public boolean isOverrideArgs() {
+ return false;
+ }
+ },
+ new InstanceMethodsInterceptPoint() {
+ @Override public ElementMatcher getMethodsMatcher() {
+ return named(CREATE_STATEMENT_METHOD_NAME).and(takesArguments(3));
+ }
+
+ @Override public String getMethodsInterceptor() {
+ return CREATE_STATEMENT_INTERCEPT_CLASS;
+ }
+
+ @Override public boolean isOverrideArgs() {
+ return false;
+ }
+ },
+ new InstanceMethodsInterceptPoint() {
+ @Override public ElementMatcher getMethodsMatcher() {
+ return named(COMMIT_METHOD_NAME).or(named(ROLLBACK_METHOD_NAME)).or(named(CLOSE_METHOD_NAME)).or(named(RELEASE_SAVE_POINT_METHOD_NAME));
+ }
+
+ @Override public String getMethodsInterceptor() {
+ return SERVICE_METHOD_INTERCEPT_CLASS;
+ }
+
+ @Override public boolean isOverrideArgs() {
+ return false;
+ }
+ }
+ };
+ }
+
+ @Override protected ClassMatch enhanceClass() {
+ return byName(ENHANCE_CLASS);
+ }
+}
diff --git a/apm-sniffer/apm-sdk-plugin/postgresql-8.x-plugin/src/main/resources/skywalking-plugin.def b/apm-sniffer/apm-sdk-plugin/postgresql-8.x-plugin/src/main/resources/skywalking-plugin.def
new file mode 100644
index 0000000000000000000000000000000000000000..816cdda1003b15a6407d025410905ad89af8a33e
--- /dev/null
+++ b/apm-sniffer/apm-sdk-plugin/postgresql-8.x-plugin/src/main/resources/skywalking-plugin.def
@@ -0,0 +1,3 @@
+postgresql-8.x=org.skywalking.apm.plugin.jdbc.postgresql.define.DriverInstrumentation
+postgresql-8.x=org.skywalking.apm.plugin.jdbc.postgresql.define.Jdbc3ConnectionInstrumentation
+postgresql-8.x=org.skywalking.apm.plugin.jdbc.postgresql.define.ConnectionInstrumentation
diff --git a/apm-sniffer/apm-sdk-plugin/sharding-jdbc-1.5.x-plugin/pom.xml b/apm-sniffer/apm-sdk-plugin/sharding-jdbc-1.5.x-plugin/pom.xml
index 33f6cb7b887b2f87cb2ebdc1390a05c1d87b7d7c..4e63ec2e6973d516ee2274cbb9b3acc905a331e8 100644
--- a/apm-sniffer/apm-sdk-plugin/sharding-jdbc-1.5.x-plugin/pom.xml
+++ b/apm-sniffer/apm-sdk-plugin/sharding-jdbc-1.5.x-plugin/pom.xml
@@ -38,12 +38,6 @@
-
- ${groupId}
- apm-jdbc-plugin
- ${project.version}
- test
-
mysql
mysql-connector-java
@@ -89,4 +83,4 @@
-
\ No newline at end of file
+