I am using felix osgi + ds + weld cdi + pax cdi. So I have the following service:
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.ServiceScope;
@Component(
immediate = false,
property={"label=stub"},
scope=ServiceScope.PROTOTYPE
)
public class ServiceImpl implements ServiceI{
@Override
public String getMyString() {
Component t=null;
return "This is my string:"+t;
}
}
To generate ds.xml file I use maven-bundle-plugin as I know this is modern way of generating ds xml files. So everything seems to work. Ds xml file is generated by maven plugin and put into OSGI-INF. I decided to check what the felix will do if I delete this ds.xml file. So I deleted this xml file and cleaned the osgi cache. And I was very suprised with the results. The service still works and successfully injected. I just get message:Component descriptor entry 'OSGI-INF/....xml' not found. Besides I thought that @Component annotation is removed after compilation. That's why I didn't install org.osgi.service.component bundle in my osgi. However everything works fine and all bundles are resolved.
So the questions -
- why do DS services work without xml file?
- why my osgi framework doesn't need
org.osgi.service.component.annotations.Component
? Felix bundle hasorg.osgi.service.component.annotations
package but notorg.osgi.service.component.annotations.Component
annotation.