Hi,
Am Montag, den 14.01.2008, 17:46 +0100 schrieb Bertrand Delacretaz:
> Hi,
>
> Currently org.apache.sling.jcr.jackrabbit.server.Activator does this:
>
> public void start(BundleContext context) throws Exception {
> ....
> ServiceReference sr =
> context.getServiceReference(ConfigurationAdmin.class.getName());
> if (sr == null) {
> log.info("Activator: Need ConfigurationAdmin Service to
> ensure configuration");
> return;
> }
>
> So if this jackrabbit.server bundle is started before
> ConfigurationAdmin, it does not start correctly, yet is shown started
> in the OSGi console.
Not really. The bundle activator just tries to ensure at least one
configuration in the Configuration Admin. If there is no Configuration
Admin (yet), this can of course not be done and this is not considered
problematic. In fact, if the Configuration Admin service will never run,
the bundle will never be provided with configuration and never provide
service.
On a side note: We might make this evident by adding a "Import-Service:
ConfigurationAdmin" header to the bundle manifest. This is not enforced
by the framework but highlights the dependency on a running service.
>
> Throwing an Exception instead of log.info would be better already, as
> in that case OSGi sees the problem and does not mark the bundle as
> started.
No, because as I said, the bundle may well start without the service.
>
> There's probably a better way though - how do I tell OSGi that the
> jackrabbit.server bundle must be started after the ConfigurationAdmin
> service is started?
There is no way because these are two levels of abstraction: On is the
lifecycle layer which is responsible for the bundle lifecycle and the
other is the service layer providing means to register and retrieve
services.
>
> With SCR I'd add an @scr.reference, but I'm not sure how to do it with
> this Activator.
What we can do here, to fix this issue is something likes this:
(a) If the Configuration Admin is available when the bundle starts,
the
configuration is verified as it is now.
(b) Otherwise a service listener is registered for the Configuration
Admin
service, which is triggered as soon as the Configuration Admin
Service
is registered. Then the listener may verify the configuration
(and
unregister as a service listener)
WDYT ?
Regards
Felix
>
> -Bertrand