Hi,

On 25.08.2009, at 11:25, [email protected] wrote:

Hello again,

I must add my two iPojo services have the same start level because
they're coming from the same bundle. I don't know if it can be usefull
to understand my problem...

++

[email protected] wrote:
Hello,

I've two iPojo services object and objectRegistry. The service object
requires objectRegistry and the services objectRegistry doesn't require
any services.
When starting (iPojo @Validate) my object service it automatically bind
itself in the objectRegistry service.
When stopping (iPojo @Invalidate) my object service it automatically
unbind itself from the objectRegistry service.

Sometimes I get this warning when shutting down my Felix:

[WARNING] object : [object.42679d9e-eee8-4810-bcd4-a21b5cbc91a1] The
dependency is not optional, however no service objectRegistry can be
injected in obr -> objectRegistry

After this warning I get a null pointer exception - no more as I verify
now if obr is null or not before any call on it - on my object
invalidate stop method because object try to unbind itself from my
objectRegistry services.

As I can not reproduce the problem every time I've the impression Felix is shutting down its services in a disorder way ... Some times it's ok
some times not...

I would like to understand why the service objectRegistry has been
shutdown before the service object as object requires objectRegistry ? Should Felix not manage the requires tree at shutdown as it managed it
at start ? Do I miss something ? Is this a known bug ? Is there a
solution for this problem ?

Thanks for all.


It not a bug, it a normal behavior. Let me explain why:
during the shutdown, Felix stops all the bundles, and so services leaves. When a required (not optional) service leaves, it invalidates the instance. If this instance has an 'invalidate' callback, this callback is called. The callback is called after its unregistration, that's why the service is no more available. So, invalidate callbacks must be developed defensively to check service availability:
public void stop() {
  if (myservice != null) {
    // you can use myservice
 }
}

If you really need to do something on this service before it leaves, you can add an unbind callback on the dependency. This callback is called during the unregistration, and so you have access to the service.

Regards,

Clement





---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]





---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to