├── .gitignore
├── README.md
├── pom.xml
├── src
├── main
│ ├── java
│ │ └── com
│ │ │ ├── brian
│ │ │ ├── MainTest.java
│ │ │ ├── aop
│ │ │ │ ├── LogAspects.java
│ │ │ │ └── MathCalculator.java
│ │ │ ├── async
│ │ │ │ ├── Callable01.java
│ │ │ │ ├── DeferredResult02.java
│ │ │ │ └── ResultQueue.java
│ │ │ ├── bean
│ │ │ │ ├── Alan.java
│ │ │ │ ├── Brian.java
│ │ │ │ ├── BrianBeanFactory.java
│ │ │ │ ├── Person.java
│ │ │ │ ├── Vincent.java
│ │ │ │ └── WenTao.java
│ │ │ ├── condition
│ │ │ │ ├── BrianCondition.java
│ │ │ │ └── BrianSelector.java
│ │ │ ├── config
│ │ │ │ ├── BrianTypeFilter.java
│ │ │ │ ├── MainConfig.java
│ │ │ │ ├── MainConfigOfAOP.java
│ │ │ │ ├── MainConfigOfAutowired.java
│ │ │ │ ├── MainConfigOfLifeCycle.java
│ │ │ │ ├── MainConfigOfProfile.java
│ │ │ │ └── MainConfigOfPropertyValues.java
│ │ │ ├── controller
│ │ │ │ └── BookController.java
│ │ │ ├── ext
│ │ │ │ ├── BrianApplicationListener.java
│ │ │ │ ├── BrianBeanDefinitionRegistryPostProcessor.java
│ │ │ │ ├── BrianBeanFactoryPostProcessor.java
│ │ │ │ ├── BrianService.java
│ │ │ │ └── ExtConfig.java
│ │ │ ├── mvc
│ │ │ │ ├── BrianWebAppInitializer.java
│ │ │ │ ├── config
│ │ │ │ │ ├── AppConfig.java
│ │ │ │ │ └── WebConfig.java
│ │ │ │ ├── controller
│ │ │ │ │ └── TestController.java
│ │ │ │ └── service
│ │ │ │ │ └── TestService.java
│ │ │ ├── repository
│ │ │ │ └── BookRepository.java
│ │ │ ├── service
│ │ │ │ ├── BookService.java
│ │ │ │ └── impl
│ │ │ │ │ ├── BookServiceImpl.java
│ │ │ │ │ └── OtherBookServiceImpl.java
│ │ │ └── tx
│ │ │ │ ├── AccessRightService.java
│ │ │ │ ├── AccessRigntDao.java
│ │ │ │ └── TxConfig.java
│ │ │ └── write
│ │ │ ├── annotation
│ │ │ ├── BrianAnnotation.java
│ │ │ ├── TestGetAnnotation.java
│ │ │ └── transaction
│ │ │ │ ├── BrianTransaction.java
│ │ │ │ ├── TransactionUtils.java
│ │ │ │ ├── aop
│ │ │ │ └── BrianAopTransaction.java
│ │ │ │ ├── config
│ │ │ │ └── Config.java
│ │ │ │ ├── dao
│ │ │ │ └── TJsonDao.java
│ │ │ │ └── service
│ │ │ │ └── TJsonService.java
│ │ │ ├── bjdbc
│ │ │ ├── BrianDbPool.java
│ │ │ ├── BrianDbPoolImpl.java
│ │ │ └── DbBean.java
│ │ │ ├── blinklist
│ │ │ └── BrianLinkList.java
│ │ │ ├── blist
│ │ │ ├── BrianArrayList.java
│ │ │ └── BrianList.java
│ │ │ ├── bmap
│ │ │ ├── BrianHashMap.java
│ │ │ └── BrianMap.java
│ │ │ ├── bmvc
│ │ │ ├── annotation
│ │ │ │ ├── BrianController.java
│ │ │ │ └── BrianRequestMapping.java
│ │ │ ├── controller
│ │ │ │ └── TestController.java
│ │ │ └── servlet
│ │ │ │ └── BrianDispatcherServlet.java
│ │ │ ├── bmybatis
│ │ │ ├── domain
│ │ │ │ └── TJson.java
│ │ │ ├── mapper
│ │ │ │ └── TJsonMapper.java
│ │ │ ├── orm
│ │ │ │ ├── annotaton
│ │ │ │ │ ├── BrianInsert.java
│ │ │ │ │ ├── BrianParam.java
│ │ │ │ │ └── BrianSelect.java
│ │ │ │ └── aop
│ │ │ │ │ └── BrianInvocationHandler.java
│ │ │ ├── sql
│ │ │ │ └── SqlSession.java
│ │ │ └── utils
│ │ │ │ ├── JDBCUtils.java
│ │ │ │ └── SQLUtils.java
│ │ │ └── bservice
│ │ │ ├── BrianAnnotationConfigApplicationContext.java
│ │ │ └── annotation
│ │ │ ├── BrianResource.java
│ │ │ ├── BrianService.java
│ │ │ ├── service
│ │ │ ├── BaseService.java
│ │ │ └── OtherService.java
│ │ │ └── utils
│ │ │ └── ClassUtil.java
│ ├── resources
│ │ ├── SpringSources.txt
│ │ ├── app.properties
│ │ └── app.yml
│ └── webapp
│ │ └── WEB-INF
│ │ └── web.xml
└── test
│ └── java
│ ├── BASEIC_LIST_TEST.java
│ ├── BASEIC_MAP_TEST.java
│ ├── IOC_TEST_AOP.java
│ ├── IOC_TEST_Autowired.java
│ ├── IOC_TEST_EXT.java
│ ├── IOC_TEST_PropertyValues.java
│ ├── IOC_TEST_TX.java
│ ├── IOC_test_Profile.java
│ ├── JDBC_TEST_CONNECT.java
│ ├── MYBATIS_TEST_ORM.java
│ └── MianTest.java
└── target
├── classes
├── SpringSources.txt
├── app.properties
└── app.yml
└── maven-status
└── maven-compiler-plugin
└── compile
└── default-compile
├── createdFiles.lst
└── inputFiles.lst
/.gitignore:
--------------------------------------------------------------------------------
1 | # Compiled class file
2 | *.class
3 |
4 | # Log file
5 | *.log
6 |
7 | # BlueJ files
8 | *.ctxt
9 |
10 | # Mobile Tools for Java (J2ME)
11 | .mtj.tmp/
12 |
13 | # Package Files #
14 | *.jar
15 | *.war
16 | *.nar
17 | *.ear
18 | *.zip
19 | *.tar.gz
20 | *.rar
21 |
22 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
23 | hs_err_pid*
24 | /target/
25 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ### 天道酬请,一步一个坑
2 | ### spring-annotation
3 |
4 | #### 1.源码分析
5 | ##### 1.1 Spring 5.X 源码分析
6 | ###### 1.1.1 Spring5源码深度解析(一)之理解Configuration注解 https://www.cnblogs.com/hlkawa/p/11085020.html
7 | ###### 1.1.2 Spring5源码深度分析(二)之理解@Conditional,@Import注解 https://www.cnblogs.com/hlkawa/p/11088129.html
8 | ###### 1.1.3 Spring5深度源码分析(三)之AnnotationConfigApplicationContext启动原理分析 https://www.cnblogs.com/hlkawa/p/11100604.html
9 |
10 | #### 2. 手写框架
11 | ##### 2.1手写 Spring事务框架
12 | ##### 2.2 手写@Service和@Resource注解
13 | ##### 2.3 手写SpringMVC框架(手写SpringMVC控制框,手写@Controller注解,手写@RequestMapping注解)
14 | ##### 2.4手写数据库连接池
15 | ##### 2.5 手写orm框架--mybatis
16 | ##### 2.6 手写ArrayList集合
17 | ##### 2.7 手写LinkList集合
18 | ##### 2.8 手写HashMap结合(数组+单向链表实现)
19 |
20 | #### 3. 项目重构或项目设计时常用的设计模式 https://gitee.com/showkawa_admin/architect/tree/master/designPattern
21 | ##### 3.1 策略模式 strategy
22 | ##### 3.2 责任链模式 responsibilitychain
23 | ##### 3.3 模板方法模式 template
24 | ##### 3.4 装饰器模式 decorative
25 | ##### 3.5 代理模式 proxy
26 | ##### 3.6 观察者模式 observer
27 | ##### 3.7 单例模式 singleton
28 | ##### 3.8 适配器模式 adapter
29 |
30 | #### 4.微服务SpringCloud2.X https://gitee.com/showkawa_admin/architect/tree/master/microservice
31 | ##### 4.1 服务治理 eureka
32 | ##### 4.2 DiscoveryClient实现负载均衡,轮询模式
33 | ##### 4.3 feign客户端调用,给人感觉就像调用本地服务一样
34 | ##### 4.4 config分布式配置中心
35 | ##### 4.5 apollo分布式配置中心
36 | ##### 4.6 zuul动态网关和统一API管理
37 | ##### 4.7 config分布式配置中心 + bus消息总线实现全局微服务的通知
38 | ##### 4.8 zipkin链路追踪 主要是微服务复杂调用的时候方便第一时间快速定位问题
39 |
40 | #### 5.互联网高并发场景 https://gitee.com/showkawa_admin/architect/tree/master/concurrent
41 | ##### 5.1 服务保护断路器 hystrix
42 | ##### 5.2 服务限流 ratelimit
43 | ##### 5.3 rabbitMQ 消息幂等性设计和分布式事务处理 rabbitmq
44 | ##### 5.4 lcn 分布式事务
45 | ##### 5.5 sharding-jdbc 分库分表
46 |
47 | #### 6.互联网安全架构 https://gitee.com/showkawa_admin/architect/tree/master/security
48 | ##### 6.1 预防xss跨站脚本攻击 xss
49 | ##### 6.2 防盗链技术 doorchain
50 | ##### 6.3 接口幂等性设计 idempotent
51 | ##### 6.3 springboot security细粒度基于页面的权限控制
52 |
53 | #### 7 lambda 表达式
54 | ##### 7.1 lambda https://gitee.com/showkawa_admin/netty-annotation/tree/master/src/main/java/com/brian/java8/lambda
55 |
--------------------------------------------------------------------------------
/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 | brian.annotation
8 | com.annotation
9 | 1.0.1
10 |
11 |
12 | 17
13 | 17
14 | 17
15 |
16 |
17 |
18 |
19 |
20 | org.springframework
21 | spring-context
22 | 5.3.18
23 |
24 |
25 | org.springframework
26 | spring-aspects
27 | 5.3.18
28 |
29 |
30 | org.springframework
31 | spring-jdbc
32 | 5.3.18
33 |
34 |
35 |
36 |
37 | javax.servlet
38 | javax.servlet-api
39 | 4.0.1
40 | provided
41 |
42 |
43 | org.springframework
44 | spring-webmvc
45 | 5.3.18
46 |
47 |
48 |
49 |
50 | junit
51 | junit
52 | 4.13.1
53 | test
54 |
55 |
56 |
57 |
58 | c3p0
59 | c3p0
60 | 0.9.1.2
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 | org.apache.maven.plugins
78 | maven-compiler-plugin
79 |
80 | 17
81 | 17
82 |
83 |
84 |
85 |
86 |
87 |
--------------------------------------------------------------------------------
/src/main/java/com/brian/MainTest.java:
--------------------------------------------------------------------------------
1 | package com.brian;
2 |
3 | import com.brian.config.MainConfig;
4 | import com.brian.controller.BookController;
5 | import org.springframework.context.ApplicationContext;
6 | import org.springframework.context.annotation.AnnotationConfigApplicationContext;
7 |
8 | import java.lang.reflect.InvocationTargetException;
9 | import java.lang.reflect.Method;
10 |
11 | public class MainTest {
12 | public static void main(String[] args) {
13 | ApplicationContext mainConfig =
14 | new AnnotationConfigApplicationContext(MainConfig.class);
15 |
16 | System.out.println("MainConfig容器创建成功");
17 |
18 | BookController bookController = mainConfig.getBean(BookController.class);
19 | try {
20 | Method printBook = bookController.getClass().getDeclaredMethod("printBook");
21 | printBook.setAccessible(true);
22 | printBook.invoke(bookController);
23 | } catch (NoSuchMethodException e) {
24 | e.printStackTrace();
25 | } catch (IllegalAccessException e) {
26 | e.printStackTrace();
27 | } catch (InvocationTargetException e) {
28 | e.printStackTrace();
29 | }
30 | // Alan alan1 = acac.getBean(Alan.class);
31 | // System.out.println("--ALAN--:" + alan1);
32 | // Alan alan2 = acac.getBean(Alan.class);
33 | //System.out.println("比较两个Alan实例: " + (alan1 == alan2));
34 |
35 | // Person person1 = (Person) acac.getBean("person01");
36 | // System.out.println("---main---test---person1---: " + person1.toString());
37 | // Person person2 = (Person) acac.getBean("person02");
38 | // System.out.println("---main---test---person2---: " + person2.toString());
39 |
40 |
41 | // MathCalculator mathCalculator = (MathCalculator) acac.getBean("mathCalculator");
42 | // System.out.println("----get--mathCalculator---: " + mathCalculator);
43 |
44 | // BrianBeanFactory beanFactory = acac.getBean(BrianBeanFactory.class);
45 | // WenTao wentao = null;
46 | // try {
47 | // wentao = beanFactory.getObject();
48 | // } catch (Exception e) {
49 | // e.printStackTrace();
50 | // }
51 | // System.out.println("----get--WenTao---: " + wentao);
52 |
53 |
54 | //关闭ioc容器
55 | ((AnnotationConfigApplicationContext) mainConfig).close();
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/src/main/java/com/brian/aop/LogAspects.java:
--------------------------------------------------------------------------------
1 | package com.brian.aop;
2 |
3 |
4 | import org.aspectj.lang.JoinPoint;
5 | import org.aspectj.lang.annotation.*;
6 |
7 | import java.lang.reflect.Array;
8 | import java.util.Arrays;
9 |
10 | @Aspect
11 | public class LogAspects {
12 |
13 | @Pointcut("execution(public int com.brian.aop.MathCalculator.*(..))")
14 | public void pointCut() { }
15 |
16 | @Before("com.brian.aop.LogAspects.pointCut()")
17 | public void logStart(JoinPoint joinPoint) {
18 | String methodName = joinPoint.getSignature().getName();
19 | Object[] per = joinPoint.getArgs();
20 | System.out.println( methodName+"()...@Before... 入参:{"+ Arrays.asList(per) +"}");
21 | }
22 | @After("com.brian.aop.LogAspects.pointCut()")
23 | public void logEnd(JoinPoint joinPoint) {
24 | String methodName = joinPoint.getSignature().getName();
25 | System.out.println(methodName+"()... @After...");
26 | }
27 | @AfterReturning(value = "com.brian.aop.LogAspects.pointCut()",returning = "re")
28 | public void logReturn(Object re) {
29 | System.out.println("@AfterReturning... 返回值:{"+ re +"}");
30 | }
31 | @AfterThrowing(value = "com.brian.aop.LogAspects.pointCut()",throwing = "ex")
32 | public void logThrowing(Exception ex) {
33 | System.out.println("@AfterThrowing... 异常信息:{"+ ex+"}");
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/src/main/java/com/brian/aop/MathCalculator.java:
--------------------------------------------------------------------------------
1 | package com.brian.aop;
2 |
3 | public class MathCalculator {
4 |
5 | public int div( int i,int j) {
6 | System.out.println("MathCalculator.div() method excute...");
7 | return i/j;
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/src/main/java/com/brian/async/Callable01.java:
--------------------------------------------------------------------------------
1 | package com.brian.async;
2 |
3 |
4 | import org.springframework.stereotype.Controller;
5 | import org.springframework.web.bind.annotation.RequestMapping;
6 | import org.springframework.web.bind.annotation.ResponseBody;
7 |
8 | import java.util.concurrent.Callable;
9 |
10 | /**
11 | * SpringMVC异步调用 Callable =>执行过程
12 | * 1.控制器返回Callable
13 | * 2.Spring异步调用,将Callable提交到TaskExecutor使用一个隔离的线程进行执行
14 | * 3.DispatcherServlet和所有的Filter退出web容器的线程,而response保持打开的状态
15 | * 4.Callable返回结果,SpringMVC将请求重新派发给容器,并且恢复之前的处理。
16 | * 5.根据Callable返回的结果。SpringMVC继续进行试图渲染流程等等等等。
17 | */
18 | @Controller
19 | public class Callable01 {
20 |
21 | @ResponseBody
22 | @RequestMapping("/async01")
23 | public Callable async01() {
24 |
25 | System.out.println("主线程start...." + Thread.currentThread()+"-"+System.currentTimeMillis());
26 | Callable callable = new Callable() {
27 |
28 | public String call() throws Exception {
29 | System.out.println("callable线程start...." + Thread.currentThread() + "-" + System.currentTimeMillis());
30 | Thread.sleep(3000);
31 | System.out.println("callable线程end...." + Thread.currentThread() + "-" + System.currentTimeMillis());
32 | return "ok";
33 | }
34 | };
35 | System.out.println("主线程end...." + Thread.currentThread()+"-"+System.currentTimeMillis());
36 | return callable;
37 | }
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/src/main/java/com/brian/async/DeferredResult02.java:
--------------------------------------------------------------------------------
1 | package com.brian.async;
2 |
3 | import org.springframework.stereotype.Controller;
4 | import org.springframework.web.bind.annotation.RequestMapping;
5 | import org.springframework.web.context.request.async.DeferredResult;
6 |
7 | import java.util.UUID;
8 |
9 | /**
10 | * DeferredResult异步调用
11 | *
12 | */
13 | @Controller
14 | public class DeferredResult02 {
15 |
16 | @RequestMapping("/create")
17 | public DeferredResult