Closed arcane86 closed 13 years ago
The complete life cycle of a bean bundle is now:
STARTING => START => INITIALIZED => [VALID =>] STOPPING => SHUTDOWN => [INVALID =>] STOP
But got another error when instantiating bean in the onShutdown method (dependent scoped bean catching the BundleContainerEvents.BundleContainerShutdown event):
ERROR o.o.c.i.e.OSGiServiceBean - Unable to instantiate OSGiServiceBean [HelloWorld] with qualifiers [@Any @OSGiService @Filter(value=(language.value=ENGLISH))] due to java.lang.IllegalStateException: Can only add listeners while bundle is active or activating.
The error eventually occurs after a random number of bean creations. Here the log dump:
16:29:14.946 [Gogo shell] TRACE o.o.c.i.i.IntegrationActivator - Firing the BundleContainerEvents.BundleContainerShutdown event
16:29:14.947 [Gogo shell] DEBUG o.o.c.i.e.OSGiServiceProducerBean - Instantiation of an OSGiServiceProducerBean [org.osgi.cdi.api.extension.Service<com.sample.api.HelloWorld>] with qualifiers [@Any @Default]
16:29:14.947 [Gogo shell] DEBUG o.o.c.i.e.b.ServiceImpl - Creation of a new service provider for bundle com.sample.hello-world-consumer2-multilingual [12] as interface com.sample.api.HelloWorld with filter @org.osgi.cdi.api.extension.annotation.Filter(value="")
16:29:14.948 [Gogo shell] DEBUG o.o.c.i.e.OSGiServiceBean - Instantiation of an OSGiServiceBean [HelloWorld] with qualifiers [@Any @OSGiService @Filter(value=(language.value=ENGLISH))]
16:29:14.948 [Gogo shell] DEBUG o.o.c.i.e.b.DynamicServiceHandler - Creation of a new DynamicServiceHandler for bundle com.sample.hello-world-consumer2-multilingual [12] as a com.sample.api.HelloWorld with filter (language.value=ENGLISH)
16:29:14.949 [Gogo shell] ERROR o.o.c.i.e.OSGiServiceBean - Unable to instantiate OSGiServiceBean [HelloWorld] with qualifiers [@Any @OSGiService @Filter(value=(language.value=ENGLISH))] due to java.lang.IllegalStateException: Can only add listeners while bundle is active or activating.
With application scoped beans the error is still there for service producers only.
Hey Matthieu, what about this one ?
Same point i think. I'll work on it right now :)
Can you try to reproduce it quickly ?
Bundle lifec cycle is validated with this commit https://github.com/arcane86/core/commit/d967fe70d5aae6b0e17d35f14452c527d037cfa5.
Still need to test usages of CDI in synchronously called method during STOPPING phase of life cycle. VALID and INVALID states could be tested as well.
The life cycle behavior for bean bundles now complies with specifications except that auto published service (Publish annotated service) should not be usable into OSGi BundleActivator stop method (but they are).
Nothing very wrong, i think this may be a new issue for future releases.
It seems right but it forbids usage of OSGi related features in the
method of a bean bundle when it occurs due to the stopping of the bean bundle.
We should: -specify that this method should not use OSGi or CDI-OSGi features -find a way to modify the bean bundle life cycle from OSGi_start ==> CDIContainer_initialized ==> OSGi_stop ==> CDIContainer_shutdown to OSGi_start ==> CDIContainer_initialized ==> CDIContainer_shutdown ==> OSGi_stop