图1 如上面图1所示,RequestMappingHandlerMapping的类继承图,List-2中getHandler方法调用在AbstractHandlerMapping中,如下List -3,接着来看getHandlerInternal(request)的实现 List-3 public final HandlerExecutionChain getHandler(HttpServletRequest executionChain, config); } return executionChain; } getHandlerInternal的实现在AbstractHandlerMethodMapping中,如List -3所示 获取request中的url 调用lookupHandlerMethod方法获取HandlerMethod,如List-4所示 List-3 @Override protected HandlerMethod 回到List-3,在List-4中返回HandlerMethod后,调用getHandlerExecutionChain方法构造一个HandlerExecutionChain,读者可以去看下HandlerExecutionChain
this.registry); } return this.registry.getBeanDefinitionCount() - beanCountAtScanStart; } List holder.getBeanName() + "'."); } definition.setAutowireMode(2); } } } List List-3的processBeanDefinitions方法中设置BeanClass为MapperFactoryBean,答案就在这个MapperFactoryBean中。 注意List-3的末尾处有个"definition.setAutowireMode(2);",这是设置注入的类型,哪2是哪种类型呢,来看AbstractBeanDefinition,如下List-4,2 or 'sqlSessionTemplate' are required"); } } Spring会调用List-6中的方法setSqlSessionFactory方法,为什么这么说,List
systemd/system/ sudo vim /etc/systemd/system/mysql.service 在/etc/systemd/system/mysql.service文件末尾加入如下List -3中的内容 List-3 LimitNOFILE=65535 LimitMEMLOCK=65535 3.编辑/etc/mysql/my.cnf,加入List-4中的内容 List-4 [mysqld
来分析getDefaultStrategies的源码,如下List-3所示。 List-3 getDefaultStrategies的源码 protected <T> List<T> getDefaultStrategies(ApplicationContext context, 我们来看下这个文件里面的内容,如下图3所示,可以看到默认情况下HandlerMapping定义了俩个,即BeanNameUrlHandlerMapping和DefaultAnnotationHandlerMapping,所以List 图3 文件DispatcherServlet.properties的内容 List-3中的createDefaultStrategy(context, clazz),代码如下List-4所示。
this.methodCache.put(cacheKey, cached); } return cached; } getInterceptorsAndDynamicInterceptionAdvice的方法实现如下List -3所示,会将Advisor转换为Interceptor,List-3中的registry是DefaultAdvisorAdapterRegistry。 List-3 public class DefaultAdvisorChainFactory implements AdvisorChainFactory, Serializable { @Override
3.GlobalSecurityContextHolderStrategy 它里面使用的是静态属性,如下List-3所示: List-3 private static SecurityContext
图2 如图2中所示的红框内,就是获取Filter,在拿到Filter之后,会对它们进行排序,这个看下SecurityFilters,如下List-3所示,排序是根据List-3中的属性order List-3 enum SecurityFilters { FIRST(Integer.MIN_VALUE), CHANNEL_FILTER, SECURITY_CONTEXT_FILTER,
} } 在List-2中的doFilterInternal,通过getFilters(HttpServletRequest)方法,根据request的url来获取对应的Filter,如下List List-3 private List<Filter> getFilters(HttpServletRequest request) { for (SecurityFilterChain chain SecurityFilterChain { boolean matches(HttpServletRequest request); List<Filter> getFilters(); } 如果List
为什么说LocalCache生命周期与SqlSession一致,如List-3所示: List-3 DefaultSqlSessionFactory的openSessionFromDataSource List-3中的方法openSessionFromDataSource和方法openSessionFromConnection中的configuration.newExecutor(tx, execType
this.interceptorsAndDynamicMethodMatchers = interceptorsAndDynamicMethodMatchers; } ReflectiveMethodInvocation一个重要的方法是proceed(),如下List List-3 public Object proceed() throws Throwable { // We start with an index of -1 and increment early return ((MethodInterceptor) interceptorOrInterceptionAdvice).invoke(this); } } List-3中,如果拦截器还没有执行完
JdbcClientDetailsService则是将ClientDetails存储在数据库中,如下List-3所示 List-3 JdbcClientDetailsService的loadClientByClientId new NoSuchClientException("No client with requested id: " + clientId); } return details; } 如List
图1 List-3 public ContentNegotiationManager build() { List<ContentNegotiationStrategy> strategies = this.contentNegotiationManager = new ContentNegotiationManager(strategies); return this.contentNegotiationManager; } 如上List ContentNegotiationManager的resolveMediaTypes方法,顺序遍历strategy,如果resolveMediaTypes返回的值不等于MEDIA_TYPE_ALL_LIST,那么就直接返回,结合List
FeignContext是在FeignAutoConfiguration中注册到Spring容器中的,如List-3所示,会将spring容器所有的FeignClientSpecification放入到 List-3 public class FeignAutoConfiguration { @Autowired(required = false) private List<FeignClientSpecification 来看下FeignContext的父类NamedContextFactory,List-5中的setConfigurations方法在List-3中调用,在构造FeignContext的时候调用的。
a|egrep -v 'mysql|post|kiban|elas|mongo'|awk '{print $1}'|xargs -t docker rm 有些时候会有些<none>的镜像,如下List -3,可能是临时产生的,删除这种镜像,直接用List-1中的是不行的 List-3 mjduan@mjduan:/opt/tmp/images$ docker images REPOSITORY
所以,我们可以通过定义AuthenticationEntryPoint统一处理抛出的异常,如下List-3 List-3 @Component @AllArgsConstructor public class
2.2 验证Java数组对象的头部占用byte数 List-3 验证数组的情况 import org.openjdk.jol.info.ClassLayout; import org.openjdk.jol.vm.VM ClassLayout.parseInstance(new A[2]).toPrintable()); } public static class A { // no fields } } List 图2 List-3的运行结果 图2的说明:第一个红框和第二个红框分别是mark word和kclass pointer,它们分别占8bytes和4bytes,之后的4bytes用来表示数组长度 List-3源码中的,我们的数组new A[2]的长度是2,每个下标处占4bytes,这个类似C语言中的指针。 所以可以看到数组和普通的Java对象头部是有区别的。
List-3 EventHandlerGroup<T> createWorkerPool( final Sequence[] barrierSequences, final WorkHandler workerSequences); return new EventHandlerGroup<>(this, consumerRepository, workerSequences); } 如List
DynamicRegistrationBean实现,DynamicRegistrationBean再将ServletContext用方法addRegistration传递给子类ServletRegistrationBean——见List -3,List-3中用addServlet方法加入的就是DispatcherServletRegistrationBean传递到父类ServletRegistrationBean中的。 code ServletException} */ void onStartup(ServletContext servletContext) throws ServletException; } List
如下List-2所示,Disruptor中默认使用ExceptionHandler的ExceptionHandlerWrapper实现,如List-3所示,使用了代理,委托内部的delete来处理。 List-3 public class ExceptionHandlerWrapper<T> implements ExceptionHandler<T> { private ExceptionHandler
<property name="filterProcessesUrl" value="/logout/cas"/> </bean> 来看下LogoutFilter的doFilter方法,如下List -3所示, List-3 public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws logoutSuccessHandler.onLogoutSuccess(request, response, auth); return; } chain.doFilter(request, response); } 在List