diff --git a/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-3.x-plugin/pom.xml b/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-3.x-plugin/pom.xml
new file mode 100644
index 0000000000000000000000000000000000000000..6f6b29a55b339a6541e07eadc14cabd3700bea0f
--- /dev/null
+++ b/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-3.x-plugin/pom.xml
@@ -0,0 +1,54 @@
+
+
+
+
+ spring-plugins
+ org.skywalking
+ 3.2.3-2017
+
+ 4.0.0
+
+ apm-springmvc-annotation-3.x-plugin
+ jar
+
+ mvc-annotation-3.x-plugin
+ http://maven.apache.org
+
+
+
+ org.springframework
+ spring-core
+ 3.2.18.RELEASE
+ compile
+
+
+ org.springframework
+ spring-webmvc
+ 3.2.18.RELEASE
+ compile
+
+
+ javax.servlet
+ javax.servlet-api
+ 3.0.1
+ provided
+
+
+
diff --git a/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-3.x-plugin/src/main/java/org/skywalking/apm/plugin/spring/mvc/v3/ControllerConstructorInterceptor.java b/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-3.x-plugin/src/main/java/org/skywalking/apm/plugin/spring/mvc/v3/ControllerConstructorInterceptor.java
new file mode 100644
index 0000000000000000000000000000000000000000..df1d1e9c6891ff4698c19992c37382e4bead4de2
--- /dev/null
+++ b/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-3.x-plugin/src/main/java/org/skywalking/apm/plugin/spring/mvc/v3/ControllerConstructorInterceptor.java
@@ -0,0 +1,46 @@
+/*
+ * 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.spring.mvc.v3;
+
+import org.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
+import org.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceConstructorInterceptor;
+import org.springframework.web.bind.annotation.RequestMapping;
+
+/**
+ * {@link ControllerConstructorInterceptor} cache the value of {@link RequestMapping} annotation with method in class
+ * annotation with {@link org.springframework.stereotype.Controller}.
+ *
+ * @author zhangxin
+ */
+public class ControllerConstructorInterceptor implements InstanceConstructorInterceptor {
+ @Override
+ public void onConstruct(EnhancedInstance objInst, Object[] allArguments) {
+ String basePath = "";
+ RequestMapping basePathRequestMapping = objInst.getClass().getAnnotation(RequestMapping.class);
+ if (basePathRequestMapping != null) {
+ if (basePathRequestMapping.value().length > 0) {
+ basePath = basePathRequestMapping.value()[0];
+ }
+ }
+
+ EnhanceRequireObjectCache enhanceCache = new EnhanceRequireObjectCache();
+ enhanceCache.setPathMappingCache(new PathMappingCache(basePath));
+ objInst.setSkyWalkingDynamicField(enhanceCache);
+ }
+}
diff --git a/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-3.x-plugin/src/main/java/org/skywalking/apm/plugin/spring/mvc/v3/ControllerMethodInterceptor.java b/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-3.x-plugin/src/main/java/org/skywalking/apm/plugin/spring/mvc/v3/ControllerMethodInterceptor.java
new file mode 100644
index 0000000000000000000000000000000000000000..43f51dbd7ab01bbe16244dbee4886045adc8f430
--- /dev/null
+++ b/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-3.x-plugin/src/main/java/org/skywalking/apm/plugin/spring/mvc/v3/ControllerMethodInterceptor.java
@@ -0,0 +1,100 @@
+/*
+ * 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.spring.mvc.v3;
+
+import java.lang.reflect.Method;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import org.skywalking.apm.agent.core.context.CarrierItem;
+import org.skywalking.apm.agent.core.context.ContextCarrier;
+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.network.trace.component.ComponentsDefine;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.context.request.RequestContextHolder;
+import org.springframework.web.context.request.ServletRequestAttributes;
+
+/**
+ * {@link ControllerMethodInterceptor} create entry span when the client call the method annotation with {@link
+ * RequestMapping} in the class annotation with {@link org.springframework.stereotype.Controller}.
+ *
+ * @author zhangxin
+ */
+public class ControllerMethodInterceptor implements InstanceMethodsAroundInterceptor {
+ @Override
+ public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class>[] argumentsTypes,
+ MethodInterceptResult result) throws Throwable {
+ EnhanceRequireObjectCache pathMappingCache = (EnhanceRequireObjectCache)objInst.getSkyWalkingDynamicField();
+ String requestURL = pathMappingCache.findPathMapping(method);
+ if (requestURL == null) {
+ requestURL = getRequestURL(method);
+ pathMappingCache.addPathMapping(method, requestURL);
+ requestURL = pathMappingCache.findPathMapping(method);
+ }
+
+ HttpServletRequest request =
+ ((ServletRequestAttributes)RequestContextHolder.getRequestAttributes()).getRequest();
+
+ ContextCarrier contextCarrier = new ContextCarrier();
+ CarrierItem next = contextCarrier.items();
+ while (next.hasNext()) {
+ next = next.next();
+ next.setHeadValue(request.getHeader(next.getHeadKey()));
+ }
+
+ AbstractSpan span = ContextManager.createEntrySpan(requestURL, contextCarrier);
+ Tags.URL.set(span, request.getRequestURL().toString());
+ Tags.HTTP.METHOD.set(span, request.getMethod());
+ span.setComponent(ComponentsDefine.SPRING_MVC_ANNOTATION);
+ SpanLayer.asHttp(span);
+ }
+
+ @Override
+ public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class>[] argumentsTypes,
+ Object ret) throws Throwable {
+ HttpServletResponse response = ((EnhanceRequireObjectCache)objInst.getSkyWalkingDynamicField()).getHttpServletResponse();
+ AbstractSpan span = ContextManager.activeSpan();
+ if (response.getStatus() >= 400) {
+ span.errorOccurred();
+ Tags.STATUS_CODE.set(span, Integer.toString(response.getStatus()));
+ }
+ ContextManager.stopSpan();
+ return ret;
+ }
+
+ @Override
+ public void handleMethodException(EnhancedInstance objInst, Method method, Object[] allArguments,
+ Class>[] argumentsTypes, Throwable t) {
+ ContextManager.activeSpan().errorOccurred().log(t);
+ }
+
+ public String getRequestURL(Method method) {
+ String requestURL = "";
+ RequestMapping methodRequestMapping = method.getAnnotation(RequestMapping.class);
+ if (methodRequestMapping.value().length > 0) {
+ requestURL = methodRequestMapping.value()[0];
+ }
+ return requestURL;
+ }
+}
diff --git a/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-3.x-plugin/src/main/java/org/skywalking/apm/plugin/spring/mvc/v3/EnhanceRequireObjectCache.java b/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-3.x-plugin/src/main/java/org/skywalking/apm/plugin/spring/mvc/v3/EnhanceRequireObjectCache.java
new file mode 100644
index 0000000000000000000000000000000000000000..eb92f4848680f25bcedecaa6441567713b79b6e1
--- /dev/null
+++ b/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-3.x-plugin/src/main/java/org/skywalking/apm/plugin/spring/mvc/v3/EnhanceRequireObjectCache.java
@@ -0,0 +1,52 @@
+/*
+ * 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.spring.mvc.v3;
+
+import java.lang.reflect.Method;
+import javax.servlet.http.HttpServletResponse;
+import org.springframework.web.context.request.NativeWebRequest;
+
+public class EnhanceRequireObjectCache {
+ private PathMappingCache pathMappingCache;
+ private NativeWebRequest nativeWebRequest;
+
+ public void setPathMappingCache(PathMappingCache pathMappingCache) {
+ this.pathMappingCache = pathMappingCache;
+ }
+
+ public HttpServletResponse getHttpServletResponse() {
+ return (HttpServletResponse)nativeWebRequest.getNativeResponse();
+ }
+
+ public void setNativeWebRequest(NativeWebRequest nativeWebRequest) {
+ this.nativeWebRequest = nativeWebRequest;
+ }
+
+ public String findPathMapping(Method method) {
+ return pathMappingCache.findPathMapping(method);
+ }
+
+ public void addPathMapping(Method method, String url) {
+ pathMappingCache.addPathMapping(method, url);
+ }
+
+ public PathMappingCache getPathMappingCache() {
+ return pathMappingCache;
+ }
+}
diff --git a/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-3.x-plugin/src/main/java/org/skywalking/apm/plugin/spring/mvc/v3/GetBeanInterceptor.java b/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-3.x-plugin/src/main/java/org/skywalking/apm/plugin/spring/mvc/v3/GetBeanInterceptor.java
new file mode 100644
index 0000000000000000000000000000000000000000..7a771458afbf4a59001481998225acd55c4e8150
--- /dev/null
+++ b/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-3.x-plugin/src/main/java/org/skywalking/apm/plugin/spring/mvc/v3/GetBeanInterceptor.java
@@ -0,0 +1,53 @@
+/*
+ * 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.spring.mvc.v3;
+
+import java.lang.reflect.Method;
+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.springframework.web.context.request.NativeWebRequest;
+
+/**
+ * {@link GetBeanInterceptor} pass the {@link NativeWebRequest} object into the {@link
+ * org.springframework.stereotype.Controller} object.
+ *
+ * @author zhangxin
+ */
+public class GetBeanInterceptor 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 (ret instanceof EnhancedInstance) {
+ ((EnhanceRequireObjectCache)((EnhancedInstance)ret).getSkyWalkingDynamicField()).setNativeWebRequest((NativeWebRequest)objInst.getSkyWalkingDynamicField());
+ }
+ return ret;
+ }
+
+ @Override
+ public void handleMethodException(EnhancedInstance objInst, Method method, Object[] allArguments,
+ Class>[] argumentsTypes, Throwable t) {
+
+ }
+}
diff --git a/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-3.x-plugin/src/main/java/org/skywalking/apm/plugin/spring/mvc/v3/InvokeForRequestInterceptor.java b/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-3.x-plugin/src/main/java/org/skywalking/apm/plugin/spring/mvc/v3/InvokeForRequestInterceptor.java
new file mode 100644
index 0000000000000000000000000000000000000000..cc7cde4c7abcc7738fe757b1f66318697e6b354d
--- /dev/null
+++ b/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-3.x-plugin/src/main/java/org/skywalking/apm/plugin/spring/mvc/v3/InvokeForRequestInterceptor.java
@@ -0,0 +1,51 @@
+/*
+ * 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.spring.mvc.v3;
+
+import java.lang.reflect.Method;
+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.springframework.web.context.request.NativeWebRequest;
+
+/**
+ * {@link InvokeForRequestInterceptor} pass the {@link NativeWebRequest} object into the {@link
+ * org.springframework.stereotype.Controller} object.
+ *
+ * @author zhangxin
+ */
+public class InvokeForRequestInterceptor implements InstanceMethodsAroundInterceptor {
+ @Override
+ public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class>[] argumentsTypes,
+ MethodInterceptResult result) throws Throwable {
+ objInst.setSkyWalkingDynamicField(allArguments[0]);
+ }
+
+ @Override
+ public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class>[] argumentsTypes,
+ Object ret) throws Throwable {
+ return ret;
+ }
+
+ @Override
+ public void handleMethodException(EnhancedInstance objInst, Method method, Object[] allArguments,
+ Class>[] argumentsTypes, Throwable t) {
+
+ }
+}
diff --git a/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-3.x-plugin/src/main/java/org/skywalking/apm/plugin/spring/mvc/v3/PathMappingCache.java b/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-3.x-plugin/src/main/java/org/skywalking/apm/plugin/spring/mvc/v3/PathMappingCache.java
new file mode 100644
index 0000000000000000000000000000000000000000..5c732ce2cb4c09027312d5190fec517ca7a01cdf
--- /dev/null
+++ b/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-3.x-plugin/src/main/java/org/skywalking/apm/plugin/spring/mvc/v3/PathMappingCache.java
@@ -0,0 +1,45 @@
+/*
+ * 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.spring.mvc.v3;
+
+import java.lang.reflect.Method;
+import java.util.concurrent.ConcurrentHashMap;
+
+/**
+ * {@link PathMappingCache} cache all request urls of {@link org.springframework.stereotype.Controller} .
+ *
+ * @author zhangxin
+ */
+public class PathMappingCache {
+ private String classPath = "";
+
+ private ConcurrentHashMap methodPathMapping = new ConcurrentHashMap();
+
+ public PathMappingCache(String classPath) {
+ this.classPath = classPath;
+ }
+
+ public String findPathMapping(Method method) {
+ return methodPathMapping.get(method);
+ }
+
+ public void addPathMapping(Method method, String methodPath) {
+ methodPathMapping.put(method, classPath + methodPath);
+ }
+}
diff --git a/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-3.x-plugin/src/main/java/org/skywalking/apm/plugin/spring/mvc/v3/define/AbstractSpring3Instrumentation.java b/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-3.x-plugin/src/main/java/org/skywalking/apm/plugin/spring/mvc/v3/define/AbstractSpring3Instrumentation.java
new file mode 100644
index 0000000000000000000000000000000000000000..900bf2134d5e40a12c6db467be2dfc84156bd53c
--- /dev/null
+++ b/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-3.x-plugin/src/main/java/org/skywalking/apm/plugin/spring/mvc/v3/define/AbstractSpring3Instrumentation.java
@@ -0,0 +1,36 @@
+/*
+ * 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.spring.mvc.v3.define;
+
+import org.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine;
+
+/**
+ * {@link AbstractSpring3Instrumentation} define witness classes of the spring mvc 3 plugin. all Instrumentations
+ * extends this class.
+ *
+ * @author zhangxin
+ */
+public abstract class AbstractSpring3Instrumentation extends ClassInstanceMethodsEnhancePluginDefine {
+
+ public static final String WITHNESS_CLASSES = "org.springframework.web.servlet.view.xslt.AbstractXsltView";
+
+ @Override protected final String[] witnessClasses() {
+ return new String[] {WITHNESS_CLASSES};
+ }
+}
diff --git a/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-3.x-plugin/src/main/java/org/skywalking/apm/plugin/spring/mvc/v3/define/ControllerInstrumentation.java b/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-3.x-plugin/src/main/java/org/skywalking/apm/plugin/spring/mvc/v3/define/ControllerInstrumentation.java
new file mode 100644
index 0000000000000000000000000000000000000000..4b22c7550392b00b28acd650c71db0dbe1c54553
--- /dev/null
+++ b/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-3.x-plugin/src/main/java/org/skywalking/apm/plugin/spring/mvc/v3/define/ControllerInstrumentation.java
@@ -0,0 +1,89 @@
+/*
+ * 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.spring.mvc.v3.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.match.ClassMatch;
+
+import static net.bytebuddy.matcher.ElementMatchers.any;
+import static net.bytebuddy.matcher.ElementMatchers.isAnnotatedWith;
+import static net.bytebuddy.matcher.ElementMatchers.named;
+import static org.skywalking.apm.agent.core.plugin.match.ClassAnnotationMatch.byClassAnnotationMatch;
+
+/**
+ * {@link ControllerInstrumentation} intercept the constructor and the methods annotated with {@link
+ * org.springframework.web.bind.annotation.RequestMapping} in the class annotated with {@link
+ * org.springframework.stereotype.Controller}.
+ *
+ * @author zhangxin
+ */
+public class ControllerInstrumentation extends AbstractSpring3Instrumentation {
+ public static final String CONTROLLER_ENHANCE_ANNOTATION = "org.springframework.stereotype.Controller";
+ public static final String CONSTRUCTOR_INTERCEPTOR = "org.skywalking.apm.plugin.spring.mvc.v3.ControllerConstructorInterceptor";
+ public static final String REQUEST_MAPPING_ENHANCE_ANNOTATION = "org.springframework.web.bind.annotation.RequestMapping";
+ public static final String REQUEST_MAPPING_METHOD_INTERCEPTOR = "org.skywalking.apm.plugin.spring.mvc.v3.ControllerMethodInterceptor";
+
+ @Override
+ protected ConstructorInterceptPoint[] getConstructorsInterceptPoints() {
+ return new ConstructorInterceptPoint[] {
+ new ConstructorInterceptPoint() {
+ @Override
+ public ElementMatcher getConstructorMatcher() {
+ return any();
+ }
+
+ @Override
+ public String getConstructorInterceptor() {
+ return CONSTRUCTOR_INTERCEPTOR;
+ }
+ }
+ };
+ }
+
+ @Override
+ protected InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() {
+ return new InstanceMethodsInterceptPoint[] {
+ new InstanceMethodsInterceptPoint() {
+ @Override
+ public ElementMatcher getMethodsMatcher() {
+ return isAnnotatedWith(named(REQUEST_MAPPING_ENHANCE_ANNOTATION));
+ }
+
+ @Override
+ public String getMethodsInterceptor() {
+ return REQUEST_MAPPING_METHOD_INTERCEPTOR;
+ }
+
+ @Override
+ public boolean isOverrideArgs() {
+ return false;
+ }
+ }
+ };
+ }
+
+ @Override
+ protected ClassMatch enhanceClass() {
+ return byClassAnnotationMatch(new String[] {CONTROLLER_ENHANCE_ANNOTATION});
+ }
+
+}
diff --git a/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-3.x-plugin/src/main/java/org/skywalking/apm/plugin/spring/mvc/v3/define/HandlerMethodInstrumentation.java b/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-3.x-plugin/src/main/java/org/skywalking/apm/plugin/spring/mvc/v3/define/HandlerMethodInstrumentation.java
new file mode 100644
index 0000000000000000000000000000000000000000..06819c1a9896605f48c0eefa27d10ea00882d9b5
--- /dev/null
+++ b/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-3.x-plugin/src/main/java/org/skywalking/apm/plugin/spring/mvc/v3/define/HandlerMethodInstrumentation.java
@@ -0,0 +1,73 @@
+/*
+ * 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.spring.mvc.v3.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.match.ClassMatch;
+
+import static net.bytebuddy.matcher.ElementMatchers.named;
+import static org.skywalking.apm.agent.core.plugin.match.NameMatch.byName;
+
+/**
+ * {@link HandlerMethodInstrumentation} intercept the getBean
method in the
+ * org.springframework.web.method.HandlerMethod
class.
+ *
+ * @author zhangxin
+ */
+public class HandlerMethodInstrumentation extends AbstractSpring3Instrumentation {
+
+ public static final String ENHANCE_METHOD = "getBean";
+ public static final String INTERCEPTOR_CLASS = "org.skywalking.apm.plugin.spring.mvc.v3.GetBeanInterceptor";
+ public static final String ENHANCE_CLASS = "org.springframework.web.method.HandlerMethod";
+
+ @Override
+ protected ConstructorInterceptPoint[] getConstructorsInterceptPoints() {
+ return new ConstructorInterceptPoint[0];
+ }
+
+ @Override
+ protected InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() {
+ return new InstanceMethodsInterceptPoint[] {
+ new InstanceMethodsInterceptPoint() {
+ @Override
+ public ElementMatcher getMethodsMatcher() {
+ return named(ENHANCE_METHOD);
+ }
+
+ @Override
+ public String getMethodsInterceptor() {
+ return INTERCEPTOR_CLASS;
+ }
+
+ @Override
+ public boolean isOverrideArgs() {
+ return false;
+ }
+ }
+ };
+ }
+
+ @Override
+ protected ClassMatch enhanceClass() {
+ return byName(ENHANCE_CLASS);
+ }
+}
diff --git a/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-3.x-plugin/src/main/java/org/skywalking/apm/plugin/spring/mvc/v3/define/InvocableHandlerInstrumentation.java b/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-3.x-plugin/src/main/java/org/skywalking/apm/plugin/spring/mvc/v3/define/InvocableHandlerInstrumentation.java
new file mode 100644
index 0000000000000000000000000000000000000000..0b87e87678cce95a6610037d900d44c8f5578856
--- /dev/null
+++ b/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-3.x-plugin/src/main/java/org/skywalking/apm/plugin/spring/mvc/v3/define/InvocableHandlerInstrumentation.java
@@ -0,0 +1,70 @@
+/*
+ * 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.spring.mvc.v3.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.match.ClassMatch;
+
+import static net.bytebuddy.matcher.ElementMatchers.named;
+import static org.skywalking.apm.agent.core.plugin.match.NameMatch.byName;
+
+/**
+ * {@link InvocableHandlerInstrumentation} intercept the invokeForRequest
method in the
+ * org.springframework.web.method.support.InvocableHandlerMethod
class.
+ *
+ * @author zhangxin
+ */
+public class InvocableHandlerInstrumentation extends AbstractSpring3Instrumentation {
+
+ public static final String ENHANCE_METHOD = "invokeForRequest";
+ public static final String INTERCEPTOR_CLASS = "org.skywalking.apm.plugin.spring.mvc.v3.InvokeForRequestInterceptor";
+ public static final String ENHANCE_CLASS = "org.springframework.web.method.support.InvocableHandlerMethod";
+
+ @Override protected ConstructorInterceptPoint[] getConstructorsInterceptPoints() {
+ return new ConstructorInterceptPoint[0];
+ }
+
+ @Override protected InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() {
+ return new InstanceMethodsInterceptPoint[] {
+ new InstanceMethodsInterceptPoint() {
+ @Override
+ public ElementMatcher getMethodsMatcher() {
+ return named(ENHANCE_METHOD);
+ }
+
+ @Override
+ public String getMethodsInterceptor() {
+ return INTERCEPTOR_CLASS;
+ }
+
+ @Override
+ public boolean isOverrideArgs() {
+ return false;
+ }
+ },
+ };
+ }
+
+ @Override protected ClassMatch enhanceClass() {
+ return byName(ENHANCE_CLASS);
+ }
+}
diff --git a/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-3.x-plugin/src/main/resources/skywalking-plugin.def b/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-3.x-plugin/src/main/resources/skywalking-plugin.def
new file mode 100644
index 0000000000000000000000000000000000000000..86b7b7658a7a956232728aece5e2629b3aebd6b4
--- /dev/null
+++ b/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-3.x-plugin/src/main/resources/skywalking-plugin.def
@@ -0,0 +1,3 @@
+spring-mvc-annotation-3.x=org.skywalking.apm.plugin.spring.mvc.v3.define.ControllerInstrumentation
+spring-mvc-annotation-3.x=org.skywalking.apm.plugin.spring.mvc.v3.define.HandlerMethodInstrumentation
+spring-mvc-annotation-3.x=org.skywalking.apm.plugin.spring.mvc.v3.define.InvocableHandlerInstrumentation
diff --git a/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-3.x-plugin/src/test/java/org/skywalking/apm/plugin/spring/mvc/v3/ControllerConstructorInterceptorTest.java b/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-3.x-plugin/src/test/java/org/skywalking/apm/plugin/spring/mvc/v3/ControllerConstructorInterceptorTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..678a6bdead6ddf224df89cc93c16d2fd67ba2070
--- /dev/null
+++ b/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-3.x-plugin/src/test/java/org/skywalking/apm/plugin/spring/mvc/v3/ControllerConstructorInterceptorTest.java
@@ -0,0 +1,101 @@
+/*
+ * 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.spring.mvc.v3;
+
+import java.lang.reflect.Field;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.powermock.modules.junit4.PowerMockRunner;
+import org.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
+import org.springframework.web.bind.annotation.RequestMapping;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.Is.is;
+
+@RunWith(PowerMockRunner.class)
+public class ControllerConstructorInterceptorTest {
+
+ private ControllerConstructorInterceptor interceptor;
+
+ private MockRequestMappingObject mappingObject;
+
+ private MockRequestMappingObjectWithoutRequestMapping withoutRequestMapping;
+
+ @Before
+ public void setUp() {
+ mappingObject = new MockRequestMappingObject();
+ withoutRequestMapping = new MockRequestMappingObjectWithoutRequestMapping();
+ interceptor = new ControllerConstructorInterceptor();
+ }
+
+ @Test
+ public void testClassAnnotationWithRequestMapping() throws NoSuchFieldException, IllegalAccessException {
+ interceptor.onConstruct(mappingObject, null);
+
+ assertThat("/test", is(getBasePath(mappingObject.requireObjectCache.getPathMappingCache())));
+ }
+
+ @Test
+ public void testClassAnnotationWithoutRequestMapping() throws NoSuchFieldException, IllegalAccessException {
+ interceptor.onConstruct(withoutRequestMapping, null);
+
+ assertThat("", is(getBasePath(withoutRequestMapping.requireObjectCache.getPathMappingCache())));
+ }
+
+ private String getBasePath(PathMappingCache mappingCache) throws NoSuchFieldException, IllegalAccessException {
+ Field classPath = mappingCache.getClass().getDeclaredField("classPath");
+ classPath.setAccessible(true);
+ return (String)classPath.get(mappingCache);
+ }
+
+ @RequestMapping("/test")
+ private class MockRequestMappingObject implements EnhancedInstance {
+ private EnhanceRequireObjectCache requireObjectCache;
+
+ @RequestMapping("/test")
+ private void mockTestMethod() {
+
+ }
+
+ @Override public Object getSkyWalkingDynamicField() {
+ return requireObjectCache;
+ }
+
+ @Override public void setSkyWalkingDynamicField(Object value) {
+ this.requireObjectCache = (EnhanceRequireObjectCache)value;
+ }
+ }
+
+ private class MockRequestMappingObjectWithoutRequestMapping implements EnhancedInstance {
+ private EnhanceRequireObjectCache requireObjectCache;
+
+ private void mockTestMethod() {
+
+ }
+
+ @Override public Object getSkyWalkingDynamicField() {
+ return requireObjectCache;
+ }
+
+ @Override public void setSkyWalkingDynamicField(Object value) {
+ this.requireObjectCache = (EnhanceRequireObjectCache)value;
+ }
+ }
+}
diff --git a/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-3.x-plugin/src/test/java/org/skywalking/apm/plugin/spring/mvc/v3/ControllerMethodInterceptorTest.java b/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-3.x-plugin/src/test/java/org/skywalking/apm/plugin/spring/mvc/v3/ControllerMethodInterceptorTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..e971815b466e050c8f73b9478fe8da9843bebf78
--- /dev/null
+++ b/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-3.x-plugin/src/test/java/org/skywalking/apm/plugin/spring/mvc/v3/ControllerMethodInterceptorTest.java
@@ -0,0 +1,178 @@
+/*
+ * 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.spring.mvc.v3;
+
+import java.lang.reflect.Method;
+import java.util.List;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
+import org.powermock.modules.junit4.PowerMockRunnerDelegate;
+import org.skywalking.apm.agent.core.context.SW3CarrierItem;
+import org.skywalking.apm.agent.core.context.trace.AbstractTracingSpan;
+import org.skywalking.apm.agent.core.context.trace.LogDataEntity;
+import org.skywalking.apm.agent.core.context.trace.SpanLayer;
+import org.skywalking.apm.agent.core.context.trace.TraceSegment;
+import org.skywalking.apm.agent.core.context.trace.TraceSegmentRef;
+import org.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
+import org.skywalking.apm.agent.test.helper.SegmentHelper;
+import org.skywalking.apm.agent.test.helper.SegmentRefHelper;
+import org.skywalking.apm.agent.test.helper.SpanHelper;
+import org.skywalking.apm.agent.test.tools.AgentServiceRule;
+import org.skywalking.apm.agent.test.tools.SegmentStorage;
+import org.skywalking.apm.agent.test.tools.SegmentStoragePoint;
+import org.skywalking.apm.agent.test.tools.TracingSegmentRunner;
+import org.skywalking.apm.network.trace.component.ComponentsDefine;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.context.request.NativeWebRequest;
+import org.springframework.web.context.request.RequestContextHolder;
+import org.springframework.web.context.request.ServletRequestAttributes;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.powermock.api.mockito.PowerMockito.mockStatic;
+import static org.powermock.api.mockito.PowerMockito.when;
+import static org.skywalking.apm.agent.test.tools.SpanAssert.assertComponent;
+import static org.skywalking.apm.agent.test.tools.SpanAssert.assertException;
+import static org.skywalking.apm.agent.test.tools.SpanAssert.assertLayer;
+import static org.skywalking.apm.agent.test.tools.SpanAssert.assertTag;
+
+@RunWith(PowerMockRunner.class)
+@PowerMockRunnerDelegate(TracingSegmentRunner.class)
+@PrepareForTest({RequestContextHolder.class, ServletRequestAttributes.class})
+public class ControllerMethodInterceptorTest {
+
+ @SegmentStoragePoint
+ private SegmentStorage segmentStorage;
+
+ @Rule
+ public AgentServiceRule serviceRule = new AgentServiceRule();
+
+ @Mock
+ private EnhancedInstance enhancedInstance;
+ @Mock
+ private NativeWebRequest nativeWebRequest;
+ @Mock
+ private HttpServletResponse httpServletResponse;
+ @Mock
+ private ServletRequestAttributes servletRequestAttributes;
+ @Mock
+ private HttpServletRequest httpServletRequest;
+
+ private Method method;
+
+ private EnhanceRequireObjectCache enhanceRequireObjectCache;
+ private ControllerMethodInterceptor controllerMethodInterceptor;
+
+ @Before
+ public void setUp() throws NoSuchMethodException {
+ controllerMethodInterceptor = new ControllerMethodInterceptor();
+ enhanceRequireObjectCache = new EnhanceRequireObjectCache();
+ enhanceRequireObjectCache.setPathMappingCache(new PathMappingCache("/test"));
+ method = ControllerMethodInterceptorTest.class.getDeclaredMethod("mockControllerService");
+ enhanceRequireObjectCache.addPathMapping(method, "/test");
+
+ enhanceRequireObjectCache.setNativeWebRequest(nativeWebRequest);
+ enhanceRequireObjectCache.setPathMappingCache(new PathMappingCache("/test"));
+
+ mockStatic(RequestContextHolder.class);
+ when(servletRequestAttributes.getRequest()).thenReturn(httpServletRequest);
+ when(nativeWebRequest.getNativeResponse()).thenReturn(httpServletResponse);
+ when(enhancedInstance.getSkyWalkingDynamicField()).thenReturn(enhanceRequireObjectCache);
+ when(RequestContextHolder.getRequestAttributes()).thenReturn(servletRequestAttributes);
+ when(httpServletRequest.getMethod()).thenReturn("GET");
+ when(httpServletRequest.getRequestURL()).thenReturn(new StringBuffer("http://localhost:8080/skywalking-test/test"));
+ }
+
+ @Test
+ public void testWithoutSerializedContextData() throws Throwable {
+ controllerMethodInterceptor.beforeMethod(enhancedInstance, method, null, null, null);
+ controllerMethodInterceptor.afterMethod(enhancedInstance, method, null, null, null);
+
+ assertThat(segmentStorage.getTraceSegments().size(), is(1));
+ TraceSegment traceSegment = segmentStorage.getTraceSegments().get(0);
+
+ List spans = SegmentHelper.getSpans(traceSegment);
+ assertThat(spans.size(), is(1));
+ assertRequestSpan(spans.get(0));
+ }
+
+ @Test
+ public void testWithSerializedContextData() throws Throwable {
+ Mockito.when(httpServletRequest.getHeader(SW3CarrierItem.HEADER_NAME)).thenReturn("1.234.111|3|1|1|#192.168.1.8:18002|#/portal/|#/testEntrySpan|#AQA*#AQA*Et0We0tQNQA*");
+
+ controllerMethodInterceptor.beforeMethod(enhancedInstance, method, null, null, null);
+ controllerMethodInterceptor.afterMethod(enhancedInstance, method, null, null, null);
+
+ assertThat(segmentStorage.getTraceSegments().size(), is(1));
+ TraceSegment traceSegment = segmentStorage.getTraceSegments().get(0);
+
+ List spans = SegmentHelper.getSpans(traceSegment);
+ assertThat(spans.size(), is(1));
+ assertRequestSpan(spans.get(0));
+
+ List traceSegmentRefs = traceSegment.getRefs();
+ assertThat(traceSegmentRefs.size(), is(1));
+ assertTraceSegmentRef(traceSegmentRefs.get(0));
+ }
+
+ @Test
+ public void testOccurException() throws Throwable {
+ controllerMethodInterceptor.beforeMethod(enhancedInstance, method, null, null, null);
+ controllerMethodInterceptor.handleMethodException(enhancedInstance, method, null, null, new RuntimeException());
+ controllerMethodInterceptor.afterMethod(enhancedInstance, method, null, null, null);
+
+ assertThat(segmentStorage.getTraceSegments().size(), is(1));
+ TraceSegment traceSegment = segmentStorage.getTraceSegments().get(0);
+
+ List spans = SegmentHelper.getSpans(traceSegment);
+ assertThat(spans.size(), is(1));
+ assertRequestSpan(spans.get(0));
+
+ List logDataEntities = SpanHelper.getLogs(spans.get(0));
+ assertThat(logDataEntities.size(), is(1));
+ assertException(logDataEntities.get(0), RuntimeException.class);
+ }
+
+ private void assertTraceSegmentRef(TraceSegmentRef ref) {
+ assertThat(SegmentRefHelper.getEntryApplicationInstanceId(ref), is(1));
+ assertThat(SegmentRefHelper.getSpanId(ref), is(3));
+ assertThat(SegmentRefHelper.getTraceSegmentId(ref).toString(), is("1.234.111"));
+ }
+
+ private void assertRequestSpan(AbstractTracingSpan span) {
+ assertThat(span.getOperationName(), is("/test/test"));
+ assertComponent(span, ComponentsDefine.SPRING_MVC_ANNOTATION);
+ assertTag(span, 0, "http://localhost:8080/skywalking-test/test");
+ assertThat(span.isEntry(), is(true));
+ assertLayer(span, SpanLayer.HTTP);
+ }
+
+ @RequestMapping("/test")
+ public void mockControllerService() {
+
+ }
+}
diff --git a/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-3.x-plugin/src/test/java/org/skywalking/apm/plugin/spring/mvc/v3/GetBeanInterceptorTest.java b/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-3.x-plugin/src/test/java/org/skywalking/apm/plugin/spring/mvc/v3/GetBeanInterceptorTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..d5b73d0b1c19a0f54259639699bc01a02cd6c25b
--- /dev/null
+++ b/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-3.x-plugin/src/test/java/org/skywalking/apm/plugin/spring/mvc/v3/GetBeanInterceptorTest.java
@@ -0,0 +1,70 @@
+/*
+ * 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.spring.mvc.v3;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Matchers;
+import org.mockito.Mock;
+import org.mockito.runners.MockitoJUnitRunner;
+import org.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
+import org.springframework.web.context.request.NativeWebRequest;
+
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+@RunWith(MockitoJUnitRunner.class)
+public class GetBeanInterceptorTest {
+
+ @Mock
+ private EnhancedInstance enhancedInstance;
+
+ @Mock
+ private NativeWebRequest request;
+
+ @Mock
+ private EnhancedInstance enhanceRet;
+
+ private GetBeanInterceptor interceptor;
+
+ @Before
+ public void setUp() {
+ interceptor = new GetBeanInterceptor();
+
+ when(enhanceRet.getSkyWalkingDynamicField()).thenReturn(new EnhanceRequireObjectCache());
+ when(enhancedInstance.getSkyWalkingDynamicField()).thenReturn(request);
+ }
+
+ @Test
+ public void testResultIsNotEnhanceInstance() throws Throwable {
+ interceptor.afterMethod(enhancedInstance, null, null, null, new Object());
+
+ verify(enhanceRet, times(0)).setSkyWalkingDynamicField(Matchers.any());
+ }
+
+ @Test
+ public void testResultIsEnhanceInstance() throws Throwable {
+ interceptor.afterMethod(enhancedInstance, null, null, null, enhanceRet);
+
+ verify(enhanceRet, times(0)).setSkyWalkingDynamicField(Matchers.any());
+ }
+
+}
diff --git a/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-3.x-plugin/src/test/java/org/skywalking/apm/plugin/spring/mvc/v3/InvokeForRequestInterceptorTest.java b/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-3.x-plugin/src/test/java/org/skywalking/apm/plugin/spring/mvc/v3/InvokeForRequestInterceptorTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..5cd45920aa52caa224bf1303abffdda533755a3f
--- /dev/null
+++ b/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-3.x-plugin/src/test/java/org/skywalking/apm/plugin/spring/mvc/v3/InvokeForRequestInterceptorTest.java
@@ -0,0 +1,57 @@
+/*
+ * 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.spring.mvc.v3;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Matchers;
+import org.mockito.Mock;
+import org.mockito.runners.MockitoJUnitRunner;
+import org.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
+import org.springframework.web.context.request.NativeWebRequest;
+
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+
+@RunWith(MockitoJUnitRunner.class)
+public class InvokeForRequestInterceptorTest {
+ private InvokeForRequestInterceptor interceptor;
+
+ @Mock
+ private EnhancedInstance enhancedInstance;
+
+ @Mock
+ private NativeWebRequest nativeWebRequest;
+
+ private Object argument[];
+
+ @Before
+ public void setUp() {
+ interceptor = new InvokeForRequestInterceptor();
+ argument = new Object[] {nativeWebRequest};
+ }
+
+ @Test
+ public void testPassNativeWebRequest() throws Throwable {
+ interceptor.beforeMethod(enhancedInstance, null, argument, new Class[] {NativeWebRequest.class}, null);
+
+ verify(enhancedInstance, times(1)).setSkyWalkingDynamicField(Matchers.any());
+ }
+}
diff --git a/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-4.x-plugin/pom.xml b/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-4.x-plugin/pom.xml
index a27e12bae691e3cb56df29ec7fe6dcbb96f60821..b0d3e300147400eb123cb1a538c0359ddb35bae9 100644
--- a/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-4.x-plugin/pom.xml
+++ b/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-4.x-plugin/pom.xml
@@ -47,7 +47,7 @@
javax.servlet
javax.servlet-api
- 4.0.0-b01
+ 3.0.1
provided
diff --git a/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-4.x-plugin/src/main/java/org/skywalking/apm/plugin/spring/mvc/AbstractMethodInteceptor.java b/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-4.x-plugin/src/main/java/org/skywalking/apm/plugin/spring/mvc/v4/AbstractMethodInteceptor.java
similarity index 98%
rename from apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-4.x-plugin/src/main/java/org/skywalking/apm/plugin/spring/mvc/AbstractMethodInteceptor.java
rename to apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-4.x-plugin/src/main/java/org/skywalking/apm/plugin/spring/mvc/v4/AbstractMethodInteceptor.java
index c641b1f535346e42f932e1d6d80681cba8995f96..62f02b6cfa9ac9ed6032077b6b40d5bef530bf64 100644
--- a/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-4.x-plugin/src/main/java/org/skywalking/apm/plugin/spring/mvc/AbstractMethodInteceptor.java
+++ b/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-4.x-plugin/src/main/java/org/skywalking/apm/plugin/spring/mvc/v4/AbstractMethodInteceptor.java
@@ -16,7 +16,7 @@
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
-package org.skywalking.apm.plugin.spring.mvc;
+package org.skywalking.apm.plugin.spring.mvc.v4;
import java.lang.reflect.Method;
import javax.servlet.http.HttpServletRequest;
diff --git a/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-4.x-plugin/src/main/java/org/skywalking/apm/plugin/spring/mvc/ControllerConstructorInterceptor.java b/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-4.x-plugin/src/main/java/org/skywalking/apm/plugin/spring/mvc/v4/ControllerConstructorInterceptor.java
similarity index 97%
rename from apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-4.x-plugin/src/main/java/org/skywalking/apm/plugin/spring/mvc/ControllerConstructorInterceptor.java
rename to apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-4.x-plugin/src/main/java/org/skywalking/apm/plugin/spring/mvc/v4/ControllerConstructorInterceptor.java
index 75ef94dc5c34df18997177867d63e48aee93ad52..83f72c4664cb8b143f80f774510489c793943db3 100644
--- a/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-4.x-plugin/src/main/java/org/skywalking/apm/plugin/spring/mvc/ControllerConstructorInterceptor.java
+++ b/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-4.x-plugin/src/main/java/org/skywalking/apm/plugin/spring/mvc/v4/ControllerConstructorInterceptor.java
@@ -16,7 +16,7 @@
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
-package org.skywalking.apm.plugin.spring.mvc;
+package org.skywalking.apm.plugin.spring.mvc.v4;
import org.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
import org.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceConstructorInterceptor;
diff --git a/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-4.x-plugin/src/main/java/org/skywalking/apm/plugin/spring/mvc/PathMappingCache.java b/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-4.x-plugin/src/main/java/org/skywalking/apm/plugin/spring/mvc/v4/PathMappingCache.java
similarity index 96%
rename from apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-4.x-plugin/src/main/java/org/skywalking/apm/plugin/spring/mvc/PathMappingCache.java
rename to apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-4.x-plugin/src/main/java/org/skywalking/apm/plugin/spring/mvc/v4/PathMappingCache.java
index ea26246b09c9792db4500df51cfc1c2179c9549a..ea49c81d3573c63b759ed6f82f4dbc07d3b87451 100644
--- a/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-4.x-plugin/src/main/java/org/skywalking/apm/plugin/spring/mvc/PathMappingCache.java
+++ b/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-4.x-plugin/src/main/java/org/skywalking/apm/plugin/spring/mvc/v4/PathMappingCache.java
@@ -16,7 +16,7 @@
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
-package org.skywalking.apm.plugin.spring.mvc;
+package org.skywalking.apm.plugin.spring.mvc.v4;
import java.lang.reflect.Method;
import java.util.concurrent.ConcurrentHashMap;
diff --git a/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-4.x-plugin/src/main/java/org/skywalking/apm/plugin/spring/mvc/RequestMappingMethodInterceptor.java b/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-4.x-plugin/src/main/java/org/skywalking/apm/plugin/spring/mvc/v4/RequestMappingMethodInterceptor.java
similarity index 96%
rename from apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-4.x-plugin/src/main/java/org/skywalking/apm/plugin/spring/mvc/RequestMappingMethodInterceptor.java
rename to apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-4.x-plugin/src/main/java/org/skywalking/apm/plugin/spring/mvc/v4/RequestMappingMethodInterceptor.java
index 2f733bfc1478d6847de8da148d4726d60112bba4..4b1bdd4e55bb251ea2600cd710ebaf42c8396dd6 100644
--- a/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-4.x-plugin/src/main/java/org/skywalking/apm/plugin/spring/mvc/RequestMappingMethodInterceptor.java
+++ b/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-4.x-plugin/src/main/java/org/skywalking/apm/plugin/spring/mvc/v4/RequestMappingMethodInterceptor.java
@@ -16,7 +16,7 @@
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
-package org.skywalking.apm.plugin.spring.mvc;
+package org.skywalking.apm.plugin.spring.mvc.v4;
import java.lang.reflect.Method;
import org.springframework.web.bind.annotation.RequestMapping;
diff --git a/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-4.x-plugin/src/main/java/org/skywalking/apm/plugin/spring/mvc/RestMappingMethodInterceptor.java b/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-4.x-plugin/src/main/java/org/skywalking/apm/plugin/spring/mvc/v4/RestMappingMethodInterceptor.java
similarity index 98%
rename from apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-4.x-plugin/src/main/java/org/skywalking/apm/plugin/spring/mvc/RestMappingMethodInterceptor.java
rename to apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-4.x-plugin/src/main/java/org/skywalking/apm/plugin/spring/mvc/v4/RestMappingMethodInterceptor.java
index ad51e6b1d64064a94f75aafc4b29705410545939..571098b9efde6ef2958680be3001b0650d10f6b0 100644
--- a/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-4.x-plugin/src/main/java/org/skywalking/apm/plugin/spring/mvc/RestMappingMethodInterceptor.java
+++ b/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-4.x-plugin/src/main/java/org/skywalking/apm/plugin/spring/mvc/v4/RestMappingMethodInterceptor.java
@@ -16,7 +16,7 @@
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
-package org.skywalking.apm.plugin.spring.mvc;
+package org.skywalking.apm.plugin.spring.mvc.v4;
import java.lang.reflect.Method;
import org.springframework.web.bind.annotation.DeleteMapping;
diff --git a/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-4.x-plugin/src/main/java/org/skywalking/apm/plugin/spring/mvc/define/AbstractControllerInstrumentation.java b/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-4.x-plugin/src/main/java/org/skywalking/apm/plugin/spring/mvc/v4/define/AbstractControllerInstrumentation.java
similarity index 98%
rename from apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-4.x-plugin/src/main/java/org/skywalking/apm/plugin/spring/mvc/define/AbstractControllerInstrumentation.java
rename to apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-4.x-plugin/src/main/java/org/skywalking/apm/plugin/spring/mvc/v4/define/AbstractControllerInstrumentation.java
index c4d2e41958551564a8c020d9180527a6a5e9f1ea..3e7670fe732f1199f96f019f37769d52bc45f54e 100644
--- a/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-4.x-plugin/src/main/java/org/skywalking/apm/plugin/spring/mvc/define/AbstractControllerInstrumentation.java
+++ b/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-4.x-plugin/src/main/java/org/skywalking/apm/plugin/spring/mvc/v4/define/AbstractControllerInstrumentation.java
@@ -16,7 +16,7 @@
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
-package org.skywalking.apm.plugin.spring.mvc.define;
+package org.skywalking.apm.plugin.spring.mvc.v4.define;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.matcher.ElementMatcher;
diff --git a/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-4.x-plugin/src/main/java/org/skywalking/apm/plugin/spring/mvc/define/ControllerInstrumentation.java b/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-4.x-plugin/src/main/java/org/skywalking/apm/plugin/spring/mvc/v4/define/ControllerInstrumentation.java
similarity index 94%
rename from apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-4.x-plugin/src/main/java/org/skywalking/apm/plugin/spring/mvc/define/ControllerInstrumentation.java
rename to apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-4.x-plugin/src/main/java/org/skywalking/apm/plugin/spring/mvc/v4/define/ControllerInstrumentation.java
index cdfe7d0293db721879062fa4a346c4b9db406fca..e7747463f648853fcec8cb65284c5e1768706e92 100644
--- a/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-4.x-plugin/src/main/java/org/skywalking/apm/plugin/spring/mvc/define/ControllerInstrumentation.java
+++ b/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-4.x-plugin/src/main/java/org/skywalking/apm/plugin/spring/mvc/v4/define/ControllerInstrumentation.java
@@ -16,7 +16,7 @@
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
-package org.skywalking.apm.plugin.spring.mvc.define;
+package org.skywalking.apm.plugin.spring.mvc.v4.define;
public class ControllerInstrumentation extends AbstractControllerInstrumentation {
diff --git a/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-4.x-plugin/src/main/java/org/skywalking/apm/plugin/spring/mvc/define/RestControllerInstrumentation.java b/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-4.x-plugin/src/main/java/org/skywalking/apm/plugin/spring/mvc/v4/define/RestControllerInstrumentation.java
similarity index 94%
rename from apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-4.x-plugin/src/main/java/org/skywalking/apm/plugin/spring/mvc/define/RestControllerInstrumentation.java
rename to apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-4.x-plugin/src/main/java/org/skywalking/apm/plugin/spring/mvc/v4/define/RestControllerInstrumentation.java
index cefa8406928092c03b2aca22472c36fbbf0544c9..03431d78bdf14f3f13263983a8db3175b068f6e3 100644
--- a/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-4.x-plugin/src/main/java/org/skywalking/apm/plugin/spring/mvc/define/RestControllerInstrumentation.java
+++ b/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-4.x-plugin/src/main/java/org/skywalking/apm/plugin/spring/mvc/v4/define/RestControllerInstrumentation.java
@@ -16,7 +16,7 @@
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
-package org.skywalking.apm.plugin.spring.mvc.define;
+package org.skywalking.apm.plugin.spring.mvc.v4.define;
public class RestControllerInstrumentation extends AbstractControllerInstrumentation {
diff --git a/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-4.x-plugin/src/main/resources/skywalking-plugin.def b/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-4.x-plugin/src/main/resources/skywalking-plugin.def
index 92d3695bae8ee2fb9d585ce34757e6ecb0e219e6..9196c36f349d75396ec22a375755a15c1a675106 100644
--- a/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-4.x-plugin/src/main/resources/skywalking-plugin.def
+++ b/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-4.x-plugin/src/main/resources/skywalking-plugin.def
@@ -1,2 +1,2 @@
-spring-mvc-annotation-4.x=org.skywalking.apm.plugin.spring.mvc.define.ControllerInstrumentation
-spring-mvc-annotation-4.x=org.skywalking.apm.plugin.spring.mvc.define.RestControllerInstrumentation
\ No newline at end of file
+spring-mvc-annotation-4.x=org.skywalking.apm.plugin.spring.mvc.v4.define.ControllerInstrumentation
+spring-mvc-annotation-4.x=org.skywalking.apm.plugin.spring.mvc.v4.define.RestControllerInstrumentation
diff --git a/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-4.x-plugin/src/test/java/org/skywalking/apm/plugin/spring/mvc/ControllerConstructorInterceptorTest.java b/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-4.x-plugin/src/test/java/org/skywalking/apm/plugin/spring/mvc/v4/ControllerConstructorInterceptorTest.java
similarity index 98%
rename from apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-4.x-plugin/src/test/java/org/skywalking/apm/plugin/spring/mvc/ControllerConstructorInterceptorTest.java
rename to apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-4.x-plugin/src/test/java/org/skywalking/apm/plugin/spring/mvc/v4/ControllerConstructorInterceptorTest.java
index 76547a0c3d0dabf2e3b6062b36b82d00faa6aaee..0e96121a0a19f13e73f2a5feb9ddf761390d93fe 100644
--- a/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-4.x-plugin/src/test/java/org/skywalking/apm/plugin/spring/mvc/ControllerConstructorInterceptorTest.java
+++ b/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-4.x-plugin/src/test/java/org/skywalking/apm/plugin/spring/mvc/v4/ControllerConstructorInterceptorTest.java
@@ -16,7 +16,7 @@
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
-package org.skywalking.apm.plugin.spring.mvc;
+package org.skywalking.apm.plugin.spring.mvc.v4;
import java.lang.reflect.Method;
import org.junit.Assert;
diff --git a/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-4.x-plugin/src/test/java/org/skywalking/apm/plugin/spring/mvc/PathMappingCacheTest.java b/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-4.x-plugin/src/test/java/org/skywalking/apm/plugin/spring/mvc/v4/PathMappingCacheTest.java
similarity index 97%
rename from apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-4.x-plugin/src/test/java/org/skywalking/apm/plugin/spring/mvc/PathMappingCacheTest.java
rename to apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-4.x-plugin/src/test/java/org/skywalking/apm/plugin/spring/mvc/v4/PathMappingCacheTest.java
index 9d7eb008dcdf094e489fefc7c78f5b542fadb1aa..a0761b507f5e217f73670679a5b5a1c93af82f3d 100644
--- a/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-4.x-plugin/src/test/java/org/skywalking/apm/plugin/spring/mvc/PathMappingCacheTest.java
+++ b/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-4.x-plugin/src/test/java/org/skywalking/apm/plugin/spring/mvc/v4/PathMappingCacheTest.java
@@ -16,7 +16,7 @@
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
-package org.skywalking.apm.plugin.spring.mvc;
+package org.skywalking.apm.plugin.spring.mvc.v4;
import java.lang.reflect.Method;
import org.junit.Assert;
diff --git a/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-4.x-plugin/src/test/java/org/skywalking/apm/plugin/spring/mvc/RequestMappingMethodInterceptorTest.java b/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-4.x-plugin/src/test/java/org/skywalking/apm/plugin/spring/mvc/v4/RequestMappingMethodInterceptorTest.java
similarity index 99%
rename from apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-4.x-plugin/src/test/java/org/skywalking/apm/plugin/spring/mvc/RequestMappingMethodInterceptorTest.java
rename to apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-4.x-plugin/src/test/java/org/skywalking/apm/plugin/spring/mvc/v4/RequestMappingMethodInterceptorTest.java
index b03db674d2dcce55bf242b058becb26b79d61c83..2ed195557eed4841e1cdb88cbdf126e6bdac96e8 100644
--- a/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-4.x-plugin/src/test/java/org/skywalking/apm/plugin/spring/mvc/RequestMappingMethodInterceptorTest.java
+++ b/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-4.x-plugin/src/test/java/org/skywalking/apm/plugin/spring/mvc/v4/RequestMappingMethodInterceptorTest.java
@@ -16,7 +16,7 @@
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
-package org.skywalking.apm.plugin.spring.mvc;
+package org.skywalking.apm.plugin.spring.mvc.v4;
import java.lang.reflect.Method;
import java.util.List;
diff --git a/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-4.x-plugin/src/test/java/org/skywalking/apm/plugin/spring/mvc/RestMappingMethodInterceptorTest.java b/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-4.x-plugin/src/test/java/org/skywalking/apm/plugin/spring/mvc/v4/RestMappingMethodInterceptorTest.java
similarity index 99%
rename from apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-4.x-plugin/src/test/java/org/skywalking/apm/plugin/spring/mvc/RestMappingMethodInterceptorTest.java
rename to apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-4.x-plugin/src/test/java/org/skywalking/apm/plugin/spring/mvc/v4/RestMappingMethodInterceptorTest.java
index 0f19b38a0a585d729878adf0ef073bcb8dc60036..75db61abfe1d69fbf2a9c339a70b976b70787268 100644
--- a/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-4.x-plugin/src/test/java/org/skywalking/apm/plugin/spring/mvc/RestMappingMethodInterceptorTest.java
+++ b/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-4.x-plugin/src/test/java/org/skywalking/apm/plugin/spring/mvc/v4/RestMappingMethodInterceptorTest.java
@@ -16,7 +16,7 @@
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
-package org.skywalking.apm.plugin.spring.mvc;
+package org.skywalking.apm.plugin.spring.mvc.v4;
import java.lang.reflect.Method;
import java.util.List;
diff --git a/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-4.x-plugin/src/test/java/org/skywalking/apm/plugin/spring/mvc/define/ControllerInstrumentationTest.java b/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-4.x-plugin/src/test/java/org/skywalking/apm/plugin/spring/mvc/v4/define/ControllerInstrumentationTest.java
similarity index 98%
rename from apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-4.x-plugin/src/test/java/org/skywalking/apm/plugin/spring/mvc/define/ControllerInstrumentationTest.java
rename to apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-4.x-plugin/src/test/java/org/skywalking/apm/plugin/spring/mvc/v4/define/ControllerInstrumentationTest.java
index 7cd9eead54e93c1d01a3b17c197ed57c50f6ce44..8c9f30828219fa2616c5635eeb2f3d4940d81e45 100644
--- a/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-4.x-plugin/src/test/java/org/skywalking/apm/plugin/spring/mvc/define/ControllerInstrumentationTest.java
+++ b/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-4.x-plugin/src/test/java/org/skywalking/apm/plugin/spring/mvc/v4/define/ControllerInstrumentationTest.java
@@ -16,7 +16,7 @@
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
-package org.skywalking.apm.plugin.spring.mvc.define;
+package org.skywalking.apm.plugin.spring.mvc.v4.define;
import net.bytebuddy.matcher.ElementMatchers;
import org.junit.Assert;
diff --git a/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-4.x-plugin/src/test/java/org/skywalking/apm/plugin/spring/mvc/define/RestControllerInstrumentationTest.java b/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-4.x-plugin/src/test/java/org/skywalking/apm/plugin/spring/mvc/v4/define/RestControllerInstrumentationTest.java
similarity index 97%
rename from apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-4.x-plugin/src/test/java/org/skywalking/apm/plugin/spring/mvc/define/RestControllerInstrumentationTest.java
rename to apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-4.x-plugin/src/test/java/org/skywalking/apm/plugin/spring/mvc/v4/define/RestControllerInstrumentationTest.java
index 0116821df5b99da9a3d3892a19414a060b710958..97bf085f225cdfd0450d82ebfcdf4539793c00ec 100644
--- a/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-4.x-plugin/src/test/java/org/skywalking/apm/plugin/spring/mvc/define/RestControllerInstrumentationTest.java
+++ b/apm-sniffer/apm-sdk-plugin/spring-plugins/mvc-annotation-4.x-plugin/src/test/java/org/skywalking/apm/plugin/spring/mvc/v4/define/RestControllerInstrumentationTest.java
@@ -16,7 +16,7 @@
* Project repository: https://github.com/OpenSkywalking/skywalking
*/
-package org.skywalking.apm.plugin.spring.mvc.define;
+package org.skywalking.apm.plugin.spring.mvc.v4.define;
import org.junit.Assert;
import org.junit.Before;
diff --git a/apm-sniffer/apm-sdk-plugin/spring-plugins/pom.xml b/apm-sniffer/apm-sdk-plugin/spring-plugins/pom.xml
index 83be51dec4a5f35e911d2fa668bd2dc369b72a67..546d3bcb84f45f62a7a8d655f71e2313fd517e9f 100644
--- a/apm-sniffer/apm-sdk-plugin/spring-plugins/pom.xml
+++ b/apm-sniffer/apm-sdk-plugin/spring-plugins/pom.xml
@@ -33,6 +33,7 @@
resttemplate-4.x-plugin
mvc-annotation-4.x-plugin
spring-cloud
+ mvc-annotation-3.x-plugin
pom