Initialize beans after application startup/on application event [spring] -


i have following situation. in microservice [ma] i'd initialise/destroy beans after application startup, or based on event. imagination there microservice [mb] holds informations contentstores. after ma startup i'd ask mb contentstore entries , based on i'd create many beans needed. there can event trigger storecreated/storedeleted , in case need destroy bean.

i don't know interfaces need implement/classes extend please give me suggestions.

so let's start applicationlistener , event applicationreadyevent. 2 know ma initialized , can ask mb list of stores.

in place can take advantage of event's applicationcontext , create beans (each bean have it's own qualifier - e.g. id) , if needed autowire dependencies.

but place don't know how add created beans applicationcontext.

the same mechanism should exists application events, in case can @ first check if beans created , if so, return them.

note: i'm using spring-boot 1.4.

thanks

i'd initialise/destroy beans after application startup, or based on event.

for question, can regist bean using org.springframework.beans.factory.support.beandefinitionregistrypostprocessor register beandefinition

an alternative use @postconstruct in bean - "the postconstruct annotation used on method needs executed after dependency injection done perform initialization. "

for application exit, can use application exit hook here - doc


Comments

Popular posts from this blog

unity3d - Rotate an object to face an opposite direction -

angular - Is it possible to get native element for formControl? -

javascript - Why jQuery Select box change event is now working? -