为什么FilterSecurityMetadataSource类到控制器类需要更长的时间?

时间:2015-08-14 05:22:48

标签: java spring-security timing spring-security-oauth2

我在我们的应用程序中使用了Spring security oauth2。对于某些特定请求,FilterSecurityMetadataSource对控制器所花费的时间要高得多。

FilterSecurityMetadataSource上课:

public class FilterSecurityMetadataSource implements
        FilterInvocationSecurityMetadataSource {

    @Override
    public List<ConfigAttribute> getAttributes(Object object) {
        // ...
        System.out.println("In FilterInvocation Class");
        attributes = SecurityConfig.createListFromCommaDelimitedString(roles);
        return attributes;
    }

    @Override
    public Collection<ConfigAttribute> getAllConfigAttributes() {
        return null;
    }

    @Override
    public boolean supports(Class<?> clazz) {
        return FilterInvocation.class.isAssignableFrom(clazz);
    }
}

我的控制器类是这样的:

@RestController
public class MobileController {

    @RequestMapping(value = "/read/bills", method = RequestMethod.POST)
       public Map method1(HttpServletRequest request, HttpServletResponse response) {
       // ...
   }

    @RequestMapping(value = "/test/id", method = RequestMethod.GET)
       public Map method2(HttpServletRequest request, HttpServletResponse response) {
       // ...
   }

    @RequestMapping(value = "/test/item", method = RequestMethod.GET)
       public Map method3(HttpServletRequest request, HttpServletResponse response) {

     System.out.println("Test Method3");
     // ...
    }
}

在我检查的服务器上,我发现打印两个SOUT时存在巨大的时差。

是什么原因?

0 个答案:

没有答案