Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Equinox » declarative services dependency injection questions
declarative services dependency injection questions [message #104106] Sun, 20 January 2008 12:05
David Donohue is currently offline David DonohueFriend
Messages: 104
Registered: July 2009
Senior Member
I am having a perplexing problem, that DS is not working as I expected.

I have a bundle org.bundleA, which declares both a service and a component.

<?xml version="1.0"?>
<component name="ComponentA" immediate="true">
<implementation class=""/>
<provide interface=""/>

<?xml version="1.0"?>
<component name="ServiceA" immediate="true">
<implementation class=""/>
<reference name="IComponent"
policy="dynamic" />

I test this in the bundle's Activator.

public void start(BundleContext context) throws Exception {
ServiceA serviceA = new ServiceA();
System.out.println("Created ServiceA with " + serviceA.countComponents() + " components");

and I get this output
Created ServiceA with 0 components
Running ServiceA.addComponent()

So my first question is: is this the order in which this should happen? Note that the componets do not seem to be available until later (too late).

So I move the above start method to a 2nd bundle's Activator instead. And here is the output

Created ServiceA with 0 components

Apparently the DS did not kick in and inject the dependencies when I create a ServiceA object from a 2nd bundle.

Second question: Is this the expected behavior? Can only the bundle which declares the component and/or service use them?

Previous Topic:System Resources Monitoring
Next Topic:Activator invalid problem
Goto Forum:

Current Time: Tue Dec 07 04:12:55 GMT 2021

Powered by FUDForum. Page generated in 0.01894 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top