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註釋看起來像是我所需要的 - 我只想盡可能少編寫代碼! –