[osgi] models as adapters

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[osgi] models as adapters

Nicolas Peltier-4
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 :)
Reply | Threaded
Open this post in threaded view
|

Re: [osgi] models as adapters

Robert Munteanu-2
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