You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by Bram Pouwelse <br...@pouwelse.com> on 2016/05/25 18:38:57 UTC

DependencyManager: Removing component before bundle is started doesn't work

Hi,

I have an issue with a bundle that removes a DM component before the bundle
is started. If that happens the service remains available in the service
registry.

I could reproduce this using a simple activator (which doesn't make any
sense but works to demonstrate the issue).

public class Activator extends DependencyActivatorBase {

  @Override
  public void init(BundleContext arg0, DependencyManager dm) throws
Exception {
    Component addRemove =
createComponent().setInterface(Object.class.getName(),
null).setImplementation(Object.class);
    dm.add(addRemove);
    dm.remove(addRemove);
  }
}

After starting this bundle the dm gogo command doesn't list any components
but the service is available in the service registry.

g! dm

g! inspect cap service 1
dm.test [1] provides:
---------------------
service; java.lang.Object with properties:
   service.bundleid = 1
   service.id = 4
   service.scope = singleton

g!


Is this expected behavior or a bug?

Regards,

Bram

Re: DependencyManager: Removing component before bundle is started doesn't work

Posted by Pierre De Rop <pi...@gmail.com>.
Good to know it works :-)

I just created FELIX-5268 <https://issues.apache.org/jira/browse/FELIX-5268>
which describes the issue, and added a test case.

Thanks for having reported this problem.

cheers
/Pierre


On Thu, May 26, 2016 at 3:55 PM, Bram Pouwelse <br...@pouwelse.com> wrote:

> Pierre,
>
> I've tested with trunk that seems to work for me :) You are quick, fixing
> the issue took you less time than it took me figuring out what was
> happening ..
>
> Thanks!
>
> Bram
>
> On Thu, May 26, 2016 at 3:45 PM Pierre De Rop <pi...@gmail.com>
> wrote:
>
> > Bram,
> >
> > Can you svn update the trunk, and give it a try ?
> >
> > I fixed the following: when a component is being removed, its service was
> > not unregistered if the bundle state was STARTING !
> >
> > Can you confirm it works now with the trunk ? I wait for your
> confirmation,
> > then I will make a jira issue and the corresponding test case, but
> probably
> > tomorrow.
> >
> > thanks !
> >
> > /pierre
> >
> > On Thu, May 26, 2016 at 9:09 AM, Bram Pouwelse <br...@pouwelse.com>
> wrote:
> >
> > > Thanks!
> > >
> > > Maybe good to mention that I have a workaround for the issue, by
> adding a
> > > bundle dependency [1] to the component that creates and removes these
> > > services everything works ok.
> > >
> > > Regards,
> > > Bram
> > >
> > > 1: createBundleDependency().setBundle(context
> > > .getBundle()).setStateMask(Bundle.ACTIVE).setRequired(true)
> > >
> > > On Thu, May 26, 2016 at 9:05 AM Pierre De Rop <pi...@gmail.com>
> > > wrote:
> > >
> > > > ok Bram; I will try to reproduce this issue with a test case. (I'm
> off
> > > this
> > > > morning, will do it this afternoon).
> > > >
> > > > cheers;
> > > > /Pierre
> > > >
> > > > On Thu, May 26, 2016 at 8:58 AM, Bram Pouwelse <br...@pouwelse.com>
> > > wrote:
> > > >
> > > > > I use an Activator and create a component with service
> dependencies,
> > > when
> > > > > services are added / removed the component will add / remove
> > additional
> > > > > components. This all works but if a component is removed before the
> > > > > BundleActivator#start method has completed the service will stick
> > > around
> > > > in
> > > > > the service registry.
> > > > >
> > > > > Regards,
> > > > > Bram
> > > > >
> > > > > On Thu, May 26, 2016 at 8:51 AM Pierre De Rop <
> > pierre.derop@gmail.com>
> > > > > wrote:
> > > > >
> > > > > > but the Activator is invoked only when the bundle is started. I'm
> > not
> > > > > sure
> > > > > > I understand ?
> > > > > > Are you invoking the Activator.init method from another bundle,
> > like
> > > an
> > > > > > extender bundle which would track all install/resolve bundles and
> > > would
> > > > > > instantiate an Activator from a not started bundle and invoke it
> ?
> > > > > >
> > > > > > thanks;
> > > > > > /Pierre
> > > > > >
> > > > > > On Thu, May 26, 2016 at 8:46 AM, Bram Pouwelse <
> bram@pouwelse.com>
> > > > > wrote:
> > > > > >
> > > > > > > Hi Pierre,
> > > > > > >
> > > > > > > Thanks for the quick reply. I should've been a bit more clear
> in
> > my
> > > > > > > message, the problem is when you remove a component before the
> > > bundle
> > > > > is
> > > > > > > started (that's why I used the Activator to demonstrate the
> > issue).
> > > > > Once
> > > > > > > the test you've created runs the bundle is already started and
> > all
> > > > > works
> > > > > > as
> > > > > > > expected.
> > > > > > >
> > > > > > > Regards,
> > > > > > > Bram
> > > > > > >
> > > > > > > On Thu, May 26, 2016 at 8:15 AM Pierre De Rop <
> > > > pierre.derop@gmail.com>
> > > > > > > wrote:
> > > > > > >
> > > > > > > > Hi Bram,
> > > > > > > >
> > > > > > > > The service should be removed from the service registry when
> > you
> > > > > remove
> > > > > > > the
> > > > > > > > Component from DependencyManager.
> > > > > > > >
> > > > > > > > Now, I tried to reproduce the issue you are describing in
> [1],
> > > but
> > > > I
> > > > > > > could
> > > > > > > > not (the test is OK).
> > > > > > > > Can you please take a look at it in order to see if it the
> same
> > > > kind
> > > > > of
> > > > > > > > scenario you have ? Am i missing something ?
> > > > > > > >
> > > > > > > > thank you;
> > > > > > > >
> > > > > > > > cheers;
> > > > > > > > /Pierre
> > > > > > > >
> > > > > > > > [1]
> > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager.itest/src/org/apache/felix/dm/itest/api/AddRemoteTest.java
> > > > > > > >
> > > > > > > > On Wed, May 25, 2016 at 8:38 PM, Bram Pouwelse <
> > > bram@pouwelse.com>
> > > > > > > wrote:
> > > > > > > >
> > > > > > > > > Hi,
> > > > > > > > >
> > > > > > > > > I have an issue with a bundle that removes a DM component
> > > before
> > > > > the
> > > > > > > > bundle
> > > > > > > > > is started. If that happens the service remains available
> in
> > > the
> > > > > > > service
> > > > > > > > > registry.
> > > > > > > > >
> > > > > > > > > I could reproduce this using a simple activator (which
> > doesn't
> > > > make
> > > > > > any
> > > > > > > > > sense but works to demonstrate the issue).
> > > > > > > > >
> > > > > > > > > public class Activator extends DependencyActivatorBase {
> > > > > > > > >
> > > > > > > > >   @Override
> > > > > > > > >   public void init(BundleContext arg0, DependencyManager
> dm)
> > > > throws
> > > > > > > > > Exception {
> > > > > > > > >     Component addRemove =
> > > > > > > > > createComponent().setInterface(Object.class.getName(),
> > > > > > > > > null).setImplementation(Object.class);
> > > > > > > > >     dm.add(addRemove);
> > > > > > > > >     dm.remove(addRemove);
> > > > > > > > >   }
> > > > > > > > > }
> > > > > > > > >
> > > > > > > > > After starting this bundle the dm gogo command doesn't list
> > any
> > > > > > > > components
> > > > > > > > > but the service is available in the service registry.
> > > > > > > > >
> > > > > > > > > g! dm
> > > > > > > > >
> > > > > > > > > g! inspect cap service 1
> > > > > > > > > dm.test [1] provides:
> > > > > > > > > ---------------------
> > > > > > > > > service; java.lang.Object with properties:
> > > > > > > > >    service.bundleid = 1
> > > > > > > > >    service.id = 4
> > > > > > > > >    service.scope = singleton
> > > > > > > > >
> > > > > > > > > g!
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > Is this expected behavior or a bug?
> > > > > > > > >
> > > > > > > > > Regards,
> > > > > > > > >
> > > > > > > > > Bram
> > > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>

Re: DependencyManager: Removing component before bundle is started doesn't work

Posted by Bram Pouwelse <br...@pouwelse.com>.
Pierre,

I've tested with trunk that seems to work for me :) You are quick, fixing
the issue took you less time than it took me figuring out what was
happening ..

Thanks!

Bram

On Thu, May 26, 2016 at 3:45 PM Pierre De Rop <pi...@gmail.com>
wrote:

> Bram,
>
> Can you svn update the trunk, and give it a try ?
>
> I fixed the following: when a component is being removed, its service was
> not unregistered if the bundle state was STARTING !
>
> Can you confirm it works now with the trunk ? I wait for your confirmation,
> then I will make a jira issue and the corresponding test case, but probably
> tomorrow.
>
> thanks !
>
> /pierre
>
> On Thu, May 26, 2016 at 9:09 AM, Bram Pouwelse <br...@pouwelse.com> wrote:
>
> > Thanks!
> >
> > Maybe good to mention that I have a workaround for the issue, by adding a
> > bundle dependency [1] to the component that creates and removes these
> > services everything works ok.
> >
> > Regards,
> > Bram
> >
> > 1: createBundleDependency().setBundle(context
> > .getBundle()).setStateMask(Bundle.ACTIVE).setRequired(true)
> >
> > On Thu, May 26, 2016 at 9:05 AM Pierre De Rop <pi...@gmail.com>
> > wrote:
> >
> > > ok Bram; I will try to reproduce this issue with a test case. (I'm off
> > this
> > > morning, will do it this afternoon).
> > >
> > > cheers;
> > > /Pierre
> > >
> > > On Thu, May 26, 2016 at 8:58 AM, Bram Pouwelse <br...@pouwelse.com>
> > wrote:
> > >
> > > > I use an Activator and create a component with service dependencies,
> > when
> > > > services are added / removed the component will add / remove
> additional
> > > > components. This all works but if a component is removed before the
> > > > BundleActivator#start method has completed the service will stick
> > around
> > > in
> > > > the service registry.
> > > >
> > > > Regards,
> > > > Bram
> > > >
> > > > On Thu, May 26, 2016 at 8:51 AM Pierre De Rop <
> pierre.derop@gmail.com>
> > > > wrote:
> > > >
> > > > > but the Activator is invoked only when the bundle is started. I'm
> not
> > > > sure
> > > > > I understand ?
> > > > > Are you invoking the Activator.init method from another bundle,
> like
> > an
> > > > > extender bundle which would track all install/resolve bundles and
> > would
> > > > > instantiate an Activator from a not started bundle and invoke it ?
> > > > >
> > > > > thanks;
> > > > > /Pierre
> > > > >
> > > > > On Thu, May 26, 2016 at 8:46 AM, Bram Pouwelse <br...@pouwelse.com>
> > > > wrote:
> > > > >
> > > > > > Hi Pierre,
> > > > > >
> > > > > > Thanks for the quick reply. I should've been a bit more clear in
> my
> > > > > > message, the problem is when you remove a component before the
> > bundle
> > > > is
> > > > > > started (that's why I used the Activator to demonstrate the
> issue).
> > > > Once
> > > > > > the test you've created runs the bundle is already started and
> all
> > > > works
> > > > > as
> > > > > > expected.
> > > > > >
> > > > > > Regards,
> > > > > > Bram
> > > > > >
> > > > > > On Thu, May 26, 2016 at 8:15 AM Pierre De Rop <
> > > pierre.derop@gmail.com>
> > > > > > wrote:
> > > > > >
> > > > > > > Hi Bram,
> > > > > > >
> > > > > > > The service should be removed from the service registry when
> you
> > > > remove
> > > > > > the
> > > > > > > Component from DependencyManager.
> > > > > > >
> > > > > > > Now, I tried to reproduce the issue you are describing in [1],
> > but
> > > I
> > > > > > could
> > > > > > > not (the test is OK).
> > > > > > > Can you please take a look at it in order to see if it the same
> > > kind
> > > > of
> > > > > > > scenario you have ? Am i missing something ?
> > > > > > >
> > > > > > > thank you;
> > > > > > >
> > > > > > > cheers;
> > > > > > > /Pierre
> > > > > > >
> > > > > > > [1]
> > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager.itest/src/org/apache/felix/dm/itest/api/AddRemoteTest.java
> > > > > > >
> > > > > > > On Wed, May 25, 2016 at 8:38 PM, Bram Pouwelse <
> > bram@pouwelse.com>
> > > > > > wrote:
> > > > > > >
> > > > > > > > Hi,
> > > > > > > >
> > > > > > > > I have an issue with a bundle that removes a DM component
> > before
> > > > the
> > > > > > > bundle
> > > > > > > > is started. If that happens the service remains available in
> > the
> > > > > > service
> > > > > > > > registry.
> > > > > > > >
> > > > > > > > I could reproduce this using a simple activator (which
> doesn't
> > > make
> > > > > any
> > > > > > > > sense but works to demonstrate the issue).
> > > > > > > >
> > > > > > > > public class Activator extends DependencyActivatorBase {
> > > > > > > >
> > > > > > > >   @Override
> > > > > > > >   public void init(BundleContext arg0, DependencyManager dm)
> > > throws
> > > > > > > > Exception {
> > > > > > > >     Component addRemove =
> > > > > > > > createComponent().setInterface(Object.class.getName(),
> > > > > > > > null).setImplementation(Object.class);
> > > > > > > >     dm.add(addRemove);
> > > > > > > >     dm.remove(addRemove);
> > > > > > > >   }
> > > > > > > > }
> > > > > > > >
> > > > > > > > After starting this bundle the dm gogo command doesn't list
> any
> > > > > > > components
> > > > > > > > but the service is available in the service registry.
> > > > > > > >
> > > > > > > > g! dm
> > > > > > > >
> > > > > > > > g! inspect cap service 1
> > > > > > > > dm.test [1] provides:
> > > > > > > > ---------------------
> > > > > > > > service; java.lang.Object with properties:
> > > > > > > >    service.bundleid = 1
> > > > > > > >    service.id = 4
> > > > > > > >    service.scope = singleton
> > > > > > > >
> > > > > > > > g!
> > > > > > > >
> > > > > > > >
> > > > > > > > Is this expected behavior or a bug?
> > > > > > > >
> > > > > > > > Regards,
> > > > > > > >
> > > > > > > > Bram
> > > > > > > >
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>

Re: DependencyManager: Removing component before bundle is started doesn't work

Posted by Pierre De Rop <pi...@gmail.com>.
Bram,

Can you svn update the trunk, and give it a try ?

I fixed the following: when a component is being removed, its service was
not unregistered if the bundle state was STARTING !

Can you confirm it works now with the trunk ? I wait for your confirmation,
then I will make a jira issue and the corresponding test case, but probably
tomorrow.

thanks !

/pierre

On Thu, May 26, 2016 at 9:09 AM, Bram Pouwelse <br...@pouwelse.com> wrote:

> Thanks!
>
> Maybe good to mention that I have a workaround for the issue, by adding a
> bundle dependency [1] to the component that creates and removes these
> services everything works ok.
>
> Regards,
> Bram
>
> 1: createBundleDependency().setBundle(context
> .getBundle()).setStateMask(Bundle.ACTIVE).setRequired(true)
>
> On Thu, May 26, 2016 at 9:05 AM Pierre De Rop <pi...@gmail.com>
> wrote:
>
> > ok Bram; I will try to reproduce this issue with a test case. (I'm off
> this
> > morning, will do it this afternoon).
> >
> > cheers;
> > /Pierre
> >
> > On Thu, May 26, 2016 at 8:58 AM, Bram Pouwelse <br...@pouwelse.com>
> wrote:
> >
> > > I use an Activator and create a component with service dependencies,
> when
> > > services are added / removed the component will add / remove additional
> > > components. This all works but if a component is removed before the
> > > BundleActivator#start method has completed the service will stick
> around
> > in
> > > the service registry.
> > >
> > > Regards,
> > > Bram
> > >
> > > On Thu, May 26, 2016 at 8:51 AM Pierre De Rop <pi...@gmail.com>
> > > wrote:
> > >
> > > > but the Activator is invoked only when the bundle is started. I'm not
> > > sure
> > > > I understand ?
> > > > Are you invoking the Activator.init method from another bundle, like
> an
> > > > extender bundle which would track all install/resolve bundles and
> would
> > > > instantiate an Activator from a not started bundle and invoke it ?
> > > >
> > > > thanks;
> > > > /Pierre
> > > >
> > > > On Thu, May 26, 2016 at 8:46 AM, Bram Pouwelse <br...@pouwelse.com>
> > > wrote:
> > > >
> > > > > Hi Pierre,
> > > > >
> > > > > Thanks for the quick reply. I should've been a bit more clear in my
> > > > > message, the problem is when you remove a component before the
> bundle
> > > is
> > > > > started (that's why I used the Activator to demonstrate the issue).
> > > Once
> > > > > the test you've created runs the bundle is already started and all
> > > works
> > > > as
> > > > > expected.
> > > > >
> > > > > Regards,
> > > > > Bram
> > > > >
> > > > > On Thu, May 26, 2016 at 8:15 AM Pierre De Rop <
> > pierre.derop@gmail.com>
> > > > > wrote:
> > > > >
> > > > > > Hi Bram,
> > > > > >
> > > > > > The service should be removed from the service registry when you
> > > remove
> > > > > the
> > > > > > Component from DependencyManager.
> > > > > >
> > > > > > Now, I tried to reproduce the issue you are describing in [1],
> but
> > I
> > > > > could
> > > > > > not (the test is OK).
> > > > > > Can you please take a look at it in order to see if it the same
> > kind
> > > of
> > > > > > scenario you have ? Am i missing something ?
> > > > > >
> > > > > > thank you;
> > > > > >
> > > > > > cheers;
> > > > > > /Pierre
> > > > > >
> > > > > > [1]
> > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
> http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager.itest/src/org/apache/felix/dm/itest/api/AddRemoteTest.java
> > > > > >
> > > > > > On Wed, May 25, 2016 at 8:38 PM, Bram Pouwelse <
> bram@pouwelse.com>
> > > > > wrote:
> > > > > >
> > > > > > > Hi,
> > > > > > >
> > > > > > > I have an issue with a bundle that removes a DM component
> before
> > > the
> > > > > > bundle
> > > > > > > is started. If that happens the service remains available in
> the
> > > > > service
> > > > > > > registry.
> > > > > > >
> > > > > > > I could reproduce this using a simple activator (which doesn't
> > make
> > > > any
> > > > > > > sense but works to demonstrate the issue).
> > > > > > >
> > > > > > > public class Activator extends DependencyActivatorBase {
> > > > > > >
> > > > > > >   @Override
> > > > > > >   public void init(BundleContext arg0, DependencyManager dm)
> > throws
> > > > > > > Exception {
> > > > > > >     Component addRemove =
> > > > > > > createComponent().setInterface(Object.class.getName(),
> > > > > > > null).setImplementation(Object.class);
> > > > > > >     dm.add(addRemove);
> > > > > > >     dm.remove(addRemove);
> > > > > > >   }
> > > > > > > }
> > > > > > >
> > > > > > > After starting this bundle the dm gogo command doesn't list any
> > > > > > components
> > > > > > > but the service is available in the service registry.
> > > > > > >
> > > > > > > g! dm
> > > > > > >
> > > > > > > g! inspect cap service 1
> > > > > > > dm.test [1] provides:
> > > > > > > ---------------------
> > > > > > > service; java.lang.Object with properties:
> > > > > > >    service.bundleid = 1
> > > > > > >    service.id = 4
> > > > > > >    service.scope = singleton
> > > > > > >
> > > > > > > g!
> > > > > > >
> > > > > > >
> > > > > > > Is this expected behavior or a bug?
> > > > > > >
> > > > > > > Regards,
> > > > > > >
> > > > > > > Bram
> > > > > > >
> > > > > >
> > > > >
> > > >
> > >
> >
>

Re: DependencyManager: Removing component before bundle is started doesn't work

Posted by Bram Pouwelse <br...@pouwelse.com>.
Thanks!

Maybe good to mention that I have a workaround for the issue, by adding a
bundle dependency [1] to the component that creates and removes these
services everything works ok.

Regards,
Bram

1: createBundleDependency().setBundle(context
.getBundle()).setStateMask(Bundle.ACTIVE).setRequired(true)

On Thu, May 26, 2016 at 9:05 AM Pierre De Rop <pi...@gmail.com>
wrote:

> ok Bram; I will try to reproduce this issue with a test case. (I'm off this
> morning, will do it this afternoon).
>
> cheers;
> /Pierre
>
> On Thu, May 26, 2016 at 8:58 AM, Bram Pouwelse <br...@pouwelse.com> wrote:
>
> > I use an Activator and create a component with service dependencies, when
> > services are added / removed the component will add / remove additional
> > components. This all works but if a component is removed before the
> > BundleActivator#start method has completed the service will stick around
> in
> > the service registry.
> >
> > Regards,
> > Bram
> >
> > On Thu, May 26, 2016 at 8:51 AM Pierre De Rop <pi...@gmail.com>
> > wrote:
> >
> > > but the Activator is invoked only when the bundle is started. I'm not
> > sure
> > > I understand ?
> > > Are you invoking the Activator.init method from another bundle, like an
> > > extender bundle which would track all install/resolve bundles and would
> > > instantiate an Activator from a not started bundle and invoke it ?
> > >
> > > thanks;
> > > /Pierre
> > >
> > > On Thu, May 26, 2016 at 8:46 AM, Bram Pouwelse <br...@pouwelse.com>
> > wrote:
> > >
> > > > Hi Pierre,
> > > >
> > > > Thanks for the quick reply. I should've been a bit more clear in my
> > > > message, the problem is when you remove a component before the bundle
> > is
> > > > started (that's why I used the Activator to demonstrate the issue).
> > Once
> > > > the test you've created runs the bundle is already started and all
> > works
> > > as
> > > > expected.
> > > >
> > > > Regards,
> > > > Bram
> > > >
> > > > On Thu, May 26, 2016 at 8:15 AM Pierre De Rop <
> pierre.derop@gmail.com>
> > > > wrote:
> > > >
> > > > > Hi Bram,
> > > > >
> > > > > The service should be removed from the service registry when you
> > remove
> > > > the
> > > > > Component from DependencyManager.
> > > > >
> > > > > Now, I tried to reproduce the issue you are describing in [1], but
> I
> > > > could
> > > > > not (the test is OK).
> > > > > Can you please take a look at it in order to see if it the same
> kind
> > of
> > > > > scenario you have ? Am i missing something ?
> > > > >
> > > > > thank you;
> > > > >
> > > > > cheers;
> > > > > /Pierre
> > > > >
> > > > > [1]
> > > > >
> > > > >
> > > >
> > >
> >
> http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager.itest/src/org/apache/felix/dm/itest/api/AddRemoteTest.java
> > > > >
> > > > > On Wed, May 25, 2016 at 8:38 PM, Bram Pouwelse <br...@pouwelse.com>
> > > > wrote:
> > > > >
> > > > > > Hi,
> > > > > >
> > > > > > I have an issue with a bundle that removes a DM component before
> > the
> > > > > bundle
> > > > > > is started. If that happens the service remains available in the
> > > > service
> > > > > > registry.
> > > > > >
> > > > > > I could reproduce this using a simple activator (which doesn't
> make
> > > any
> > > > > > sense but works to demonstrate the issue).
> > > > > >
> > > > > > public class Activator extends DependencyActivatorBase {
> > > > > >
> > > > > >   @Override
> > > > > >   public void init(BundleContext arg0, DependencyManager dm)
> throws
> > > > > > Exception {
> > > > > >     Component addRemove =
> > > > > > createComponent().setInterface(Object.class.getName(),
> > > > > > null).setImplementation(Object.class);
> > > > > >     dm.add(addRemove);
> > > > > >     dm.remove(addRemove);
> > > > > >   }
> > > > > > }
> > > > > >
> > > > > > After starting this bundle the dm gogo command doesn't list any
> > > > > components
> > > > > > but the service is available in the service registry.
> > > > > >
> > > > > > g! dm
> > > > > >
> > > > > > g! inspect cap service 1
> > > > > > dm.test [1] provides:
> > > > > > ---------------------
> > > > > > service; java.lang.Object with properties:
> > > > > >    service.bundleid = 1
> > > > > >    service.id = 4
> > > > > >    service.scope = singleton
> > > > > >
> > > > > > g!
> > > > > >
> > > > > >
> > > > > > Is this expected behavior or a bug?
> > > > > >
> > > > > > Regards,
> > > > > >
> > > > > > Bram
> > > > > >
> > > > >
> > > >
> > >
> >
>

Re: DependencyManager: Removing component before bundle is started doesn't work

Posted by Pierre De Rop <pi...@gmail.com>.
ok Bram; I will try to reproduce this issue with a test case. (I'm off this
morning, will do it this afternoon).

cheers;
/Pierre

On Thu, May 26, 2016 at 8:58 AM, Bram Pouwelse <br...@pouwelse.com> wrote:

> I use an Activator and create a component with service dependencies, when
> services are added / removed the component will add / remove additional
> components. This all works but if a component is removed before the
> BundleActivator#start method has completed the service will stick around in
> the service registry.
>
> Regards,
> Bram
>
> On Thu, May 26, 2016 at 8:51 AM Pierre De Rop <pi...@gmail.com>
> wrote:
>
> > but the Activator is invoked only when the bundle is started. I'm not
> sure
> > I understand ?
> > Are you invoking the Activator.init method from another bundle, like an
> > extender bundle which would track all install/resolve bundles and would
> > instantiate an Activator from a not started bundle and invoke it ?
> >
> > thanks;
> > /Pierre
> >
> > On Thu, May 26, 2016 at 8:46 AM, Bram Pouwelse <br...@pouwelse.com>
> wrote:
> >
> > > Hi Pierre,
> > >
> > > Thanks for the quick reply. I should've been a bit more clear in my
> > > message, the problem is when you remove a component before the bundle
> is
> > > started (that's why I used the Activator to demonstrate the issue).
> Once
> > > the test you've created runs the bundle is already started and all
> works
> > as
> > > expected.
> > >
> > > Regards,
> > > Bram
> > >
> > > On Thu, May 26, 2016 at 8:15 AM Pierre De Rop <pi...@gmail.com>
> > > wrote:
> > >
> > > > Hi Bram,
> > > >
> > > > The service should be removed from the service registry when you
> remove
> > > the
> > > > Component from DependencyManager.
> > > >
> > > > Now, I tried to reproduce the issue you are describing in [1], but I
> > > could
> > > > not (the test is OK).
> > > > Can you please take a look at it in order to see if it the same kind
> of
> > > > scenario you have ? Am i missing something ?
> > > >
> > > > thank you;
> > > >
> > > > cheers;
> > > > /Pierre
> > > >
> > > > [1]
> > > >
> > > >
> > >
> >
> http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager.itest/src/org/apache/felix/dm/itest/api/AddRemoteTest.java
> > > >
> > > > On Wed, May 25, 2016 at 8:38 PM, Bram Pouwelse <br...@pouwelse.com>
> > > wrote:
> > > >
> > > > > Hi,
> > > > >
> > > > > I have an issue with a bundle that removes a DM component before
> the
> > > > bundle
> > > > > is started. If that happens the service remains available in the
> > > service
> > > > > registry.
> > > > >
> > > > > I could reproduce this using a simple activator (which doesn't make
> > any
> > > > > sense but works to demonstrate the issue).
> > > > >
> > > > > public class Activator extends DependencyActivatorBase {
> > > > >
> > > > >   @Override
> > > > >   public void init(BundleContext arg0, DependencyManager dm) throws
> > > > > Exception {
> > > > >     Component addRemove =
> > > > > createComponent().setInterface(Object.class.getName(),
> > > > > null).setImplementation(Object.class);
> > > > >     dm.add(addRemove);
> > > > >     dm.remove(addRemove);
> > > > >   }
> > > > > }
> > > > >
> > > > > After starting this bundle the dm gogo command doesn't list any
> > > > components
> > > > > but the service is available in the service registry.
> > > > >
> > > > > g! dm
> > > > >
> > > > > g! inspect cap service 1
> > > > > dm.test [1] provides:
> > > > > ---------------------
> > > > > service; java.lang.Object with properties:
> > > > >    service.bundleid = 1
> > > > >    service.id = 4
> > > > >    service.scope = singleton
> > > > >
> > > > > g!
> > > > >
> > > > >
> > > > > Is this expected behavior or a bug?
> > > > >
> > > > > Regards,
> > > > >
> > > > > Bram
> > > > >
> > > >
> > >
> >
>

Re: DependencyManager: Removing component before bundle is started doesn't work

Posted by Bram Pouwelse <br...@pouwelse.com>.
I use an Activator and create a component with service dependencies, when
services are added / removed the component will add / remove additional
components. This all works but if a component is removed before the
BundleActivator#start method has completed the service will stick around in
the service registry.

Regards,
Bram

On Thu, May 26, 2016 at 8:51 AM Pierre De Rop <pi...@gmail.com>
wrote:

> but the Activator is invoked only when the bundle is started. I'm not sure
> I understand ?
> Are you invoking the Activator.init method from another bundle, like an
> extender bundle which would track all install/resolve bundles and would
> instantiate an Activator from a not started bundle and invoke it ?
>
> thanks;
> /Pierre
>
> On Thu, May 26, 2016 at 8:46 AM, Bram Pouwelse <br...@pouwelse.com> wrote:
>
> > Hi Pierre,
> >
> > Thanks for the quick reply. I should've been a bit more clear in my
> > message, the problem is when you remove a component before the bundle is
> > started (that's why I used the Activator to demonstrate the issue). Once
> > the test you've created runs the bundle is already started and all works
> as
> > expected.
> >
> > Regards,
> > Bram
> >
> > On Thu, May 26, 2016 at 8:15 AM Pierre De Rop <pi...@gmail.com>
> > wrote:
> >
> > > Hi Bram,
> > >
> > > The service should be removed from the service registry when you remove
> > the
> > > Component from DependencyManager.
> > >
> > > Now, I tried to reproduce the issue you are describing in [1], but I
> > could
> > > not (the test is OK).
> > > Can you please take a look at it in order to see if it the same kind of
> > > scenario you have ? Am i missing something ?
> > >
> > > thank you;
> > >
> > > cheers;
> > > /Pierre
> > >
> > > [1]
> > >
> > >
> >
> http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager.itest/src/org/apache/felix/dm/itest/api/AddRemoteTest.java
> > >
> > > On Wed, May 25, 2016 at 8:38 PM, Bram Pouwelse <br...@pouwelse.com>
> > wrote:
> > >
> > > > Hi,
> > > >
> > > > I have an issue with a bundle that removes a DM component before the
> > > bundle
> > > > is started. If that happens the service remains available in the
> > service
> > > > registry.
> > > >
> > > > I could reproduce this using a simple activator (which doesn't make
> any
> > > > sense but works to demonstrate the issue).
> > > >
> > > > public class Activator extends DependencyActivatorBase {
> > > >
> > > >   @Override
> > > >   public void init(BundleContext arg0, DependencyManager dm) throws
> > > > Exception {
> > > >     Component addRemove =
> > > > createComponent().setInterface(Object.class.getName(),
> > > > null).setImplementation(Object.class);
> > > >     dm.add(addRemove);
> > > >     dm.remove(addRemove);
> > > >   }
> > > > }
> > > >
> > > > After starting this bundle the dm gogo command doesn't list any
> > > components
> > > > but the service is available in the service registry.
> > > >
> > > > g! dm
> > > >
> > > > g! inspect cap service 1
> > > > dm.test [1] provides:
> > > > ---------------------
> > > > service; java.lang.Object with properties:
> > > >    service.bundleid = 1
> > > >    service.id = 4
> > > >    service.scope = singleton
> > > >
> > > > g!
> > > >
> > > >
> > > > Is this expected behavior or a bug?
> > > >
> > > > Regards,
> > > >
> > > > Bram
> > > >
> > >
> >
>

Re: DependencyManager: Removing component before bundle is started doesn't work

Posted by Pierre De Rop <pi...@gmail.com>.
but the Activator is invoked only when the bundle is started. I'm not sure
I understand ?
Are you invoking the Activator.init method from another bundle, like an
extender bundle which would track all install/resolve bundles and would
instantiate an Activator from a not started bundle and invoke it ?

thanks;
/Pierre

On Thu, May 26, 2016 at 8:46 AM, Bram Pouwelse <br...@pouwelse.com> wrote:

> Hi Pierre,
>
> Thanks for the quick reply. I should've been a bit more clear in my
> message, the problem is when you remove a component before the bundle is
> started (that's why I used the Activator to demonstrate the issue). Once
> the test you've created runs the bundle is already started and all works as
> expected.
>
> Regards,
> Bram
>
> On Thu, May 26, 2016 at 8:15 AM Pierre De Rop <pi...@gmail.com>
> wrote:
>
> > Hi Bram,
> >
> > The service should be removed from the service registry when you remove
> the
> > Component from DependencyManager.
> >
> > Now, I tried to reproduce the issue you are describing in [1], but I
> could
> > not (the test is OK).
> > Can you please take a look at it in order to see if it the same kind of
> > scenario you have ? Am i missing something ?
> >
> > thank you;
> >
> > cheers;
> > /Pierre
> >
> > [1]
> >
> >
> http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager.itest/src/org/apache/felix/dm/itest/api/AddRemoteTest.java
> >
> > On Wed, May 25, 2016 at 8:38 PM, Bram Pouwelse <br...@pouwelse.com>
> wrote:
> >
> > > Hi,
> > >
> > > I have an issue with a bundle that removes a DM component before the
> > bundle
> > > is started. If that happens the service remains available in the
> service
> > > registry.
> > >
> > > I could reproduce this using a simple activator (which doesn't make any
> > > sense but works to demonstrate the issue).
> > >
> > > public class Activator extends DependencyActivatorBase {
> > >
> > >   @Override
> > >   public void init(BundleContext arg0, DependencyManager dm) throws
> > > Exception {
> > >     Component addRemove =
> > > createComponent().setInterface(Object.class.getName(),
> > > null).setImplementation(Object.class);
> > >     dm.add(addRemove);
> > >     dm.remove(addRemove);
> > >   }
> > > }
> > >
> > > After starting this bundle the dm gogo command doesn't list any
> > components
> > > but the service is available in the service registry.
> > >
> > > g! dm
> > >
> > > g! inspect cap service 1
> > > dm.test [1] provides:
> > > ---------------------
> > > service; java.lang.Object with properties:
> > >    service.bundleid = 1
> > >    service.id = 4
> > >    service.scope = singleton
> > >
> > > g!
> > >
> > >
> > > Is this expected behavior or a bug?
> > >
> > > Regards,
> > >
> > > Bram
> > >
> >
>

Re: DependencyManager: Removing component before bundle is started doesn't work

Posted by Bram Pouwelse <br...@pouwelse.com>.
Hi Pierre,

Thanks for the quick reply. I should've been a bit more clear in my
message, the problem is when you remove a component before the bundle is
started (that's why I used the Activator to demonstrate the issue). Once
the test you've created runs the bundle is already started and all works as
expected.

Regards,
Bram

On Thu, May 26, 2016 at 8:15 AM Pierre De Rop <pi...@gmail.com>
wrote:

> Hi Bram,
>
> The service should be removed from the service registry when you remove the
> Component from DependencyManager.
>
> Now, I tried to reproduce the issue you are describing in [1], but I could
> not (the test is OK).
> Can you please take a look at it in order to see if it the same kind of
> scenario you have ? Am i missing something ?
>
> thank you;
>
> cheers;
> /Pierre
>
> [1]
>
> http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager.itest/src/org/apache/felix/dm/itest/api/AddRemoteTest.java
>
> On Wed, May 25, 2016 at 8:38 PM, Bram Pouwelse <br...@pouwelse.com> wrote:
>
> > Hi,
> >
> > I have an issue with a bundle that removes a DM component before the
> bundle
> > is started. If that happens the service remains available in the service
> > registry.
> >
> > I could reproduce this using a simple activator (which doesn't make any
> > sense but works to demonstrate the issue).
> >
> > public class Activator extends DependencyActivatorBase {
> >
> >   @Override
> >   public void init(BundleContext arg0, DependencyManager dm) throws
> > Exception {
> >     Component addRemove =
> > createComponent().setInterface(Object.class.getName(),
> > null).setImplementation(Object.class);
> >     dm.add(addRemove);
> >     dm.remove(addRemove);
> >   }
> > }
> >
> > After starting this bundle the dm gogo command doesn't list any
> components
> > but the service is available in the service registry.
> >
> > g! dm
> >
> > g! inspect cap service 1
> > dm.test [1] provides:
> > ---------------------
> > service; java.lang.Object with properties:
> >    service.bundleid = 1
> >    service.id = 4
> >    service.scope = singleton
> >
> > g!
> >
> >
> > Is this expected behavior or a bug?
> >
> > Regards,
> >
> > Bram
> >
>

Re: DependencyManager: Removing component before bundle is started doesn't work

Posted by Pierre De Rop <pi...@gmail.com>.
Hi Bram,

The service should be removed from the service registry when you remove the
Component from DependencyManager.

Now, I tried to reproduce the issue you are describing in [1], but I could
not (the test is OK).
Can you please take a look at it in order to see if it the same kind of
scenario you have ? Am i missing something ?

thank you;

cheers;
/Pierre

[1]
http://svn.apache.org/viewvc/felix/trunk/dependencymanager/org.apache.felix.dependencymanager.itest/src/org/apache/felix/dm/itest/api/AddRemoteTest.java

On Wed, May 25, 2016 at 8:38 PM, Bram Pouwelse <br...@pouwelse.com> wrote:

> Hi,
>
> I have an issue with a bundle that removes a DM component before the bundle
> is started. If that happens the service remains available in the service
> registry.
>
> I could reproduce this using a simple activator (which doesn't make any
> sense but works to demonstrate the issue).
>
> public class Activator extends DependencyActivatorBase {
>
>   @Override
>   public void init(BundleContext arg0, DependencyManager dm) throws
> Exception {
>     Component addRemove =
> createComponent().setInterface(Object.class.getName(),
> null).setImplementation(Object.class);
>     dm.add(addRemove);
>     dm.remove(addRemove);
>   }
> }
>
> After starting this bundle the dm gogo command doesn't list any components
> but the service is available in the service registry.
>
> g! dm
>
> g! inspect cap service 1
> dm.test [1] provides:
> ---------------------
> service; java.lang.Object with properties:
>    service.bundleid = 1
>    service.id = 4
>    service.scope = singleton
>
> g!
>
>
> Is this expected behavior or a bug?
>
> Regards,
>
> Bram
>