Skip to content

Commit 942449d

Browse files
committed
[NAE-2090] add documentation
1 parent 22709cf commit 942449d

3 files changed

Lines changed: 35 additions & 1 deletion

File tree

application-engine/src/main/groovy/com/netgrif/application/engine/integration/modules/ModuleHolder.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ package com.netgrif.application.engine.integration.modules
22

33
/**
44
* A class where the module services are injected. The plugins are injected into metaclasses
5-
* */
5+
*/
66
class ModuleHolder {
77
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
package com.netgrif.application.engine.integration.modules
22

3+
/**
4+
* A class where the module services are injected for a named module. The plugins are injected into metaclasses
5+
*/
36
class ModuleServiceHolder {
47
}

application-engine/src/main/groovy/com/netgrif/application/engine/integration/modules/ModuleServiceInjector.groovy

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,16 @@ import org.springframework.boot.ApplicationArguments
99
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty
1010
import 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

Comments
 (0)