Aspectran 9.0 is a significant major update aimed at modernizing the framework, enhancing developer convenience, and strengthening core performance. Starting with Java 21 support, powerful new features aligned with the latest development trends have been introduced, and the internal architecture has been innovated to elevate stability and scalability.
Additionally, starting with this release, official user guide documentation is provided to help users utilize Aspectran more easily and deeply.
✨ Highlights
- Java 21 Support: By designating Java 21, the latest LTS version, as the minimum supported version, the foundation has been strengthened to fully leverage the benefits of the latest Java ecosystem.
- Official User Guide Documentation Provided: Now, systematic official documentation is provided for everyone, from developers just starting with Aspectran to users who want to utilize advanced features.
- Core Feature Modernization: Essential features for modern application development, such as optional dependency injection using
Optional<T>
, event-driven architecture via@EventListener
, and easy asynchronous processing using@Async
, have been newly added. - XML Parsing Engine Innovation: The internal XML parsing engine (
Nodelet
) has been extensively refactored to process complex configurations quickly and efficiently, significantly improving memory usage.
💥 Breaking Changes
- Java 21 Required: To use Aspectran 9.0, a Java 21 or higher environment is mandatory. It will not run on previous Java versions.
- Guidance for Users Below Java 21: For environments below Java 21 (Java 17 or higher), please use the stable version Aspectran 8.5.3.
🚀 Detailed Improvements
New Features
- Optional Dependency Injection (
Optional<T>
)- You can use
java.util.Optional<T>
when you need to inject a bean that may not exist, such as one that is only active in a specific profile. This allows for safer and more flexible dependency management withoutNullPointerException
s. - Example:
@Component public class MainService { private final Optional<OptionalService> optionalService; @Autowired public MainService(Optional<OptionalService> optionalService) { this.optionalService = optionalService; } public void doSomething() { optionalService.ifPresent(service -> service.performAction()); } }
- You can use
- Event Handling (
@EventListener
)- An event publish/subscribe model has been introduced to reduce coupling between components. You can publish events via
activityContext.getEventPublisher().publish()
and subscribe to and handle those events using the@EventListener
annotation. - Example:
// Event Publishing public class OrderService { public void completeOrder(Order order) { // ... Order processing logic ... activityContext.getEventPublisher().publish(new OrderCompletedEvent(order)); } } // Event Subscription @Component public class NotificationEventListener { @EventListener public void handleOrderCompleted(OrderCompletedEvent event) { // Logic to send notification on order completion } }
- An event publish/subscribe model has been introduced to reduce coupling between components. You can publish events via
- Asynchronous Method Execution (
@Async
)- To execute long-running tasks asynchronously in a separate thread, you can use the
@Async
annotation on the method. - Example:
@Component public class EmailService { @Async public void sendEmail(String to, String subject, String body) { // Long-running email sending task } }
- To execute long-running tasks asynchronously in a separate thread, you can use the
Enhancements
- XML Parsing Engine (
Nodelet
) Refactoring- The core engine for parsing XML configuration files has been extensively improved, significantly enhancing performance, memory efficiency, and maintainability.
- The introduction of Fluent API and the innovative
mount
feature allows for fast and stable processing of even very complex and deeply nested XML documents.
- XML Configuration Simplification
- When configuring
<bean>
, the DTD has been improved to allow direct use of<argument>
and<property>
without wrapper elements like<arguments>
or<properties>
if there is only one constructor argument or property. This enables writing more concise XML configurations. - Example:
<!-- Improved method --> <bean id="myBean" class="com.example.MyBean"> <property name="message" value="Hello"/> </bean>
- When configuring
🔗 Useful Links
- Official User Guide: https://aspectran.com/docs/
- GitHub Repository: https://github.com/aspectran/aspectran
Juho Jeong NEWS
Release