依赖管理器的 OSGi 注入
OSGi injection of dependencymanager
我正在尝试将 DependencyManager
注入到我的组件中。 BundleContext
被注入但 DependencyManager
不是 (@Inject
)。我做错了什么?
import org.apache.felix.dm.DependencyManager;
import org.apache.felix.dm.annotation.api.Component;
import org.apache.felix.dm.annotation.api.Init;
import org.apache.felix.dm.annotation.api.Inject;
import org.apache.felix.dm.annotation.api.Start;
import org.osgi.framework.BundleContext;
@Component
public class InjectionExample
{
@Inject
BundleContext bundleContext;
@Inject
DependencyManager manager;
@Init
void init()
{
System.out.println("Bundle Context: " + bundleContext);
System.out.println("Manager: " + manager);
}
@Start
void start()
{
System.out.println("start");
}
}
我找到了 "problem"。在我的项目中,使用了 2 个不同版本的依赖管理器。强制使用一个版本后它可以工作。
我正在尝试将 DependencyManager
注入到我的组件中。 BundleContext
被注入但 DependencyManager
不是 (@Inject
)。我做错了什么?
import org.apache.felix.dm.DependencyManager;
import org.apache.felix.dm.annotation.api.Component;
import org.apache.felix.dm.annotation.api.Init;
import org.apache.felix.dm.annotation.api.Inject;
import org.apache.felix.dm.annotation.api.Start;
import org.osgi.framework.BundleContext;
@Component
public class InjectionExample
{
@Inject
BundleContext bundleContext;
@Inject
DependencyManager manager;
@Init
void init()
{
System.out.println("Bundle Context: " + bundleContext);
System.out.println("Manager: " + manager);
}
@Start
void start()
{
System.out.println("start");
}
}
我找到了 "problem"。在我的项目中,使用了 2 个不同版本的依赖管理器。强制使用一个版本后它可以工作。