Skip to content

Commit 770bc90

Browse files
committed
Merge branch 'feature-validator'
# Conflicts: # .gitignore # README.md
2 parents 6416128 + 3bf939b commit 770bc90

File tree

2 files changed

+162
-38
lines changed

2 files changed

+162
-38
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,6 @@ target/
3838
### fleet
3939
.fleet
4040

41+
42+
4143
.flattened-pom.xml

README.md

Lines changed: 160 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,30 @@ English | [中文](README_cn.md)
3030
<!-- TOC -->
3131

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

4349
<!-- TOC -->
4450

4551
## About The Project
52+
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`.
53+
54+
### Modules
55+
- **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.
56+
- **summer-validator**: A validation module that provides various validation rules for collections and objects.
4657

4758
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.
4859

@@ -72,8 +83,24 @@ the status, progress, and related information of main and sub-tasks.
7283

7384
### Prerequisites
7485
Make sure you have Java and Maven installed in your development environment.
86+
- Java 8 or higher
87+
- Maven
7588

7689
### Installation
90+
1. Clone the repository:
91+
92+
```shell
93+
git clone https://github.com/dianpoint/summer.git
94+
cd summer
95+
```
96+
97+
2. Build the project using Maven:
98+
```shell
99+
mvn clean install
100+
```
101+
102+
103+
### Usage
77104

78105
Clone the repository to your local machine:
79106

@@ -91,53 +118,148 @@ mvn clean install
91118

92119

93120
## Usage
121+
#### Bean Definition and Injection
122+
You can define beans in an XML file and use the XmlBeanDefinitionReader to load and register them. Here is an example:
123+
```java
124+
// Create a bean factory
125+
AbstractBeanFactory beanFactory = new DefaultListableBeanFactory();
126+
// Create a resource for the XML file
127+
Resource resource = new ClassPathResource("beans.xml");
128+
// Create a reader to load bean definitions from the resource
129+
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(beanFactory);
130+
reader.loadBeanDefinitions(resource);
131+
// Get a bean from the factory
132+
Object bean = beanFactory.getBean("beanName");
133+
```
94134

95-
## Roadmap
96-
97-
- [x] xxx
98-
- [x] xxx
99-
- [ ] xxx
100-
- [ ] xxx
101-
- [ ] xxx
102-
- [ ] xxx
135+
#### AOP Usage
136+
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.
137+
138+
```java
139+
// Create a proxy factory bean
140+
ProxyFactoryBean proxyFactoryBean = new ProxyFactoryBean();
141+
proxyFactoryBean.setTarget(target);
142+
proxyFactoryBean.setInterceptorName("interceptorBeanName");
143+
proxyFactoryBean.setBeanFactory(beanFactory);
144+
// Get the proxy object
145+
Object proxy = proxyFactoryBean.getSingletonInstance();
146+
```
103147

104-
See the [issues](https://github/dianpoint/summer/issues) for a full list of proposed features and known issues.
148+
#### Validation
149+
The summer-validator module provides validation rules for collections and objects. You can use the ValidationRules and Validators classes to perform validation.
150+
151+
```java
152+
// Validate a collection
153+
ValidationRule<Collection<?>> rule = ValidationRules.minsize(5);
154+
ValidationResult result = rule.validate(collection);
155+
if (result.isSuccess()) {
156+
// Collection meets the validation rule
157+
} else {
158+
// Collection does not meet the validation rule
159+
}
160+
161+
// Validate an object using annotations
162+
User user = new User(null, "123@mail.com");
163+
List<ValidationResult> validationResults = Validators.annotated(User.class).validate(user);
164+
```
105165

106-
## Contributing
166+
#### RequestMapping Annotation
167+
The RequestMapping annotation can be used to map HTTP requests to specific methods in a controller.
168+
```java
169+
import com.dianpoint.summer.web.RequestMapping;
107170

108-
## License
171+
public class MyController {
109172

110-
`Summer` distributed under the [`Apache License 2.0`](https://github.com/dianpoint/summer/blob/main/LICENSE) License.
111-
See `License.txt` for more information.
173+
@RequestMapping("/hello")
174+
public String hello() {
175+
return "Hello, World!";
176+
}
177+
}
178+
```
112179

113-
## Contact
114180

115-
+ Email: [congccoder@gmail.com](mailto://congccoder@gmail.com)
116-
+ Github: [https://github.com/ccoderJava](https://github.com/ccoderJava)
181+
#### Autowired Annotation
182+
The Autowired annotation can be used to automatically inject dependencies into fields.
183+
```java
184+
import com.dianpoint.summer.beans.factory.annotation.Autowired;
117185

118-
[//]: # (Markdown Links & Images)
186+
public class MyService {
119187

120-
[contributors-shield]: https://img.shields.io/github/contributors/dianpoint/summer.svg?style=for-the-badge
188+
@Autowired
189+
private AnotherService anotherService;
121190

122-
[contributors-url]: https://github.com/dianpoint/summer/graphs/contributors
191+
// ...
192+
}
193+
```
123194

124-
[forks-shield]: https://img.shields.io/github/forks/dianpoint/summer.svg?style=for-the-badge
125195

126-
[forks-url]: https://github.com/dianpoint/summer/forks
196+
### Project Structure
197+
```java
198+
summer/
199+
├── summer-beans/
200+
│ ├── src/
201+
│ │ ├── main/
202+
│ │ │ └── java/
203+
│ │ │ └── com/dianpoint/summer/
204+
│ │ │ ├── beans/
205+
│ │ │ ├── context/
206+
│ │ │ ├── web/
207+
│ │ │ └── ...
208+
│ │ └── test/
209+
│ │ └── java/
210+
│ │ └── com/dianpoint/summer/test/
211+
│ │ ├── xml/
212+
│ │ └── ...
213+
│ └── pom.xml
214+
├── summer-validator/
215+
│ ├── src/
216+
│ │ ├── main/
217+
│ │ │ └── java/
218+
│ │ │ └── com/dianpoint/summer/validator/
219+
│ │ │ ├── annotations/
220+
│ │ │ ├── constraintvalidators/
221+
│ │ │ └── ...
222+
│ │ └── test/
223+
│ │ └── java/
224+
│ │ └── com/dianpoint/summer/validator/test/
225+
│ │ └── ...
226+
│ └── pom.xml
227+
├── docs/
228+
│ └── readme.md
229+
├── .github/
230+
│ └── workflows/
231+
│ └── maven-test.yml
232+
├── .gitignore
233+
├── pom.xml
234+
├── README.md
235+
└── README_cn.md
236+
```
127237

128-
[stars-shield]: https://img.shields.io/github/stars/dianpoint/summer.svg?style=for-the-badge
238+
### Roadmap
129239

130-
[stars-url]: https://github.com/dianpoint/summer/stargazers
240+
- [x] Implement basic bean definition and injection
241+
- [x] Add AOP support
242+
- [ ] Improve validation module with more rules
243+
- [ ] Add support for annotation-based configuration
244+
+ [ ] Implement @Autowired and @Component annotations
245+
+ [ ] Provide annotation scanning functionality
131246

132-
[issues-shield]: https://img.shields.io/github/issues/dianpoint/summer.svg?style=for-the-badge
247+
See the issues for a full list of proposed features and known issues.
133248

134-
[issues-url]: https://github.com/dianpoint/summer/issues
135249

136-
[license-shield]: https://img.shields.io/github/license/dianpoint/summer.svg?style=for-the-badge
250+
### Contributing
251+
Contributions are what make the open-source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
137252

138-
[license-url]: https://github.com/dianpoint/summer/blob/main/LICENSE
253+
1. Fork the Project
254+
2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
255+
3. Commit your Changes (git commit -m 'Add some AmazingFeature')
256+
4. Push to the Branch (git push origin feature/AmazingFeature)
257+
5. Open a Pull Request
139258

140-
[language-shield]: https://img.shields.io/github/languages/count/dianpoint/summer?style=for-the-badge
141259

142-
[language-url]: https://img.shields.io/github/languages/count/dianpoint/summer
260+
### License
261+
Summer is distributed under the Apache License 2.0 License. See License.txt for more information.
143262

263+
### Contact
264+
+ Email: congccoder@gmail.com
265+
+ Github: https://github.com/ccoderJava

0 commit comments

Comments
 (0)