Blueprint <bean>
标记创建的实例是否可以通过使用OSGi声明式服务机制指定的服务引用自动注入?Can Blueprint beans是否有@Reference服务自动注入?
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;
@Component(service={})
public class DatabaseThing{
@Reference
public void setDataSource(DataSource ds){
...
}
如果我在@Component通过immediate=true
实例,然后我的DataSource OSGi服务注入。如果我通过蓝图<bean class="DatabaseThing">
创建实例,则不会发生自动注入。
我有一个看看白羊座源,它似乎是服务注入特定于org.apache.aries.blueprint.container.ServiceRecipe
,而不是它用于<bean>
风格的实例化...BeanRecipe
一部分。
非常感谢基督教徒 - 我尽可能多地想,但您的确认感谢。 pax-cdi注释看起来像是我所需要的 - 我只想尽可能少编写代码! –