What Event should an @EventListener method listen to in order to execute after all context is built?

java

#1

What Event should an @EventListener method listen to in order to execute right after all of Spring context has been initialized?

@EventListener
public void saveOneObject(SomeEventClass event) {
 ao.executeInTransaction(new TransactionCallback<MyObject>()
 {
     @Override
     public MyObject doInTransaction() {
     MyObject myObject = ao.create(MyObject.class);
     myObject.setAttr1();
     myObject.setAttr2();
     //...
     myObject.save();
     return myObject;
 }
 });
}

Not really part of the question, but for some context, I’m trying to initialize ActiveObjects db with some default values. Apparently, this can’t be done until all of Spring context has been initialized. https://ecosystem.atlassian.net/browse/AO-530


#2

Wouldn’t upgrade task be a better fit for your use case?


#3

Some additional links for this method:
https://developer.atlassian.com/server/framework/atlassian-sdk/upgrading-your-plugin-and-handling-data-model-updates/

https://developer.atlassian.com/server/framework/atlassian-sdk/upgrading-your-plugin-and-handling-data-model-updates/


#4

I want to let you know that I circumvented the problem with a dirty fix. I added the Active Objects seeding procedure inside the init method of a filter, and I used the moduleMetaData().awaitInitialization() to make sure nothing started until the initialization was done.

Thanks for you tips and efforts to help me.