【发布时间】:2016-11-29 16:21:54
【问题描述】:
我有一个包含多个组件的 OSGi 包,我想激活/停用同一包中其他组件的组件。
我从下面的代码中得到了BundleContext:
import aQute.bnd.annotation.component.Activate;
import aQute.bnd.annotation.component.Component;
import aQute.bnd.annotation.component.Deactivate;
@Activate
public void activate(Map<String, Object> properties) {
BundleContext bundleContext = FrameworkUtil.getBundle(MyComponent.class).getBundleContext();
}
但是我怎样才能获得ComponentContext 以便我可以使用enableComponent 或disableComponent?
【问题讨论】:
-
@Golden Gate:我批准了您的编辑。我想指出,如果您要从帖子中删除姓名(这很好),您还应该删除“谢谢”、“嗨”等。请参阅here 进行讨论,如果你是有兴趣。
-
您可能希望切换到标准 OSGi 注释,因为启发标准化注释的 bnd 注释将被弃用。
标签: java osgi osgi-bundle