How qianxingchuan/doraemon works
Main Architectural Components
• Core Framework: Represented by the “asgard-doraemon” module. It provides the essential classes such as AsgardBundle, AsgardClassLoader, BundleConfiguration, and the main entry (RunDoraemonBundle). This is where the bundle lifecycle management is implemented.
• Bundle Interface/Service: The “doraemon-facade” defines the BundleService interface which every bundle must implement. This is core to keeping the plugin system loosely coupled.
• Bundle Project Archetype: “doraemon-project-archetype” offers the basic skeleton and structure for new bundles. It includes configuration (like bundle.properties) that details the init-class and skip-class settings.
• Sample Bundles and Projects: In “doraemon-sample”, you have sample implementations (e.g., sample-auth-bundle1, sample-auth-bundle2) that demonstrate different implementations of an authentication service. Also, sample-auth-facade and sample-auth-project illustrate how bundles are operated and integrated.
• Integration Modules: The spring boot examples (“doraemon-spring-boot-expample” and “doraemon-spring-boot-starter”) show how the framework integrates into a Spring Boot environment.
Relationships and Interactions
• Each bundle (in sample-auth-bundle1 and sample-auth-bundle2) implements its own BundleService which is registered and then discovered by the core.
• The bundle.properties file in each bundle defines configuration directives. The “init-class” is loaded by the bundle’s own ClassLoader to invoke its business logic. In contrast, “skip-class” denotes classes that remain in the application’s default class loader.
• The service façade provides a common API to the application (or main runner) to interact with the loaded bundles.
• For projects that integrate with Spring Boot, the starter module auto-configures the framework (via DoraemonAutoConfigure) to scan and load bundles seamlessly upon application startup.
Architectural Patterns and Principles
• Plugin / Modular Architecture: Emphasize the isolation and pluggability. The entire design revolves around allowing bundles to be developed, packaged (as ZIP files), and dynamically loaded.
• ClassLoader Isolation: Illustrate how each bundle is loaded with its own class loader (An instance of AsgardClassLoader) ensuring that bundles are independent and shielded from each other.
• Inversion of Control: Notice the use of Spring (in some modules) and the decoupled architecture that lets the application retrieve implementations via the facade.
• Configuration Driving: Bundle-specific behavior is defined in external configuration files (bundle.properties) that dynamically influence module loading.