You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by Hubert Felber <Hu...@abacus.ch> on 2015/09/16 22:43:17 UTC

Dependency Manager does not behave as expected

Hi,

as soon as I add a ServiceDependency to my component, Felix tries to
start the service  --  before I set the implementation and before I add
the the component to the DM.

I would expect, it waits until I finally add the component to the DM?

Am I doing something wrong?

Thank you
Hubert

public void init(BundleContext bundleContext, DependencyManager
dependencyManager) throws Exception {
  Component component =  dependencyManager.createComponent();

    ServiceDependency serviceDependency = createServiceDependency();
    serviceDependency.setService(LoggingServiceImpl.class);
    serviceDependency.setRequired(true);

<<<<
    component.add(serviceDependency);   // goes to
ComponentImpl#calculateNewState() from here
>>>
    component.setImplementation(LoggingConfigService.class);
    String[] classes = new
String[]{LoggingConfigService.class.getName(),
ManagedService.class.getName()};

    component.setInterface(classes, properties);
    dependencyManager.add(component);         // thought it should go
to calculateNewState() from here ??



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: Dependency Manager does not behave as expected

Posted by Hubert Felber <Hu...@abacus.ch>.
>>> Benson Margulies <be...@basistech.com> 17.09.2015 12:39 >>>

<<you don't checkout through a viewvc link. That's just for browsing.

<< https://svn.apache.org/repos/asf/felix/sandbox/...

That helped 

Thanks
Hubert

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: Dependency Manager does not behave as expected

Posted by Benson Margulies <be...@basistech.com>.
On Thu, Sep 17, 2015 at 6:29 AM, Hubert Felber <Hu...@abacus.ch> wrote:
> Hi Pierre,
>
> Thank you for all your efforts!
>
> unfortunately I could not check it out using svn.
> I get a "Redirect cycle detected for URL 'http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager.test'"
> on both linux and windows

you don't checkout through a viewvc link. That's just for browsing.

https://svn.apache.org/repos/asf/felix/sandbox/...

>
>
> And I don´t have Eclipse installed since we work with IntelliJ Idea....
>
> nevertheless I was able to load the relevant files via http and try them.
>
> I made the same observation: as soon as a add a ServiceDependency
> then ComponentImpl#startDependencies() is called -- before I added the component
> to DM.
> Of course the service cannot be started then, the state remains inactive, but DM tries to do so and
> maybe can do this, before I finished the component configuration.
>
> I reduced the snippet:
>
>     Component comp = createComponent()
> //            .setInterface(toString(LoggingConfService.class,
> //                    ManagedService.class), null)
> //            .setImplementation(LoggingConfigServiceImpl.class)
>
> // after this, DM tries to start the service -> state remains INACTIVE
>
>             .add(createServiceDependency().setService(LoggingService.class).setRequired(true));
>
> // before I add the component to DM
>
>     System.out.println("Adding component to dependency manager");
>     dependencyManager.add(comp);
>
>
> after this, DM tries to start the service agein -> state now is WAITING_FOR_REQUIRED
> which is what I expected. The service will start as soon as the dependency is resolved.
>
>
> You should be able to see this with a breakpoint on ComponentImpl#calculateNewState
> after adding the service dependency.
> In my opinion DM should not try to start the service before I finally add the component
> to DM, but now it tries to start the service, as soon as add a ServiceDependency.
>
> Tested with DM 4.1.0
>
> Thank you again
> Hubert
>
>
>>>> Pierre De Rop <pi...@gmail.com> 17.09.2015 01:03 >>>
> Hi Hubert;
>
> I don't understand how this is possible, because a DM component initial
> state is Inactive, and remains in this state until you add it to a
> DependencyManager object.
>
> So, your service implementation can not be called in start() before you add
> the component to the dm object.
>
> Ok, in order to go ahead, I have made a (temporary) commit of a
> dependencymanager.test project in my sandbox (see [1]).
>
> So, can you please take a look at it ? I tried to follow your samples by
> creating two bundles:
>
> dependencymanager.test.log.jar -> contains the LoggingService + its
> Activator
> dependencymanager.test.logconfig.jar -> contains the LoggingConfigService
> that depends on the LoggingService.
>
> Here is the Activator for the dependencymanager.test.logconfig.jar bundle
> (I made it a bit more compact, by reusing the methods available from the
> DependencyActivatorBase)
>
> public class Activator extends DependencyActivatorBase {
>
>     @Override
>     public void init(BundleContext ctx, DependencyManager dm) throws
> Exception {
>         Component comp = createComponent()
>                 .setInterface(toString(LoggingConfigService.class,
> ManagedService.class), null)
>                 .setImplementation(LoggingConfigServiceImpl.class)
>
> .add(createServiceDependency().setService(LoggingService.class).setRequired(true));
>
>         System.out.println("Adding component to dependency manager");
>         dm.add(comp);
>     }
>
>     // Helper used to convert an array of classes to an array of class
> strings
>     String[] toString(Class<?> ... services) {
>         return Stream.of(services).map(c ->
> c.getName()).toArray(String[]::new);
>     }
>
> }
>
>
> So, can you install an Eclipse mars + java8 + latest bndtool (Use the
> dependencymanager.test directory as the eclipse workspace directory).
>
> Then open the bndtools perspective.
>
> Then click on File -> Import -> General -> Existing Projects into workspace
> -> Browse -> Ok -> Finish
>
> Then click on the dependencymanager.test/bnd.bnd file -> Run tab -> Run
> OSGi.
>
> You will then see in the console:
>
>    Adding component to dependency manager
>    LoggingConfigServiceImpl is starting.
>
> So, the "Adding component to dependency manager" message is displayed, then
> after, when the component is added to the DependencyManager "dm" object,
> then when the component is injected with the LoggingService, it is then
> started and you see the log "LoggingConfigServiceImpl is starting" message.
>
> You can also type "dm" shell command in the console:
>
> dm
>
> [8] dependencymanager.test.logconfig
>  [0] dependencymanager.test.logconf.LoggingConfigService,
> org.osgi.service.cm.ManagedService registered
>     dependencymanager.test.log.LoggingService service required available
> [9] dependencymanager.test.log
>  [1] dependencymanager.test.log.LoggingService registered
>
>
> So, maybe if you try to play with this sample, you will then be able to
> figure out what is going wrong in your own project ?
>
> hope this helps;
> /Pierre
>
> [1]
> http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager.test/
>
>
>
>
>
>
> On Wed, Sep 16, 2015 at 10:43 PM, Hubert Felber <Hu...@abacus.ch>
> wrote:
>
>> Hi,
>>
>> as soon as I add a ServiceDependency to my component, Felix tries to
>> start the service  --  before I set the implementation and before I add
>> the the component to the DM.
>>
>> I would expect, it waits until I finally add the component to the DM?
>>
>> Am I doing something wrong?
>>
>> Thank you
>> Hubert
>>
>> public void init(BundleContext bundleContext, DependencyManager
>> dependencyManager) throws Exception {
>>   Component component =  dependencyManager.createComponent();
>>
>>     ServiceDependency serviceDependency = createServiceDependency();
>>     serviceDependency.setService(LoggingServiceImpl.class);
>>     serviceDependency.setRequired(true);
>>
>> <<<<
>>     component.add(serviceDependency);   // goes to
>> ComponentImpl#calculateNewState() from here
>> >>>
>>     component.setImplementation(LoggingConfigService.class);
>>     String[] classes = new
>> String[]{LoggingConfigService.class.getName(),
>> ManagedService.class.getName()};
>>
>>     component.setInterface(classes, properties);
>>     dependencyManager.add(component);         // thought it should go
>> to calculateNewState() from here ??
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
>> For additional commands, e-mail: users-help@felix.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: Dependency Manager does not behave as expected

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

I'm sorry but don't understand when you say:

" ... DM should not try to start the service before I finally add the
component
to DM, but now it tries to start the service, as soon as add a
ServiceDependency ..."

Indeed, DM never do that. The service component is started only after you
add it to the DependencyManager. If you really observe this, then please
open a JIRA issue and a mini project that reproduces this issue.

Now, let's talk about what you observed: when a Dependency is added before
the Component is added to the DependencyManager object, the task that is
scheduled in the Component.add(Dependency) method registers the dependency
(ies) and calls the handleChange method, which in turns calls
calculateNewState. I do agree with this, but all this is made by design.
And if the Component is not yet added, the component won't be started at
all since we remain in the Inactive state.

We systematically calls handleChange when a Dependency is added, because if
some dependencies are added dynamically after the component is added (and
probably started), then we have to recalculate the state changes (if you
add a missing dependency to a started component, then it has to be stopped).

And we do all this inside the runnable task that is scheduled in the
component executor because all  events (like dynamic dependencies that are
added after the Component is added, or service injections, or service
removal, or bundle start/stop events, etc ...) are handled in a lock-free
way, through the SerialExecutor. This reduces the complexity, avoid
potential dead locks, and we want to minimize the usage of tricky
synchronization logic. We just want to systematically react to events
through the Executor, like in an Actor based thread-model.

I hope that my response will help.

Again, if you have a working sample code that demonstrates that a component
is started before it is actually added to the DependencyManager, then
please open a jira issue and we'll investigate it.

kind regards;
/Pierre





On Thu, Sep 17, 2015 at 12:29 PM, Hubert Felber <Hu...@abacus.ch>
wrote:

> Hi Pierre,
>
> Thank you for all your efforts!
>
> unfortunately I could not check it out using svn.
> I get a "Redirect cycle detected for URL '
> http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager.test'"
> on both linux and windows
>
>
> And I don´t have Eclipse installed since we work with IntelliJ Idea....
>
> nevertheless I was able to load the relevant files via http and try them.
>
> I made the same observation: as soon as a add a ServiceDependency
> then ComponentImpl#startDependencies() is called -- before I added the
> component
> to DM.
> Of course the service cannot be started then, the state remains inactive,
> but DM tries to do so and
> maybe can do this, before I finished the component configuration.
>
> I reduced the snippet:
>
>     Component comp = createComponent()
> //            .setInterface(toString(LoggingConfService.class,
> //                    ManagedService.class), null)
> //            .setImplementation(LoggingConfigServiceImpl.class)
>
> // after this, DM tries to start the service -> state remains INACTIVE
>
>
> .add(createServiceDependency().setService(LoggingService.class).setRequired(true));
>
> // before I add the component to DM
>
>     System.out.println("Adding component to dependency manager");
>     dependencyManager.add(comp);
>
>
> after this, DM tries to start the service agein -> state now is
> WAITING_FOR_REQUIRED
> which is what I expected. The service will start as soon as the dependency
> is resolved.
>
>
> You should be able to see this with a breakpoint on
> ComponentImpl#calculateNewState
> after adding the service dependency.
> In my opinion DM should not try to start the service before I finally add
> the component
> to DM, but now it tries to start the service, as soon as add a
> ServiceDependency.
>
> Tested with DM 4.1.0
>
> Thank you again
> Hubert
>
>
> >>> Pierre De Rop <pi...@gmail.com> 17.09.2015 01:03 >>>
> Hi Hubert;
>
> I don't understand how this is possible, because a DM component initial
> state is Inactive, and remains in this state until you add it to a
> DependencyManager object.
>
> So, your service implementation can not be called in start() before you add
> the component to the dm object.
>
> Ok, in order to go ahead, I have made a (temporary) commit of a
> dependencymanager.test project in my sandbox (see [1]).
>
> So, can you please take a look at it ? I tried to follow your samples by
> creating two bundles:
>
> dependencymanager.test.log.jar -> contains the LoggingService + its
> Activator
> dependencymanager.test.logconfig.jar -> contains the LoggingConfigService
> that depends on the LoggingService.
>
> Here is the Activator for the dependencymanager.test.logconfig.jar bundle
> (I made it a bit more compact, by reusing the methods available from the
> DependencyActivatorBase)
>
> public class Activator extends DependencyActivatorBase {
>
>     @Override
>     public void init(BundleContext ctx, DependencyManager dm) throws
> Exception {
>         Component comp = createComponent()
>                 .setInterface(toString(LoggingConfigService.class,
> ManagedService.class), null)
>                 .setImplementation(LoggingConfigServiceImpl.class)
>
>
> .add(createServiceDependency().setService(LoggingService.class).setRequired(true));
>
>         System.out.println("Adding component to dependency manager");
>         dm.add(comp);
>     }
>
>     // Helper used to convert an array of classes to an array of class
> strings
>     String[] toString(Class<?> ... services) {
>         return Stream.of(services).map(c ->
> c.getName()).toArray(String[]::new);
>     }
>
> }
>
>
> So, can you install an Eclipse mars + java8 + latest bndtool (Use the
> dependencymanager.test directory as the eclipse workspace directory).
>
> Then open the bndtools perspective.
>
> Then click on File -> Import -> General -> Existing Projects into workspace
> -> Browse -> Ok -> Finish
>
> Then click on the dependencymanager.test/bnd.bnd file -> Run tab -> Run
> OSGi.
>
> You will then see in the console:
>
>    Adding component to dependency manager
>    LoggingConfigServiceImpl is starting.
>
> So, the "Adding component to dependency manager" message is displayed, then
> after, when the component is added to the DependencyManager "dm" object,
> then when the component is injected with the LoggingService, it is then
> started and you see the log "LoggingConfigServiceImpl is starting" message.
>
> You can also type "dm" shell command in the console:
>
> dm
>
> [8] dependencymanager.test.logconfig
>  [0] dependencymanager.test.logconf.LoggingConfigService,
> org.osgi.service.cm.ManagedService registered
>     dependencymanager.test.log.LoggingService service required available
> [9] dependencymanager.test.log
>  [1] dependencymanager.test.log.LoggingService registered
>
>
> So, maybe if you try to play with this sample, you will then be able to
> figure out what is going wrong in your own project ?
>
> hope this helps;
> /Pierre
>
> [1]
> http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager.test/
>
>
>
>
>
>
> On Wed, Sep 16, 2015 at 10:43 PM, Hubert Felber <Hu...@abacus.ch>
> wrote:
>
> > Hi,
> >
> > as soon as I add a ServiceDependency to my component, Felix tries to
> > start the service  --  before I set the implementation and before I add
> > the the component to the DM.
> >
> > I would expect, it waits until I finally add the component to the DM?
> >
> > Am I doing something wrong?
> >
> > Thank you
> > Hubert
> >
> > public void init(BundleContext bundleContext, DependencyManager
> > dependencyManager) throws Exception {
> >   Component component =  dependencyManager.createComponent();
> >
> >     ServiceDependency serviceDependency = createServiceDependency();
> >     serviceDependency.setService(LoggingServiceImpl.class);
> >     serviceDependency.setRequired(true);
> >
> > <<<<
> >     component.add(serviceDependency);   // goes to
> > ComponentImpl#calculateNewState() from here
> > >>>
> >     component.setImplementation(LoggingConfigService.class);
> >     String[] classes = new
> > String[]{LoggingConfigService.class.getName(),
> > ManagedService.class.getName()};
> >
> >     component.setInterface(classes, properties);
> >     dependencyManager.add(component);         // thought it should go
> > to calculateNewState() from here ??
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> > For additional commands, e-mail: users-help@felix.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>
>

Re: Dependency Manager does not behave as expected

Posted by Hubert Felber <Hu...@abacus.ch>.
Hi Pierre,

Thank you for all your efforts!

unfortunately I could not check it out using svn.
I get a "Redirect cycle detected for URL 'http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager.test'" 
on both linux and windows


And I don´t have Eclipse installed since we work with IntelliJ Idea....

nevertheless I was able to load the relevant files via http and try them.

I made the same observation: as soon as a add a ServiceDependency
then ComponentImpl#startDependencies() is called -- before I added the component
to DM.
Of course the service cannot be started then, the state remains inactive, but DM tries to do so and 
maybe can do this, before I finished the component configuration.

I reduced the snippet:

    Component comp = createComponent()
//            .setInterface(toString(LoggingConfService.class,
//                    ManagedService.class), null)
//            .setImplementation(LoggingConfigServiceImpl.class)

// after this, DM tries to start the service -> state remains INACTIVE

            .add(createServiceDependency().setService(LoggingService.class).setRequired(true));

// before I add the component to DM

    System.out.println("Adding component to dependency manager");
    dependencyManager.add(comp);


after this, DM tries to start the service agein -> state now is WAITING_FOR_REQUIRED
which is what I expected. The service will start as soon as the dependency is resolved.


You should be able to see this with a breakpoint on ComponentImpl#calculateNewState 
after adding the service dependency.
In my opinion DM should not try to start the service before I finally add the component
to DM, but now it tries to start the service, as soon as add a ServiceDependency. 

Tested with DM 4.1.0

Thank you again
Hubert


>>> Pierre De Rop <pi...@gmail.com> 17.09.2015 01:03 >>>
Hi Hubert;

I don't understand how this is possible, because a DM component initial
state is Inactive, and remains in this state until you add it to a
DependencyManager object.

So, your service implementation can not be called in start() before you add
the component to the dm object.

Ok, in order to go ahead, I have made a (temporary) commit of a
dependencymanager.test project in my sandbox (see [1]).

So, can you please take a look at it ? I tried to follow your samples by
creating two bundles:

dependencymanager.test.log.jar -> contains the LoggingService + its
Activator
dependencymanager.test.logconfig.jar -> contains the LoggingConfigService
that depends on the LoggingService.

Here is the Activator for the dependencymanager.test.logconfig.jar bundle
(I made it a bit more compact, by reusing the methods available from the
DependencyActivatorBase)

public class Activator extends DependencyActivatorBase {

    @Override
    public void init(BundleContext ctx, DependencyManager dm) throws
Exception {
        Component comp = createComponent()
                .setInterface(toString(LoggingConfigService.class,
ManagedService.class), null)
                .setImplementation(LoggingConfigServiceImpl.class)

.add(createServiceDependency().setService(LoggingService.class).setRequired(true));

        System.out.println("Adding component to dependency manager");
        dm.add(comp);
    }

    // Helper used to convert an array of classes to an array of class
strings
    String[] toString(Class<?> ... services) {
        return Stream.of(services).map(c ->
c.getName()).toArray(String[]::new);
    }

}


So, can you install an Eclipse mars + java8 + latest bndtool (Use the
dependencymanager.test directory as the eclipse workspace directory).

Then open the bndtools perspective.

Then click on File -> Import -> General -> Existing Projects into workspace
-> Browse -> Ok -> Finish

Then click on the dependencymanager.test/bnd.bnd file -> Run tab -> Run
OSGi.

You will then see in the console:

   Adding component to dependency manager
   LoggingConfigServiceImpl is starting.

So, the "Adding component to dependency manager" message is displayed, then
after, when the component is added to the DependencyManager "dm" object,
then when the component is injected with the LoggingService, it is then
started and you see the log "LoggingConfigServiceImpl is starting" message.

You can also type "dm" shell command in the console:

dm

[8] dependencymanager.test.logconfig
 [0] dependencymanager.test.logconf.LoggingConfigService,
org.osgi.service.cm.ManagedService registered
    dependencymanager.test.log.LoggingService service required available
[9] dependencymanager.test.log
 [1] dependencymanager.test.log.LoggingService registered


So, maybe if you try to play with this sample, you will then be able to
figure out what is going wrong in your own project ?

hope this helps;
/Pierre

[1]
http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager.test/ 






On Wed, Sep 16, 2015 at 10:43 PM, Hubert Felber <Hu...@abacus.ch>
wrote:

> Hi,
>
> as soon as I add a ServiceDependency to my component, Felix tries to
> start the service  --  before I set the implementation and before I add
> the the component to the DM.
>
> I would expect, it waits until I finally add the component to the DM?
>
> Am I doing something wrong?
>
> Thank you
> Hubert
>
> public void init(BundleContext bundleContext, DependencyManager
> dependencyManager) throws Exception {
>   Component component =  dependencyManager.createComponent();
>
>     ServiceDependency serviceDependency = createServiceDependency();
>     serviceDependency.setService(LoggingServiceImpl.class);
>     serviceDependency.setRequired(true);
>
> <<<<
>     component.add(serviceDependency);   // goes to
> ComponentImpl#calculateNewState() from here
> >>>
>     component.setImplementation(LoggingConfigService.class);
>     String[] classes = new
> String[]{LoggingConfigService.class.getName(),
> ManagedService.class.getName()};
>
>     component.setInterface(classes, properties);
>     dependencyManager.add(component);         // thought it should go
> to calculateNewState() from here ??
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org 
> For additional commands, e-mail: users-help@felix.apache.org 
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: Dependency Manager does not behave as expected

Posted by Pierre De Rop <pi...@gmail.com>.
Hi Hubert;

I don't understand how this is possible, because a DM component initial
state is Inactive, and remains in this state until you add it to a
DependencyManager object.

So, your service implementation can not be called in start() before you add
the component to the dm object.

Ok, in order to go ahead, I have made a (temporary) commit of a
dependencymanager.test project in my sandbox (see [1]).

So, can you please take a look at it ? I tried to follow your samples by
creating two bundles:

dependencymanager.test.log.jar -> contains the LoggingService + its
Activator
dependencymanager.test.logconfig.jar -> contains the LoggingConfigService
that depends on the LoggingService.

Here is the Activator for the dependencymanager.test.logconfig.jar bundle
(I made it a bit more compact, by reusing the methods available from the
DependencyActivatorBase)

public class Activator extends DependencyActivatorBase {

    @Override
    public void init(BundleContext ctx, DependencyManager dm) throws
Exception {
        Component comp = createComponent()
                .setInterface(toString(LoggingConfigService.class,
ManagedService.class), null)
                .setImplementation(LoggingConfigServiceImpl.class)

.add(createServiceDependency().setService(LoggingService.class).setRequired(true));

        System.out.println("Adding component to dependency manager");
        dm.add(comp);
    }

    // Helper used to convert an array of classes to an array of class
strings
    String[] toString(Class<?> ... services) {
        return Stream.of(services).map(c ->
c.getName()).toArray(String[]::new);
    }

}


So, can you install an Eclipse mars + java8 + latest bndtool (Use the
dependencymanager.test directory as the eclipse workspace directory).

Then open the bndtools perspective.

Then click on File -> Import -> General -> Existing Projects into workspace
-> Browse -> Ok -> Finish

Then click on the dependencymanager.test/bnd.bnd file -> Run tab -> Run
OSGi.

You will then see in the console:

   Adding component to dependency manager
   LoggingConfigServiceImpl is starting.

So, the "Adding component to dependency manager" message is displayed, then
after, when the component is added to the DependencyManager "dm" object,
then when the component is injected with the LoggingService, it is then
started and you see the log "LoggingConfigServiceImpl is starting" message.

You can also type "dm" shell command in the console:

dm

[8] dependencymanager.test.logconfig
 [0] dependencymanager.test.logconf.LoggingConfigService,
org.osgi.service.cm.ManagedService registered
    dependencymanager.test.log.LoggingService service required available
[9] dependencymanager.test.log
 [1] dependencymanager.test.log.LoggingService registered


So, maybe if you try to play with this sample, you will then be able to
figure out what is going wrong in your own project ?

hope this helps;
/Pierre

[1]
http://svn.apache.org/viewvc/felix/sandbox/pderop/dependencymanager.test/






On Wed, Sep 16, 2015 at 10:43 PM, Hubert Felber <Hu...@abacus.ch>
wrote:

> Hi,
>
> as soon as I add a ServiceDependency to my component, Felix tries to
> start the service  --  before I set the implementation and before I add
> the the component to the DM.
>
> I would expect, it waits until I finally add the component to the DM?
>
> Am I doing something wrong?
>
> Thank you
> Hubert
>
> public void init(BundleContext bundleContext, DependencyManager
> dependencyManager) throws Exception {
>   Component component =  dependencyManager.createComponent();
>
>     ServiceDependency serviceDependency = createServiceDependency();
>     serviceDependency.setService(LoggingServiceImpl.class);
>     serviceDependency.setRequired(true);
>
> <<<<
>     component.add(serviceDependency);   // goes to
> ComponentImpl#calculateNewState() from here
> >>>
>     component.setImplementation(LoggingConfigService.class);
>     String[] classes = new
> String[]{LoggingConfigService.class.getName(),
> ManagedService.class.getName()};
>
>     component.setInterface(classes, properties);
>     dependencyManager.add(component);         // thought it should go
> to calculateNewState() from here ??
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>
>