-
Sep 12th, 2012, 07:50 AM
#1
How to get state of DI?
Hi,
I want to know if bean initialization is done and everything is ok (no errors).
How can I programatically do that?
Best regards,
Ingo
-
Sep 12th, 2012, 03:39 PM
#2
Can you be more specific? If there is an error during Spring context creation, an exception is thrown. By @Required annotation on a bean, you can check that a dependency is injected. @Autowired properties are @Required by default.
You can load a bean by applicationContext.getBean(..) and then perform any check you want on a class instance.
-
Sep 13th, 2012, 01:46 AM
#3
Sorry, I wasn't clear enough.
I want to know if all defined beans have bean correctly initialized (= dependency injection).
Why I am doing this?
I want to write a "health" servlet that returns a HTTP 200 message if all OSGi bundles with Spring DI has been initialized without an error.
-
Sep 19th, 2012, 03:13 AM
#4
I found a solution by implementing an OsgiBundleApplicationContextListener.
OsgiBundleContextFailedEvent: Signals an bean configuration error in a bundle. That's the most important part.
My application is huge, that's why it takes a while to init al beans. That's why I added an additional check:
BootstrappingDependencyEvent + OsgiBundleContextRefreshedEvent: I save all symbolic names of bootstrapping and refresh events in a set. I remove all refresh events form the bootstrapping set and if the result is empty, then all contexts of bundles have been processed.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules