Skip to content

Commit d703648

Browse files
committed
修改文档
1 parent d53a4c0 commit d703648

File tree

1 file changed

+183
-63
lines changed

1 file changed

+183
-63
lines changed

README.md

Lines changed: 183 additions & 63 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,78 +26,198 @@ 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.
4656

4757
## Getting Started
4858

4959
### Prerequisites
60+
- Java 8 or higher
61+
- Maven
5062

5163
### Installation
52-
53-
## Usage
54-
55-
## Roadmap
56-
57-
- [x] xxx
58-
- [x] xxx
59-
- [ ] xxx
60-
- [ ] xxx
61-
- [ ] xxx
62-
- [ ] xxx
63-
64-
See the [issues](https://github/dianpoint/summer/issues) for a full list of proposed features and known issues.
65-
66-
## Contributing
67-
68-
## License
69-
70-
`Summer` distributed under the [`Apache License 2.0`](https://github.com/dianpoint/summer/blob/main/LICENSE) License.
71-
See `License.txt` for more information.
72-
73-
## Contact
74-
75-
+ Email: [congccoder@gmail.com](mailto://congccoder@gmail.com)
76-
+ Github: [https://github.com/ccoderJava](https://github.com/ccoderJava)
77-
78-
[//]: # (Markdown Links & Images)
79-
80-
[contributors-shield]: https://img.shields.io/github/contributors/dianpoint/summer.svg?style=for-the-badge
81-
82-
[contributors-url]: https://github.com/dianpoint/summer/graphs/contributors
83-
84-
[forks-shield]: https://img.shields.io/github/forks/dianpoint/summer.svg?style=for-the-badge
85-
86-
[forks-url]: https://github.com/dianpoint/summer/forks
87-
88-
[stars-shield]: https://img.shields.io/github/stars/dianpoint/summer.svg?style=for-the-badge
89-
90-
[stars-url]: https://github.com/dianpoint/summer/stargazers
91-
92-
[issues-shield]: https://img.shields.io/github/issues/dianpoint/summer.svg?style=for-the-badge
93-
94-
[issues-url]: https://github.com/dianpoint/summer/issues
95-
96-
[license-shield]: https://img.shields.io/github/license/dianpoint/summer.svg?style=for-the-badge
97-
98-
[license-url]: https://github.com/dianpoint/summer/blob/main/LICENSE
99-
100-
[language-shield]: https://img.shields.io/github/languages/count/dianpoint/summer?style=for-the-badge
101-
102-
[language-url]: https://img.shields.io/github/languages/count/dianpoint/summer
103-
64+
1. Clone the repository:
65+
66+
```shell
67+
git clone https://github.com/dianpoint/summer.git
68+
cd summer
69+
```
70+
71+
2. Build the project using Maven:
72+
```shell
73+
mvn clean install
74+
```
75+
76+
77+
### Usage
78+
79+
#### Bean Definition and Injection
80+
You can define beans in an XML file and use the XmlBeanDefinitionReader to load and register them. Here is an example:
81+
```java
82+
// Create a bean factory
83+
AbstractBeanFactory beanFactory = new DefaultListableBeanFactory();
84+
// Create a resource for the XML file
85+
Resource resource = new ClassPathResource("beans.xml");
86+
// Create a reader to load bean definitions from the resource
87+
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(beanFactory);
88+
reader.loadBeanDefinitions(resource);
89+
// Get a bean from the factory
90+
Object bean = beanFactory.getBean("beanName");
91+
```
92+
93+
#### AOP Usage
94+
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.
95+
96+
```java
97+
// Create a proxy factory bean
98+
ProxyFactoryBean proxyFactoryBean = new ProxyFactoryBean();
99+
proxyFactoryBean.setTarget(target);
100+
proxyFactoryBean.setInterceptorName("interceptorBeanName");
101+
proxyFactoryBean.setBeanFactory(beanFactory);
102+
// Get the proxy object
103+
Object proxy = proxyFactoryBean.getSingletonInstance();
104+
```
105+
106+
#### Validation
107+
The summer-validator module provides validation rules for collections and objects. You can use the ValidationRules and Validators classes to perform validation.
108+
109+
```java
110+
// Validate a collection
111+
ValidationRule<Collection<?>> rule = ValidationRules.minsize(5);
112+
ValidationResult result = rule.validate(collection);
113+
if (result.isSuccess()) {
114+
// Collection meets the validation rule
115+
} else {
116+
// Collection does not meet the validation rule
117+
}
118+
119+
// Validate an object using annotations
120+
User user = new User(null, "123@mail.com");
121+
List<ValidationResult> validationResults = Validators.annotated(User.class).validate(user);
122+
```
123+
124+
#### RequestMapping Annotation
125+
The RequestMapping annotation can be used to map HTTP requests to specific methods in a controller.
126+
```java
127+
import com.dianpoint.summer.web.RequestMapping;
128+
129+
public class MyController {
130+
131+
@RequestMapping("/hello")
132+
public String hello() {
133+
return "Hello, World!";
134+
}
135+
}
136+
```
137+
138+
139+
#### Autowired Annotation
140+
The Autowired annotation can be used to automatically inject dependencies into fields.
141+
```java
142+
import com.dianpoint.summer.beans.factory.annotation.Autowired;
143+
144+
public class MyService {
145+
146+
@Autowired
147+
private AnotherService anotherService;
148+
149+
// ...
150+
}
151+
```
152+
153+
154+
### Project Structure
155+
```java
156+
summer/
157+
├── summer-beans/
158+
│ ├── src/
159+
│ │ ├── main/
160+
│ │ │ └── java/
161+
│ │ │ └── com/dianpoint/summer/
162+
│ │ │ ├── beans/
163+
│ │ │ ├── context/
164+
│ │ │ ├── web/
165+
│ │ │ └── ...
166+
│ │ └── test/
167+
│ │ └── java/
168+
│ │ └── com/dianpoint/summer/test/
169+
│ │ ├── xml/
170+
│ │ └── ...
171+
│ └── pom.xml
172+
├── summer-validator/
173+
│ ├── src/
174+
│ │ ├── main/
175+
│ │ │ └── java/
176+
│ │ │ └── com/dianpoint/summer/validator/
177+
│ │ │ ├── annotations/
178+
│ │ │ ├── constraintvalidators/
179+
│ │ │ └── ...
180+
│ │ └── test/
181+
│ │ └── java/
182+
│ │ └── com/dianpoint/summer/validator/test/
183+
│ │ └── ...
184+
│ └── pom.xml
185+
├── docs/
186+
│ └── readme.md
187+
├── .github/
188+
│ └── workflows/
189+
│ └── maven-test.yml
190+
├── .gitignore
191+
├── pom.xml
192+
├── README.md
193+
└── README_cn.md
194+
```
195+
196+
### Roadmap
197+
198+
Implement basic bean definition and injection
199+
Add AOP support
200+
Improve validation module with more rules
201+
Add support for annotation-based configuration
202+
Implement @Autowired and @Component annotations
203+
Provide annotation scanning functionality
204+
205+
See the issues for a full list of proposed features and known issues.
206+
207+
208+
### Contributing
209+
Contributions are what make the open-source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
210+
211+
Fork the Project
212+
Create your Feature Branch (git checkout -b feature/AmazingFeature)
213+
Commit your Changes (git commit -m 'Add some AmazingFeature')
214+
Push to the Branch (git push origin feature/AmazingFeature)
215+
Open a Pull Request
216+
217+
218+
### License
219+
Summer is distributed under the Apache License 2.0 License. See License.txt for more information.
220+
221+
### Contact
222+
Email: congccoder@gmail.com
223+
Github: https://github.com/ccoderJava

0 commit comments

Comments
 (0)