Hi Rubén,
This is not possible with DS because DS activates components
asynchronously and the state of the components is (almost) completely
unrelated to the state of the containing bundle -- except that
components may only be activated if the containing bundle is active, of
course. Failing to activate a component never ever has an influence on
the bundle state.
Rubén Barroso schrieb:
I have a bundle which is activated through Declarative Services and when I
perform a bundle.start(), the component defining the activate(...) method
raised an exception, but I can only see following in the logs:
Declarative Services got exception when invoking "activate" in component
myeventlistener.eventlistener-1.0.0
(java.lang.reflect.InvocationTargetException)
I agree, that this is not very helpful. What version of the scr bundle
are you using ? I kown, that I enhance logging recently, but I am not
sure, whether this is already in the latest 1.0.2 release.
Otherwise it will be contained in the next release. You might want to
crosscheck with the current snapshot version 1.0.3-SNAPSHOT.
What I want is the code doing bundle.start() to be notified of such failure,
so can stop the process.From the specs:
"If the activate method throws an exception, SCR must log an error message
containing the exception with the Log Service, if present, and the component
configuration is not activated."
I know I could use a BundleActivator approach instead, but I wouldn't want
to lose other benefits DS offers to me. Is anyone aware of some pattern I
could use to accomplish this?
As I said, a notification of the code calling bundle.start() is not
foreseen and not implemented and cannot be done, because this all runs
disconnected (and asynchronously).
Unfortunately there is also not a OSGi specified way of querying
components and their state.
Apache Felix SCR has a non-standard API to ask for components and their
state, though. Look for the ScrService. This mechanism is also used to
display the SCR component states in the Apache Felix web console.
Hope this helps.
Regards
Felix
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]