Search in sources :

Example 1 with PathMappingCache

use of org.apache.skywalking.apm.plugin.spring.mvc.commons.PathMappingCache in project incubator-skywalking by apache.

the class ControllerConstructorInterceptor method onConstruct.

@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);
}
Also used : EnhanceRequireObjectCache(org.apache.skywalking.apm.plugin.spring.mvc.commons.EnhanceRequireObjectCache) PathMappingCache(org.apache.skywalking.apm.plugin.spring.mvc.commons.PathMappingCache) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with PathMappingCache

use of org.apache.skywalking.apm.plugin.spring.mvc.commons.PathMappingCache in project incubator-skywalking by apache.

the class ControllerConstructorInterceptor method onConstruct.

@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];
        } else if (basePathRequestMapping.path().length > 0) {
            basePath = basePathRequestMapping.path()[0];
        }
    }
    EnhanceRequireObjectCache enhanceRequireObjectCache = new EnhanceRequireObjectCache();
    enhanceRequireObjectCache.setPathMappingCache(new PathMappingCache(basePath));
    objInst.setSkyWalkingDynamicField(enhanceRequireObjectCache);
}
Also used : EnhanceRequireObjectCache(org.apache.skywalking.apm.plugin.spring.mvc.commons.EnhanceRequireObjectCache) PathMappingCache(org.apache.skywalking.apm.plugin.spring.mvc.commons.PathMappingCache) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

EnhanceRequireObjectCache (org.apache.skywalking.apm.plugin.spring.mvc.commons.EnhanceRequireObjectCache)2 PathMappingCache (org.apache.skywalking.apm.plugin.spring.mvc.commons.PathMappingCache)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2