简体   繁体   中英

How to create session beans after context initializations

I have following problem. I have a Vaadin/Spring application. All the business logic and data come from a different system and my application is using REST service clients for accessing these data. I have a lot of components, where I need these service clients.

I have a singleton class (kind of helper), that can provide beans from the Spring context. I would like to have my service client beans in this context, too, and just call getBean(beanId) on my helper class in my components. However, they should be first initialized after the user logs into the application (or even better, when they are first accessed). I don't want to create objects of my service clients in each component I need them and I also don't want to pass those objects through component constructors or methods.

Could someone point me the right directions???

The default Spring configuration is for Eager Initialization - ie singletons are initialized as the ApplicationContext is started, by defining the spring beans with Lazy Initialization . That way way, they should only be initialized when requested.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM