You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@sling.apache.org by Nicolas Peltier <np...@apache.org> on 2019/11/18 15:15:42 UTC

[osgi] models as adapters

Hi,

i have the following use case:
- my bundle has a model A, and a long running thread, using
.adaptTo(A.class) from a resource,
- when upgrading my bundle with thread still running there is a period when
above adaptTo will return null

if it is "okay", and i should detect bundle status in my thread, my
question is how best should i do that?
If not, i guess, i'll dive deeper in models implementation :)

Re: [osgi] models as adapters

Posted by Robert Munteanu <ro...@apache.org>.
Hi Nicolas,

On Mon, 2019-11-18 at 16:15 +0100, Nicolas Peltier wrote:
> Hi,
> 
> i have the following use case:
> - my bundle has a model A, and a long running thread, using
> .adaptTo(A.class) from a resource,
> - when upgrading my bundle with thread still running there is a
> period when
> above adaptTo will return null
> 
> if it is "okay", and i should detect bundle status in my thread, my
> question is how best should i do that?
> If not, i guess, i'll dive deeper in models implementation :)

If you're waiting for a certain adaptTo call to become valid you can
use the Adaption service [1].

Robert

[1]: https://github.com/apache/sling-org-apache-sling-adapter/blob/master/src/main/java/org/apache/sling/adapter/Adaption.java