我想从OSGI包中启动OSGI包.正如您所看到的,此代码通过从目录部署它来启动bundle:
private void installStartBundle(BundleContext bc, String location, String name) throws BundleException
        {
            debug("installing " + location + "...");
            Bundle[] all = bc.getBundles();
            for (Bundle bundle : all)
            {
                String l = bundle.getLocation();
                if (l.indexOf(name) != -1)
                {
                    debug("already installed bundle " + bundle.getBundleId() + "|" + bundle.getLocation() + ">" + bundle.getSymbolicName());
                    return;
                }
            }
            Bundle b = bc.installBundle(location);
            debug("starting " + b.getSymbolicName());
            b.start();
        }
我注意到一个问题:例如,我有一个包含xml配置文件和主包的包,它通过将其部署到Felix并将包访问到xml包中来加载xml配置文件.
我可以从bundle成功安装bundle,但是依赖包的导出包不可访问.也许部署过程太慢,捆绑加载器无法找到导出的包.知道如何解决这个问题吗?
PS你能告诉我如何检查一个捆绑包是否在Felix中成功部署?
在Google浏览器上搜索了很多,我知道它用于测试和构建OSGI包.我还没弄清楚如何处理Apache Karaf以及如何使用它我也不太了解OSGI包的需求.
此外,我也想知道以下疑虑的答案:
我必须为学校创建一个项目.我们想要创建一个监控传感器的系统.由于传感器发展很快,他们有可能在几年内使用其他传感器.要捕获该问题,我们希望创建一个允许用户编写插件来监控传感器的系统.
我正在寻找不同的框架,主要是OSGI.
有人能告诉我Apache Felix和OSGI之间的区别吗?OSGI还活跃吗?
谢谢!
我使用Apache Felix来实现osgi包并将其用作嵌入式Felix框架来调用boundle
这是我的 Maven 插件来构建 MANIFEST.MF :
<plugin>
            <groupId>org.apache.felix</groupId>
            <artifactId>maven-bundle-plugin</artifactId>
            <version>3.5.0</version>
            <extensions>true</extensions>
            <configuration>
                <instructions>
                    <Embed-Dependency>*;scope=compile|runtime</Embed-Dependency>
                    <Bundle-Activator>a.b.c.osgi.activator.Activator</Bundle-Activator>
                </instructions>
            </configuration>
        </plugin>
我构建项目,然后在嵌入的 felix 中使用 jar 文件,如下所示
BundleContext bundleContext = f.getBundleContext();
    Bundle bundle = bundleContext.installBundle(
            "file:/home/eclipse_workSpace/my-module/target/abc-1.1.0.jar");)
    String bName = bundle.getLocation();
    bundle.getRegisteredServices();
    bundle.getState();
    /* Bundle[] bls = bundleContext.getBundles(); */
    System.out.println("starting bundle " + bName);
    bundle.start();
当我开始 Boundle 时,我遇到了这个异常
线程“main”中的异常 org.osgi.framework.BundleException:无法解析 abc [1](R 1.0):缺少要求 [abc [1](R 1.0)] osgi.wiring.package;(&(osgi.wiring.package=com.google.common.base)(version>=21.0.0)(!(version>=22.0.0))) 未解决的要求:[[abc [1](R 1.0) ] osgi.wiring.package;(&(osgi.wiring.package=com.google.common.base)(版本>=21.0.0)(!(版本>=22.0.0)))]
我应该怎么做才能解决这个问题?
apache-felix ×4
osgi ×4
java ×2
osgi-bundle ×2
apache-karaf ×1
bundle ×1
karaf ×1
modularity ×1