11 2013 档案
摘要:ReentrantLock 非公平锁lock: 如果stage==0 或 线程为当前线程 则 设置state=state+1 ,设置当前线程为独占线程 如果state不为0,且独占线程不是当前线程则: 如果tail为null,设置tail和head为new Node() addWaiter(Node.EXCLUSIVE) 新加一个独占Node,把该Node添加到链表的尾部 acquireQueued(Node)在for(;;)中执行 如果node节点的上一个节点为head且tryAcquire为true,则设置node为head(获得了锁,同时删除了上一个节点) 如果不是,则设置...
阅读全文
摘要:先看代码package com.benx.data;import javax.annotation.Resource;import org.springframework.stereotype.Service;import org.springframework.transaction.annotation.Isolation;import org.springframework.transaction.annotation.Propagation;import org.springframework.transaction.annotation.Transactional;@Service(
阅读全文
摘要:例子Spring 配置文件 接口类package com.benx.aspectj.service;public interface IHello { public String say();}接口实现类package com.benx.aspectj.service;public class HelloImpl implements IHello { public St...
阅读全文
摘要:例子IHello 接口类package com.benx.mvc;public interface IHello { public void say(); }IHello接口实现类package com.benx.mvc;public class HelloImpl implements IHello { public void say() { System.out.println("Hello World"); } }拦截器package com.benx.mvc;import org.aopalliance.intercept.MethodInt...
阅读全文
摘要:例子public interface IHello { public void say(); }public class HelloImpl implements IHello { public void say() { System.out.println("Hello World"); }}public class HelloInterceptor implements MethodInterceptor { public Object invoke(MethodInvocation methodinvocation) throws Throwa...
阅读全文
摘要:先看例子 myAdvisor debugInterceptor 配置点:1、interceptorNames 拦截器数组2、targetName 目标类3、singleton 是否单例,默认true4、proxyInterfaces 代理接口5、optimize 建议使用cglib6、proxyTargetClass问题:1、如何判断是使用jdk代理还是使用CGLIB? 答:默认使用jdk,如果没有使用接口或optimize 为true或proxyTargetCl...
阅读全文
摘要:初始化流程:1、创建WebApplicationContext context,设置context的setServletContext、setServletConfig、setId、setNamespace2、执行context.refresh(),加载spring文件,参见文章 spring 加载流程3、把context加入request Attribute 中key 为 FrameworkServlet.class.getName() + ".CONTEXT." ServletName4、spring加载问题后执行DispatcherServlet .onRefresh
阅读全文
摘要:AbstractApplicationContext.refresh()1、加载节点,获取节点的命名空间 如果命名空间为beans,默认处理import , alias , bean , beans 如果不是benas命名空间,则读取spring jar包中的META-INF/spring.hander,然后根据命名空间找到对应的解析器 加载beanDefinition2、prepareBeanFactory3、postProcessBeanFactory(beanFactory);4、invokeBeanFactoryPostProcessors(beanFactory); 执行容器中实现.
阅读全文
摘要:会注入如下classConfigurationClassPostProcessor1、遍历所有bean,如果class有注解Configuration或Component或class的方法有Bean2、利用ConfigurationClassParser 解析 class,把bean 加载到 容器中AutowiredAnnotationBeanPostProcessor1、把autowired注解的method或field注入到bean中RequiredAnnotationBeanPostProcessor1、检查如果 有Required注解,但是没有注入依赖,那么将抛错CommonAnnot
阅读全文
摘要:http内容转换器默认添加ByteArrayHttpMessageConverterStringHttpMessageConverterResourceHttpMessageConverterSourceHttpMessageConverterAllEncompassingFormHttpMessageConverter根据jar包添加MappingJacksonHttpMessageConverterMappingJackson2HttpMessageConverterJaxb2RootElementHttpMessageConverterRssChannelHttpMessageConve
阅读全文
摘要:常用接口ApplicationContextAware void setApplicationContext(ApplicationContext applicationContext)BeanNameAware void setBeanName(String name)InitializingBean void afterPropertiesSet()DisposableBean void destroy()BeanDefinitionRegistryPostProcessor void postProcessBeanDefinitionRegistry(BeanDefinitionRegi
阅读全文
摘要:会注入如下classSet beanDefinitions = ClassPathBeanDefinitionScanner.doScan(package);加载目录下面有Component、Controller.class、Repository.class、Service.class注解的class这个包含了功能
阅读全文
摘要:返回处理类ModelAndViewMethodReturnValueHandler 处理返回类型为ModelAndView,如果ModelAndView的view是String类型,则mavContainer.setViewName(viewName); 否则mavContainer.setView(ModelAndView.getView()); 最后mavContainer.addAllAttributes(mav.getModel());ModelMethodProcessor处理返回类型为Model,执行 mavContainer.addAllAttributes(((Model) .
阅读全文
摘要:参数解析类RequestParamMethodArgumentResolver处理类型: 1、包含注解RequestParam,但不处理参数类型为Map,且不包含value值 2、参数类型为MultipartFile,或javax.servlet.http.Part的类型处理方式: 1、如果参数类型为MultipartFile,返回MultipartFile 2、如果参数类型为List,返回List 3、如果参数类型为javax.servlet.http.Part,返回Part 4、否则返回request.getParameter("key") RequestParamMa
阅读全文
摘要:DispatcherServlet处理流程1、根据URL找到对应的hander2、执行HandlerExecutionChain.applyPreHandle(processedRequest, response),实际是执行HandlerInterceptor的preHandle方法,如果执行返回false,至请求完成3、执行HandlerAdapter.hander a、如果是注解方式,执行RequestMappingHandlerAdapter.handleInternal
阅读全文

浙公网安备 33010602011771号