Skip to content

Commit 010be5a

Browse files
committed
init spring
1 parent 1de66d0 commit 010be5a

File tree

11 files changed

+144
-9
lines changed

11 files changed

+144
-9
lines changed

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Spring Boot Data Bean 并发聚合支持
2+
3+
## 背景
4+
5+
## 原理
6+
7+
## 作者

pom.xml

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,23 +33,40 @@
3333

3434
<dependencyManagement>
3535
<dependencies>
36-
<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
3736
<dependency>
3837
<groupId>org.projectlombok</groupId>
3938
<artifactId>lombok</artifactId>
4039
<version>1.18.8</version>
41-
<scope>provided</scope>
40+
</dependency>
41+
42+
<dependency>
43+
<groupId>junit</groupId>
44+
<artifactId>junit</artifactId>
45+
<version>4.12</version>
46+
</dependency>
47+
48+
<dependency>
49+
<groupId>org.feego.spring</groupId>
50+
<artifactId>spring-boot-bean-aggregate-autoconfigure</artifactId>
51+
<version>${project.version}</version>
52+
</dependency>
53+
54+
<dependency>
55+
<groupId>org.feego.spring</groupId>
56+
<artifactId>spring-boot-bean-aggregate-core</artifactId>
57+
<version>${project.version}</version>
58+
</dependency>
59+
60+
<dependency>
61+
<groupId>org.feego.spring</groupId>
62+
<artifactId>spring-boot-bean-aggregate-example</artifactId>
63+
<version>${project.version}</version>
4264
</dependency>
4365
</dependencies>
4466
</dependencyManagement>
4567

4668
<dependencies>
47-
<dependency>
48-
<groupId>junit</groupId>
49-
<artifactId>junit</artifactId>
50-
<version>4.12</version>
51-
<scope>test</scope>
52-
</dependency>
69+
5370
</dependencies>
5471

5572
<build>

spring-boot-bean-aggregate-autoconfigure/pom.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,16 @@
3131
<groupId>org.projectlombok</groupId>
3232
<artifactId>lombok</artifactId>
3333
</dependency>
34+
<!-- https://mvnrepository.com/artifact/org.reflections/reflections -->
35+
<dependency>
36+
<groupId>org.reflections</groupId>
37+
<artifactId>reflections</artifactId>
38+
<version>0.9.11</version>
39+
</dependency>
40+
<dependency>
41+
<groupId>org.feego.spring</groupId>
42+
<artifactId>spring-boot-bean-aggregate-core</artifactId>
43+
</dependency>
3444
</dependencies>
3545

3646
<build>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package org.feego.spring.annotation;
2+
3+
import java.lang.annotation.*;
4+
5+
/**
6+
7+
* @since 2019/6/1 0:05
8+
*/
9+
@Target({ElementType.METHOD})
10+
@Retention(RetentionPolicy.RUNTIME)
11+
@Documented
12+
public @interface DataBeanConsumer {
13+
14+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package org.feego.spring.annotation;
2+
3+
import java.lang.annotation.*;
4+
5+
/**
6+
7+
* @since 2019/6/1 0:05
8+
*/
9+
@Target({ElementType.METHOD})
10+
@Retention(RetentionPolicy.RUNTIME)
11+
@Documented
12+
public @interface DataBeanProvider {
13+
14+
}

spring-boot-bean-aggregate-autoconfigure/src/main/java/org/feego/spring/autoconfigure/BeanAggregateAutoConfiguration.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
package org.feego.spring.autoconfigure;
22

3+
import org.feego.spring.aggregate.facade.DataBeanAggregateQueryFacade;
4+
import org.feego.spring.aggregate.facade.impl.DataBeanAggregateQueryFacadeImpl;
35
import org.springframework.beans.BeansException;
6+
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
47
import org.springframework.boot.context.properties.EnableConfigurationProperties;
58
import org.springframework.context.ApplicationContext;
69
import org.springframework.context.ApplicationContextAware;
10+
import org.springframework.context.annotation.Bean;
711
import org.springframework.context.annotation.Configuration;
812

913
/**
@@ -20,4 +24,10 @@ public class BeanAggregateAutoConfiguration implements ApplicationContextAware {
2024
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
2125
this.applicationContext = applicationContext;
2226
}
27+
28+
@Bean
29+
@ConditionalOnMissingBean
30+
public DataBeanAggregateQueryFacade dataBeanAggregateQueryFacade() {
31+
return new DataBeanAggregateQueryFacadeImpl();
32+
}
2333
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package org.feego.spring.aggregate.facade;
2+
3+
/**
4+
5+
* @since 2019/6/1 0:22
6+
*/
7+
public interface DataBeanAggregateQueryFacade {
8+
<T> T get(String id, Class<T> clazz);
9+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package org.feego.spring.aggregate.facade.impl;
2+
3+
import org.feego.spring.aggregate.facade.DataBeanAggregateQueryFacade;
4+
5+
/**
6+
7+
* @since 2019/6/1 0:22
8+
*/
9+
public class DataBeanAggregateQueryFacadeImpl implements DataBeanAggregateQueryFacade {
10+
11+
@Override
12+
public <T> T get(String id, Class<T> clazz) {
13+
return null;
14+
}
15+
}

spring-boot-bean-aggregate-example/pom.xml

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,24 @@
1818
</properties>
1919

2020
<dependencies>
21-
21+
<dependency>
22+
<groupId>junit</groupId>
23+
<artifactId>junit</artifactId>
24+
<scope>test</scope>
25+
</dependency>
26+
<dependency>
27+
<groupId>org.springframework.boot</groupId>
28+
<artifactId>spring-boot-starter</artifactId>
29+
</dependency>
30+
<dependency>
31+
<groupId>org.springframework.boot</groupId>
32+
<artifactId>spring-boot-starter-test</artifactId>
33+
<scope>test</scope>
34+
</dependency>
35+
<dependency>
36+
<groupId>org.feego.spring</groupId>
37+
<artifactId>spring-boot-bean-aggregate-autoconfigure</artifactId>
38+
</dependency>
2239
</dependencies>
2340

2441
<build>
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package org.feego.spring.example;
2+
3+
import org.feego.spring.aggregate.facade.DataBeanAggregateQueryFacade;
4+
import org.springframework.boot.SpringApplication;
5+
import org.springframework.boot.autoconfigure.SpringBootApplication;
6+
import org.springframework.context.ConfigurableApplicationContext;
7+
8+
/**
9+
10+
* @since 2019/6/1 0:13
11+
*/
12+
13+
@SpringBootApplication
14+
public class ExampleApplication {
15+
public static void main(String[] args) {
16+
ConfigurableApplicationContext context = SpringApplication.run(ExampleApplication.class);
17+
DataBeanAggregateQueryFacade queryFacade = context.getBean(DataBeanAggregateQueryFacade.class);
18+
String loginUserName = queryFacade.get("login.user", String.class);
19+
System.out.println(loginUserName);
20+
}
21+
}

0 commit comments

Comments
 (0)