@@ -9,6 +9,16 @@ import org.springframework.boot.ApplicationArguments
99import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty
1010import org.springframework.stereotype.Component
1111
12+ /**
13+ * Component responsible for injecting module services into the application runtime.
14+ * This class implements {@link ApplicationEngineFinishRunner} to perform the injection
15+ * after the application finishes its startup routine. The services are grouped by modules
16+ * and made available for runtime action delegation.
17+ *
18+ * The execution of this class is controlled by properties defined in the application configuration.
19+ * By default, it is enabled and executed in the specified order.
20+ */
21+
1222@Component
1323@RunnerOrder (209 )
1424@ConditionalOnProperty (value = " nae.modules.services.enabled" , havingValue = " true" , matchIfMissing = true )
@@ -17,6 +27,16 @@ class ModuleServiceInjector implements ApplicationEngineFinishRunner {
1727 private static final Logger log = LoggerFactory . getLogger(ModuleServiceInjector . class)
1828 private final String DEFAULT_KEY = " default"
1929
30+ /**
31+ * Executes the injection of services annotated with {@code @ModuleService }.
32+ * This method collects all beans marked with the {@code @ModuleService } annotation,
33+ * groups them by their associated module, and injects them into the respective meta-classes
34+ * (e.g., {@code ModuleHolder } and {@code ModuleServiceHolder }).
35+ *
36+ * @param args application arguments passed during startup
37+ * @throws Exception if any error occurs during the injection process
38+ */
39+
2040 @Override
2141 void run (ApplicationArguments args ) throws Exception {
2242 def injectableBeans = ApplicationContextProvider . getAppContext(). getBeansWithAnnotation(ModuleService . class)
@@ -41,6 +61,17 @@ class ModuleServiceInjector implements ApplicationEngineFinishRunner {
4161 }
4262 }
4363
64+ /**
65+ * Groups services annotated with {@code @ModuleService } by their associated module.
66+ * Each service is categorized under a module key specified by the annotation's value.
67+ * Services without a specified module are grouped under the "default" key.
68+ *
69+ * @param services a map of service names to service instances retrieved from the application context
70+ * @return a map where each key represents a module, and the value is another map containing
71+ * services (name and instance) associated with that module
72+ * @throws IllegalStateException if any service lacks the {@code @ModuleService } annotation
73+ */
74+
4475 private Map<String , Map<String , Object > > groupServicesByModule (Map<String , Object > services ) {
4576 Map<String , Map<String , Object > > grouped = [(DEFAULT_KEY ): [:]]
4677 services. each { entry ->
0 commit comments