我在我们的应用程序中使用了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
时存在巨大的时差。
是什么原因?