Skip to content

Commit 66d0727

Browse files
committed
👏 add module maxwell spring
1 parent 666bf6c commit 66d0727

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+1125
-1
lines changed

pom.xml

+2-1
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,10 @@
2525
<module>spring-learning-demo</module>
2626
<module>spring-analyze</module>
2727
<module>spring-tiny</module>
28+
<module>spring-maxwell</module>
2829
</modules>
2930

30-
<!-- 全局属性配置-->
31+
<!-- 全局属�?配置-->
3132
<properties>
3233
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
3334
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

spring-maxwell/.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/target/
2+
/.settings/
3+
/.classpath
4+
/.project

spring-maxwell/pom.xml

+158
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
5+
<!-- 父级依赖 -->
6+
<parent>
7+
<artifactId>Spring-Core</artifactId>
8+
<groupId>cn.ucaner.spring</groupId>
9+
<version>0.0.1-SNAPSHOT</version>
10+
</parent>
11+
12+
<!-- maven 坐标 -->
13+
<artifactId>spring-maxwell</artifactId>
14+
<packaging>war</packaging>
15+
16+
<!-- 项目 名称 -->
17+
<name>spring-maxwell</name>
18+
<url>http://spring-maxwell.ucaner.cn</url>
19+
20+
21+
<!-- 项目配置 -->
22+
<properties>
23+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
24+
<spring-version>4.3.2.RELEASE</spring-version>
25+
<maven.compiler.source>1.8</maven.compiler.source>
26+
<maven.compiler.target>1.8</maven.compiler.target>
27+
</properties>
28+
29+
<dependencies>
30+
<dependency>
31+
<groupId>org.springframework</groupId>
32+
<artifactId>spring-core</artifactId>
33+
<version>${spring-version}</version>
34+
</dependency>
35+
<dependency>
36+
<groupId>org.springframework</groupId>
37+
<artifactId>spring-context</artifactId>
38+
<version>${spring-version}</version>
39+
</dependency>
40+
<dependency>
41+
<groupId>org.springframework</groupId>
42+
<artifactId>spring-web</artifactId>
43+
<version>${spring-version}</version>
44+
</dependency>
45+
<dependency>
46+
<groupId>org.springframework</groupId>
47+
<artifactId>spring-jdbc</artifactId>
48+
<version>${spring-version}</version>
49+
</dependency>
50+
<dependency>
51+
<groupId>org.springframework</groupId>
52+
<artifactId>spring-tx</artifactId>
53+
<version>${spring-version}</version>
54+
</dependency>
55+
<dependency>
56+
<groupId>org.springframework</groupId>
57+
<artifactId>spring-webmvc</artifactId>
58+
<version>${spring-version}</version>
59+
</dependency>
60+
61+
<dependency>
62+
<groupId>javax.servlet</groupId>
63+
<artifactId>javax.servlet-api</artifactId>
64+
<version>3.1.0</version>
65+
<scope>provided</scope>
66+
</dependency>
67+
<dependency>
68+
<groupId>javax.servlet</groupId>
69+
<artifactId>jstl</artifactId>
70+
<version>1.2</version>
71+
</dependency>
72+
73+
<dependency>
74+
<groupId>org.aspectj</groupId>
75+
<artifactId>aspectjweaver</artifactId>
76+
<version>1.8.9</version>
77+
</dependency>
78+
<dependency>
79+
<groupId>junit</groupId>
80+
<artifactId>junit</artifactId>
81+
<version>4.12</version>
82+
</dependency>
83+
<!-- Guava -->
84+
<dependency>
85+
<groupId>com.google.guava</groupId>
86+
<artifactId>guava</artifactId>
87+
<version>21.0</version>
88+
</dependency>
89+
<dependency>
90+
<groupId>com.google.code.findbugs</groupId>
91+
<artifactId>jsr305</artifactId>
92+
<version>3.0.1</version>
93+
</dependency>
94+
<dependency>
95+
<groupId>com.google.j2objc</groupId>
96+
<artifactId>j2objc-annotations</artifactId>
97+
<version>1.3</version>
98+
</dependency>
99+
100+
<dependency>
101+
<groupId>org.codehaus.jackson</groupId>
102+
<artifactId>jackson-mapper-asl</artifactId>
103+
<version>1.9.13</version>
104+
</dependency>
105+
<dependency>
106+
<groupId>com.fasterxml.jackson.core</groupId>
107+
<artifactId>jackson-databind</artifactId>
108+
<version>2.5.3</version>
109+
</dependency>
110+
111+
<dependency>
112+
<groupId>mysql</groupId>
113+
<artifactId>mysql-connector-java</artifactId>
114+
<version>5.1.20</version>
115+
</dependency>
116+
117+
<dependency>
118+
<groupId>cglib</groupId>
119+
<artifactId>cglib</artifactId>
120+
<version>3.2.5</version>
121+
</dependency>
122+
123+
<dependency>
124+
<groupId>org.hibernate.validator</groupId>
125+
<artifactId>hibernate-validator</artifactId>
126+
<version>6.0.2.Final</version>
127+
</dependency>
128+
129+
</dependencies>
130+
131+
<build>
132+
<plugins>
133+
<plugin>
134+
<groupId>org.apache.maven.plugins</groupId>
135+
<artifactId>maven-compiler-plugin</artifactId>
136+
<configuration>
137+
<debug>false</debug>
138+
<source>${maven.compiler.source}</source>
139+
<target>${maven.compiler.target}</target>
140+
</configuration>
141+
</plugin>
142+
<!-- maven tomcat插件用 -->
143+
<plugin>
144+
<groupId>org.apache.tomcat.maven</groupId>
145+
<artifactId>tomcat7-maven-plugin</artifactId>
146+
<version>2.2</version>
147+
<configuration>
148+
<port>8080</port>
149+
<path>/spring-maxwell</path>
150+
<uriEncoding>UTF-8</uriEncoding>
151+
<server>TomcatServer</server>
152+
<username>tiger</username>
153+
<password>tiger</password>
154+
</configuration>
155+
</plugin>
156+
</plugins>
157+
</build>
158+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package cn.ucaner.maxwell.annotation;
2+
3+
import java.lang.annotation.ElementType;
4+
import java.lang.annotation.Retention;
5+
import java.lang.annotation.RetentionPolicy;
6+
import java.lang.annotation.Target;
7+
8+
/**
9+
* 测试自定义初始化标签
10+
*/
11+
@Retention(RetentionPolicy.RUNTIME)
12+
@Target(ElementType.METHOD)
13+
public @interface Init {
14+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package cn.ucaner.maxwell.aop;
2+
3+
import org.springframework.context.support.ClassPathXmlApplicationContext;
4+
5+
/**
6+
* AOP测试启动类.
7+
*/
8+
public class Bootstrap {
9+
10+
public static void main(String[] args) {
11+
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("classpath:config.xml");
12+
SimpleAopBean bean = context.getBean(SimpleAopBean.class);
13+
bean.testB();
14+
System.out.println(bean.getClass().getSimpleName());
15+
System.out.println(context.getId());
16+
context.close();
17+
}
18+
19+
}
20+
//Outputs
21+
22+
//SimpleMethodInterceptor被调用: testB
23+
//testB执行
24+
//SimpleMethodInterceptor被调用: testC
25+
//testC执行
26+
//SimpleAopBean$$EnhancerBySpringCGLIB$$e066b201
27+
//org.springframework.context.support.ClassPathXmlApplicationContext@69d0a921
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package cn.ucaner.maxwell.aop;
2+
3+
import org.springframework.aop.framework.AopContext;
4+
5+
/**
6+
*/
7+
public class SimpleAopBean {
8+
9+
public void boo() {
10+
System.out.println("testA执行");
11+
testB();
12+
}
13+
14+
public void testB() {
15+
System.out.println("testB执行");
16+
((SimpleAopBean) AopContext.currentProxy()).testC();
17+
}
18+
19+
public void testC() {
20+
System.out.println("testC执行");
21+
}
22+
23+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package cn.ucaner.maxwell.aop;
2+
3+
/**
4+
*/
5+
public class SimpleChildAopBean extends SimpleAopBean {
6+
7+
@Override
8+
public void testC() {
9+
System.out.println("child testC");
10+
}
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package cn.ucaner.maxwell.aop;
2+
3+
import org.aopalliance.intercept.MethodInterceptor;
4+
import org.aopalliance.intercept.MethodInvocation;
5+
6+
/**
7+
* simpleMethodInterceptor
8+
*/
9+
public class SimpleMethodInterceptor implements MethodInterceptor {
10+
11+
@Override
12+
public Object invoke(MethodInvocation invocation) throws Throwable {
13+
System.out.println("SimpleMethodInterceptor被调用: " + invocation.getMethod().getName());
14+
return invocation.proceed();
15+
}
16+
17+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package cn.ucaner.maxwell.base;
2+
3+
/**
4+
*/
5+
public abstract class BaseStudent {
6+
7+
private String id;
8+
9+
public String getId() {
10+
return id;
11+
}
12+
13+
public void setId(String id) {
14+
this.id = id;
15+
}
16+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package cn.ucaner.maxwell.base;
2+
3+
import org.springframework.context.support.ClassPathXmlApplicationContext;
4+
5+
import cn.ucaner.maxwell.base.transaction.TransactionBean;
6+
7+
public class Boostrap {
8+
9+
public static void main(String[] args) {
10+
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("config.xml");
11+
TransactionBean bean = context.getBean(TransactionBean.class);
12+
bean.process();
13+
14+
context.close();
15+
}
16+
17+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package cn.ucaner.maxwell.base;
2+
3+
import cn.ucaner.maxwell.annotation.Init;
4+
5+
/**
6+
* SimpleBean
7+
*
8+
*/
9+
public class SimpleBean {
10+
11+
private Student student;
12+
13+
public SimpleBean() {}
14+
15+
public SimpleBean(Student student) {
16+
this.student = student;
17+
}
18+
19+
public Student getStudent() {
20+
return student;
21+
}
22+
23+
public void setStudent(Student student) {
24+
this.student = student;
25+
}
26+
27+
public void send() {
28+
System.out.println("I am send method from SimpleBean!");
29+
}
30+
31+
@Init
32+
public void init() {
33+
System.out.println("Init!");
34+
}
35+
36+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package cn.ucaner.maxwell.base;
2+
3+
import org.springframework.beans.BeansException;
4+
import org.springframework.beans.factory.annotation.Configurable;
5+
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
6+
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
7+
8+
@Configurable
9+
public class SimpleBeanFactoryPostProcessor implements BeanFactoryPostProcessor {
10+
11+
@Override
12+
public void postProcessBeanFactory(
13+
ConfigurableListableBeanFactory beanFactory) throws BeansException {
14+
SimpleBean bean = beanFactory.getBean(SimpleBean.class);
15+
bean.getStudent().setName("^_^");
16+
}
17+
18+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package cn.ucaner.maxwell.base;
2+
3+
import org.springframework.beans.BeansException;
4+
import org.springframework.beans.factory.config.BeanPostProcessor;
5+
6+
/**
7+
*/
8+
public class SimpleBeanPostProcessor implements BeanPostProcessor {
9+
@Override
10+
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
11+
return null;
12+
}
13+
14+
@Override
15+
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
16+
return null;
17+
}
18+
}

0 commit comments

Comments
 (0)