[osgi-dev] Life-cycle race condition

2018-07-31 Thread David Leangen via osgi-dev

Hi!

I am running into a situation where, what I think is happening is:

Component A gets instantiated
Component B
  - references A
  - gets satisfied once A is satisfied 
  - kicks off a long-running process when one of its methods are called
  - the long-running process is run in a different thread, with a Promise
Component A is no longer satisfied
But
  - the long-running process is still running
  - the long-running process now references an invalid Component A
  - the long-running thread fails because of the invalid state of Component A
Component B is no longer satisfied


So, the long-running component messes things up, but its component has not yet 
shut down even though its process is still happily running in another thread.

I can think of two possible solutions, but not sure which is best and not sure 
how to implement:

 1) Figure out a way to share an ExecutorService between “related” components 
so that when one component 
  shuts down it will signal to the other related components that their 
threads are now interrupted

 2) In the long-running process, determine if the component that provides the 
required service
   is still active before continuing with the havoc-wreaking process


Does this sound about right?

How would I actually accomplish either of these?


Thanks!
=David


___
OSGi Developer Mail List
osgi-dev@mail.osgi.org
https://mail.osgi.org/mailman/listinfo/osgi-dev

Re: [osgi-dev] Setting reference target in component

2018-07-31 Thread Tim Ward via osgi-dev
This sounds like a variation on this question 
 asked a few 
weeks ago in the osgi-dev list.

In summary, there are a couple of ways to achieve what you’re trying to do, and 
using configuration admin may or may not be the best approach given that you 
want to request an instance which you directly control the lifecycle of. 
Hopefully the thread will give you the answer that you’re looking for.

Best Regards,

Tim

> On 31 Jul 2018, at 13:24, Alain Picard via osgi-dev  
> wrote:
> 
> I need to configure some Component to be session scoped. I have followed the 
> article from Dirk at 
> http://blog.vogella.com/2017/02/24/control-osgi-ds-component-instances-via-configuration-admin/
>  
> 
>  which matches what I want.
> 
> But in my case the Component that configures the service is also the has a 
> reference to this service. I read a couple of SO about this 
> (https://stackoverflow.com/questions/47393876/dynamically-setting-target-property-in-osgi-reference-annotatation
>  
> 
>  and 
> https://stackoverflow.com/questions/21166070/osgi-declarative-services-filter-references-at-runtime
>  
> )
>  but I'm struggling to figure out the best way to both specify a 
> configuration as per the 1st article and then set the target in my component 
> to the resulting instance (and/or getting a component configuration and set 
> the target for my service).
> 
> Thanks
> Alain
> 
> ___
> OSGi Developer Mail List
> osgi-dev@mail.osgi.org
> https://mail.osgi.org/mailman/listinfo/osgi-dev

___
OSGi Developer Mail List
osgi-dev@mail.osgi.org
https://mail.osgi.org/mailman/listinfo/osgi-dev

[osgi-dev] Setting reference target in component

2018-07-31 Thread Alain Picard via osgi-dev
 I need to configure some Component to be session scoped. I have followed
the article from Dirk at
http://blog.vogella.com/2017/02/24/control-osgi-ds-component-instances-via-configuration-admin/
which matches what I want.

But in my case the Component that configures the service is also the has a
reference to this service. I read a couple of SO about this (
https://stackoverflow.com/questions/47393876/dynamically-setting-target-property-in-osgi-reference-annotatation
and
https://stackoverflow.com/questions/21166070/osgi-declarative-services-filter-references-at-runtime)
but I'm struggling to figure out the best way to both specify a
configuration as per the 1st article and then set the target in my
component to the resulting instance (and/or getting a component
configuration and set the target for my service).

Thanks
Alain
___
OSGi Developer Mail List
osgi-dev@mail.osgi.org
https://mail.osgi.org/mailman/listinfo/osgi-dev