Skip to content

Commit 1790887

Browse files
committed
Merge branch 'main' of github.com:ccoderJava/summer
2 parents f1e497c + c0787cc commit 1790887

File tree

37 files changed

+500
-715
lines changed

37 files changed

+500
-715
lines changed

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,8 @@ target/
3636
!**/src/test/**/target/
3737

3838
### fleet
39-
.fleet
39+
.fleet
40+
41+
42+
.flattened-pom.xml
43+

README.md

Lines changed: 221 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ English | [中文](README_cn.md)
1313
<div align="center">
1414
<h3 align="center">Summer</h3>
1515
<p align="center">
16-
Minimized AOP,IoC kernel tools.
16+
Minimized AOP, IoC kernel tools.
1717
</p>
1818
<br>
1919
<a href="https://github.com/dianpoint/summer"><strong>Summer Docs >></strong> </a>
@@ -26,30 +26,240 @@ English | [中文](README_cn.md)
2626
<a href="https://github.com/dianpoint/summer/issues">Request Feature</a>
2727
</div>
2828

29-
3029
<!-- TOC -->
3130

3231
* [Summer](#summer)
33-
* [About The Project](#about-the-project)
34-
* [Getting Started](#getting-started)
35-
* [Prerequisites](#prerequisites)
36-
* [Installation](#installation)
37-
* [Usage](#usage)
38-
* [Roadmap](#roadmap)
39-
* [Contributing](#contributing)
40-
* [License](#license)
41-
* [Contact](#contact)
32+
* [About The Project](#about-the-project)
33+
* [Getting Started](#getting-started)
34+
* [Prerequisites](#prerequisites)
35+
* [Installation](#installation)
36+
* [Usage](#usage)
37+
* [Bean Definition and Injection](#bean-definition-and-injection)
38+
* [AOP Usage](#aop-usage)
39+
* [Validation](#validation)
40+
* [RequestMapping Annotation](#requestmapping-annotation)
41+
* [Autowired Annotation](#autowired-annotation)
42+
* [Project Structure](#project-structure)
43+
* [Roadmap](#roadmap)
44+
* [Contributing](#contributing)
45+
* [License](#license)
46+
* [Contact](#contact)
4247

4348
<!-- TOC -->
4449

4550
## About The Project
51+
Summer is a minimized AOP and IoC kernel toolset. It provides a lightweight and efficient solution for building Java applications, supporting XML-based bean definition and dependency injection, as well as AOP functionality. The project consists of two main modules: `summer-beans` and `summer-validator`.
52+
53+
### Modules
54+
- **summer-beans**: Core module for bean management, including bean definition, creation, and dependency injection. It also supports AOP features such as proxy creation and advice execution.
55+
- **summer-validator**: A validation module that provides various validation rules for collections and objects.
56+
57+
Summer is a minimized AOP (Aspect-Oriented Programming) and IoC (Inversion of Control) kernel tool library. It provides a set of validators and related utility classes to simplify the validation logic of objects and collections. Additionally, it includes some functions for batch task processing.
58+
59+
### Validation Module
60+
61+
+ **Rich Validation Rules**: The validation module offers a wide range of validation rules, including length checks, regular expression matching, and
62+
collection size validations. For example, you can easily validate strings for minimum and maximum lengths, and collections for size ranges.
63+
64+
+ **Annotation-Based Validation**: Supports annotation-based validation. You can use custom annotations to mark fields in classes and perform
65+
validation operations on objects. For instance, use the @NotNull and @Pattern annotations to validate user-defined objects.
66+
67+
+ **Collection Validation**: Provides specific validation capabilities for collections. You can set validation rules for the entire collection as
68+
well
69+
as for each element in the collection.
70+
71+
72+
### Batch Task Processing Module
73+
74+
+ **Main and Sub-Task Management**: Includes entities such as MainTask and SubTask, and corresponding data access objects (MainTaskDao). It can
75+
manage
76+
the status, progress, and related information of main and sub-tasks.
77+
78+
+ **Task Monitoring and Recovery**: The TaskWatchdog class periodically checks for stuck tasks and attempts to recover them, ensuring the reliability
79+
of task processing.
4680

4781
## Getting Started
4882

4983
### Prerequisites
84+
- Java 8 or higher
85+
- Maven
86+
87+
### Installation
88+
1. Clone the repository:
89+
90+
```shell
91+
git clone https://github.com/dianpoint/summer.git
92+
cd summer
93+
```
94+
95+
2. Build the project using Maven:
96+
```shell
97+
Make sure you have Java and Maven installed in your development environment.
5098

5199
### Installation
52100

101+
Clone the repository to your local machine:
102+
103+
```bash
104+
git clone https://github.com/dianpoint/summer.git
105+
106+
```
107+
108+
Navigate to the project directory and build the project:
109+
110+
```bash
111+
cd summer
112+
mvn clean install
113+
```
114+
115+
116+
### Usage
117+
118+
#### Bean Definition and Injection
119+
You can define beans in an XML file and use the XmlBeanDefinitionReader to load and register them. Here is an example:
120+
```java
121+
// Create a bean factory
122+
AbstractBeanFactory beanFactory = new DefaultListableBeanFactory();
123+
// Create a resource for the XML file
124+
Resource resource = new ClassPathResource("beans.xml");
125+
// Create a reader to load bean definitions from the resource
126+
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(beanFactory);
127+
reader.loadBeanDefinitions(resource);
128+
// Get a bean from the factory
129+
Object bean = beanFactory.getBean("beanName");
130+
```
131+
132+
#### AOP Usage
133+
Summer supports AOP through proxy creation and advice execution. You can use the ProxyFactoryBean to create a proxy for a target object and apply advice before or after method execution.
134+
135+
```java
136+
// Create a proxy factory bean
137+
ProxyFactoryBean proxyFactoryBean = new ProxyFactoryBean();
138+
proxyFactoryBean.setTarget(target);
139+
proxyFactoryBean.setInterceptorName("interceptorBeanName");
140+
proxyFactoryBean.setBeanFactory(beanFactory);
141+
// Get the proxy object
142+
Object proxy = proxyFactoryBean.getSingletonInstance();
143+
```
144+
145+
#### Validation
146+
The summer-validator module provides validation rules for collections and objects. You can use the ValidationRules and Validators classes to perform validation.
147+
148+
```java
149+
// Validate a collection
150+
ValidationRule<Collection<?>> rule = ValidationRules.minsize(5);
151+
ValidationResult result = rule.validate(collection);
152+
if (result.isSuccess()) {
153+
// Collection meets the validation rule
154+
} else {
155+
// Collection does not meet the validation rule
156+
}
157+
158+
// Validate an object using annotations
159+
User user = new User(null, "123@mail.com");
160+
List<ValidationResult> validationResults = Validators.annotated(User.class).validate(user);
161+
```
162+
163+
#### RequestMapping Annotation
164+
The RequestMapping annotation can be used to map HTTP requests to specific methods in a controller.
165+
```java
166+
import com.dianpoint.summer.web.RequestMapping;
167+
168+
public class MyController {
169+
170+
@RequestMapping("/hello")
171+
public String hello() {
172+
return "Hello, World!";
173+
}
174+
}
175+
```
176+
177+
178+
#### Autowired Annotation
179+
The Autowired annotation can be used to automatically inject dependencies into fields.
180+
```java
181+
import com.dianpoint.summer.beans.factory.annotation.Autowired;
182+
183+
public class MyService {
184+
185+
@Autowired
186+
private AnotherService anotherService;
187+
188+
// ...
189+
}
190+
```
191+
192+
193+
### Project Structure
194+
```java
195+
summer/
196+
├── summer-beans/
197+
│ ├── src/
198+
│ │ ├── main/
199+
│ │ │ └── java/
200+
│ │ │ └── com/dianpoint/summer/
201+
│ │ │ ├── beans/
202+
│ │ │ ├── context/
203+
│ │ │ ├── web/
204+
│ │ │ └── ...
205+
│ │ └── test/
206+
│ │ └── java/
207+
│ │ └── com/dianpoint/summer/test/
208+
│ │ ├── xml/
209+
│ │ └── ...
210+
│ └── pom.xml
211+
├── summer-validator/
212+
│ ├── src/
213+
│ │ ├── main/
214+
│ │ │ └── java/
215+
│ │ │ └── com/dianpoint/summer/validator/
216+
│ │ │ ├── annotations/
217+
│ │ │ ├── constraintvalidators/
218+
│ │ │ └── ...
219+
│ │ └── test/
220+
│ │ └── java/
221+
│ │ └── com/dianpoint/summer/validator/test/
222+
│ │ └── ...
223+
│ └── pom.xml
224+
├── docs/
225+
│ └── readme.md
226+
├── .github/
227+
│ └── workflows/
228+
│ └── maven-test.yml
229+
├── .gitignore
230+
├── pom.xml
231+
├── README.md
232+
└── README_cn.md
233+
```
234+
235+
### Roadmap
236+
237+
- [x] Implement basic bean definition and injection
238+
- [x] Add AOP support
239+
- [ ] Improve validation module with more rules
240+
- [ ] Add support for annotation-based configuration
241+
+ [ ] Implement @Autowired and @Component annotations
242+
+ [ ] Provide annotation scanning functionality
243+
244+
See the issues for a full list of proposed features and known issues.
245+
246+
247+
### Contributing
248+
Contributions are what make the open-source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
249+
250+
1. Fork the Project
251+
2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
252+
3. Commit your Changes (git commit -m 'Add some AmazingFeature')
253+
4. Push to the Branch (git push origin feature/AmazingFeature)
254+
5. Open a Pull Request
255+
256+
257+
### License
258+
Summer is distributed under the Apache License 2.0 License. See License.txt for more information.
259+
260+
### Contact
261+
+ Email: congccoder@gmail.com
262+
+ Github: https://github.com/ccoderJava
53263
## Usage
54264
55265
## Roadmap

README_cn.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,46 @@
4141
<!-- TOC -->
4242

4343
## 项目简介
44+
Summer 是一个最小化的 AOP(面向切面编程)和 IoC(控制反转)内核工具库。它提供了一系列的验证器和相关工具类,用于简化对象和集合的验证逻辑,同时也包含了一些批量任务处理的功能。
45+
46+
### 验证模块 | Validation Module
47+
48+
+ **丰富的验证规则**:验证模块提供了广泛的验证规则,包括长度检查、正则表达式匹配和集合大小验证。例如,您可以轻松验证字符串的最小和最大长度,以及集合的大小范围。
49+
50+
+ **基于注解的验证**:支持基于注解的验证。您可以使用自定义注解标记类中的字段,并对对象执行验证操作。例如,使用 @NotNull@Pattern 注解来验证用户定义的对象。
51+
52+
+ **集合验证**:为集合提供特定的验证功能。您可以为整个集合以及集合中的每个元素设置验证规则。
53+
54+
55+
### 批量任务处理模块 | Batch Task Processing Module
56+
57+
+ **主任务和子任务管理**:包括 MainTask 和 SubTask 等实体,以及相应的数据访问对象 (MainTaskDao)。它可以管理主任务和子任务的状态、进度和相关信息。
58+
59+
+ **任务监控和恢复**:TaskWatchdog 类会定期检查卡住的任务并尝试恢复它们,确保任务处理的可靠性。
4460

4561
## 入门指南
4662

4763
### 预备知识
4864

65+
确保您的开发环境中已经安装了 Java 和 Maven。
66+
4967
### 安装
5068

69+
克隆该仓库到本地:
70+
71+
```bash
72+
git clone https://github.com/dianpoint/summer.git
73+
74+
```
75+
76+
进入项目目录并构建项目:
77+
78+
```bash
79+
cd summer
80+
mvn clean install
81+
```
82+
83+
5184
## 用法
5285

5386
## 计划

docs/readme.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
![summer class uml](../docs/summer-uml.png)
2+
3+

0 commit comments

Comments
 (0)