English | 中文
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
.
- 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.
- summer-validator: A validation module that provides various validation rules for collections and objects.
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.
-
Rich Validation Rules: The validation module offers a wide range of validation rules, including length checks, regular expression matching, and collection size validations. For example, you can easily validate strings for minimum and maximum lengths, and collections for size ranges.
-
Annotation-Based Validation: Supports annotation-based validation. You can use custom annotations to mark fields in classes and perform validation operations on objects. For instance, use the @NotNull and @Pattern annotations to validate user-defined objects.
-
Collection Validation: Provides specific validation capabilities for collections. You can set validation rules for the entire collection as well as for each element in the collection.
-
Main and Sub-Task Management: Includes entities such as MainTask and SubTask, and corresponding data access objects (MainTaskDao). It can manage the status, progress, and related information of main and sub-tasks.
-
Task Monitoring and Recovery: The TaskWatchdog class periodically checks for stuck tasks and attempts to recover them, ensuring the reliability of task processing.
- Java 8 or higher
- Maven
- Clone the repository:
git clone https://github.com/dianpoint/summer.git
cd summer
- Build the project using Maven:
Make sure you have Java and Maven installed in your development environment.
### Installation
Clone the repository to your local machine:
```bash
git clone https://github.com/dianpoint/summer.git
Navigate to the project directory and build the project:
cd summer
mvn clean install
You can define beans in an XML file and use the XmlBeanDefinitionReader to load and register them. Here is an example:
// Create a bean factory
AbstractBeanFactory beanFactory = new DefaultListableBeanFactory();
// Create a resource for the XML file
Resource resource = new ClassPathResource("beans.xml");
// Create a reader to load bean definitions from the resource
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(beanFactory);
reader.loadBeanDefinitions(resource);
// Get a bean from the factory
Object bean = beanFactory.getBean("beanName");
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.
// Create a proxy factory bean
ProxyFactoryBean proxyFactoryBean = new ProxyFactoryBean();
proxyFactoryBean.setTarget(target);
proxyFactoryBean.setInterceptorName("interceptorBeanName");
proxyFactoryBean.setBeanFactory(beanFactory);
// Get the proxy object
Object proxy = proxyFactoryBean.getSingletonInstance();
The summer-validator module provides validation rules for collections and objects. You can use the ValidationRules and Validators classes to perform validation.
// Validate a collection
ValidationRule<Collection<?>> rule = ValidationRules.minsize(5);
ValidationResult result = rule.validate(collection);
if (result.isSuccess()) {
// Collection meets the validation rule
} else {
// Collection does not meet the validation rule
}
// Validate an object using annotations
User user = new User(null, "[email protected]");
List<ValidationResult> validationResults = Validators.annotated(User.class).validate(user);
The RequestMapping annotation can be used to map HTTP requests to specific methods in a controller.
import com.dianpoint.summer.web.RequestMapping;
public class MyController {
@RequestMapping("/hello")
public String hello() {
return "Hello, World!";
}
}
The Autowired annotation can be used to automatically inject dependencies into fields.
import com.dianpoint.summer.beans.factory.annotation.Autowired;
public class MyService {
@Autowired
private AnotherService anotherService;
// ...
}
summer/
├── summer-beans/
│ ├── src/
│ │ ├── main/
│ │ │ └── java/
│ │ │ └── com/dianpoint/summer/
│ │ │ ├── beans/
│ │ │ ├── context/
│ │ │ ├── web/
│ │ │ └── ...
│ │ └── test/
│ │ └── java/
│ │ └── com/dianpoint/summer/test/
│ │ ├── xml/
│ │ └── ...
│ └── pom.xml
├── summer-validator/
│ ├── src/
│ │ ├── main/
│ │ │ └── java/
│ │ │ └── com/dianpoint/summer/validator/
│ │ │ ├── annotations/
│ │ │ ├── constraintvalidators/
│ │ │ └── ...
│ │ └── test/
│ │ └── java/
│ │ └── com/dianpoint/summer/validator/test/
│ │ └── ...
│ └── pom.xml
├── docs/
│ └── readme.md
├── .github/
│ └── workflows/
│ └── maven-test.yml
├── .gitignore
├── pom.xml
├── README.md
└── README_cn.md
- Implement basic bean definition and injection
- Add AOP support
- Improve validation module with more rules
- Add support for annotation-based configuration
- Implement @Autowired and @Component annotations
- Provide annotation scanning functionality
See the issues for a full list of proposed features and known issues.
Contributions are what make the open-source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
- Fork the Project
- Create your Feature Branch (git checkout -b feature/AmazingFeature)
- Commit your Changes (git commit -m 'Add some AmazingFeature')
- Push to the Branch (git push origin feature/AmazingFeature)
- Open a Pull Request
Summer is distributed under the Apache License 2.0 License. See License.txt for more information.
- Email: [email protected]
- Github: https://github.com/ccoderJava
- xxx
- xxx
- xxx
- xxx
- xxx
- xxx
See the issues for a full list of proposed features and known issues.
Summer
distributed under the Apache License 2.0
License.
See License.txt
for more information.
- Email: [email protected]
- Github: https://github.com/ccoderJava