Execute Daemon Module After Specific Daemon Module

Hi Team,

I want to execute custom daemon module after specific daemon module. If it is possible, please suggest the solution. Thanks in advance…

Harin Delli

Hi Harin,

To execute com.example.repository.SecondDaemonModule after com.example.repository.FirstDaemonModule, I think you can try to put @org.onehippo.repository.modules.After annotation onto the SecondDaemonModule class:

@After(modules= { FirstDaemonModule.class })
public class SecondDaemonModule ...{



Hi Woonsan,

Thanks for quick response…
I have tried RequiresService also. I tried to access the service {HippoServiceRegistry.register(service, FirstDaemonModuleService.class);} defined on FirstDaemonModule to SecondDaemonModule. I am not able to use service which one is showing “null”. Any restriction is there like “We cannot access service on DaemonModule”.

Harin Delli

Did you add ProvidesService annotation in the FirstDaemonModule with the FirstDaemonModuleService.class, and RequiresService with FirstDaemonModuleService.class in the SecondDaemonModule?

Yes. I added ProvidesService annotation in the FirstDaemonModule with the FirstDaemonModuleService.class , and RequiresService with FirstDaemonModuleService.class in the SecondDaemonModule. After adding like this “I have observed one thing. SecondDaemonModule is executing before FirstDaemonModule”.

May i know the execution flow of DaemonModules like alphabetic order?

Note:: ProvidesService on FirstDaemonModule, RequiresService on SecondDaemonModule…

It seems like module executions (i.e, invoking #initialize()) is done in ModuleManager#startModules() [1], which expects a sorted module list from ModuleRegistry#getModuleRegistrations() [2].
I don’t think @RequireServices and @ProvideServices affects the execution ordering. Instead only @After annotation seems to have a real impact.
Is your trial with @After not working?


[1] https://code.onehippo.org/cms-community/hippo-repository/blob/hippo-repository-14.1.0/engine/src/main/java/org/onehippo/repository/modules/ModuleManager.java#L123-127
[2] https://code.onehippo.org/cms-community/hippo-repository/blob/hippo-repository-14.1.0/engine/src/main/java/org/onehippo/repository/modules/ModuleRegistry.java#L53-110

Thanks Woonsan. This information helped to me…