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); }  @Override void onConstruct(EnhancedInstance objInst, Object[] allArguments);  }
@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()))); }