scala – 简单的Hello World使用Akka Actors演示OSGi?

我想创建一个非常简单的(Hello Simple World)POC,它展示了将OSGi(Felix)与
Scala和Actors(Akka)集成的能力.这是我到目前为止:

$tree
.
├── bin
│   └── felix.jar
├── bundle
│   └── akka-osgi_2.10-2.2.1.jar
├── conf
    └── config.properties

$cat conf/config.properties
org.osgi.framework.storage.clean: onFirstInit
org.osgi.framework.system.packages.extra: javafx
org.osgi.framework.bootdelegation: sun.misc
felix.auto.deploy.action=install,start
felix.log.level=1
org.osgi.service.http.port=8080
obr.repository.url=http://felix.apache.org/obr/releases.xml

$java -jar bin/felix.jar
ERROR: Bundle com.typesafe.akka.osgi [1] Error starting file:/home/axiopisty/projects/test/bundle/akka-osgi_2.10-2.2.1.jar (org.osgi.framework.BundleException: Unresolved constraint in bundle com.typesafe.akka.osgi [1]: Unable to resolve 1.0: missing requirement [1.0] osgi.wiring.package; (&(osgi.wiring.package=com.typesafe.config)(version>=0.4.1)(!(version>=1.1.0))))
org.osgi.framework.BundleException: Unresolved constraint in bundle com.typesafe.akka.osgi [1]: Unable to resolve 1.0: missing requirement [1.0] osgi.wiring.package; (&(osgi.wiring.package=com.typesafe.config)(version>=0.4.1)(!(version>=1.1.0)))
        at org.apache.felix.framework.Felix.resolveBundleRevision(Felix.java:3974)
        at org.apache.felix.framework.Felix.startBundle(Felix.java:2037)
        at org.apache.felix.framework.Felix.setActiveStartLevel(Felix.java:1291)
        at org.apache.felix.framework.FrameworkStartLevelImpl.run(FrameworkStartLevelImpl.java:304)
        at java.lang.Thread.run(Thread.java:744)

我从这个错误消息中了解到没有捆绑导出osgi.wiring.package.但我不知道我需要包含哪个包来导出该包.它会来自Akka,来自Felix,还是来自其他地方?

从提供的config.properties可以看出,我试图按照akka文档中有关如何使用Configure the OSGi Framework的说明进行操作,但我不知道我是否正在按照正确的方式执行他们所说的操作.

akka文档说:

To use Akka in an OSGi environment, the
org.osgi.framework.bootdelegation property must be set to always
delegate the sun.misc package to the boot classloader instead of
resolving it through the normal OSGi class space.

如何使用Felix作为OSGi容器,并使用默认的felix启动器?

一个简单的hello world示例使用OSGi(Felix不是必需的,但是首选)和Akka Actors是我正在寻找的理想选择.如果你知道github(或其他地方)的任何东西证明这一点,我会接受这个作为答案.

最佳答案 Akka源代码树中有一个示例OSGi应用程序.希望你可以把它作为一个起点.它使用Karaf.

https://github.com/akka/akka/tree/v2.2.3/akka-samples/akka-sample-osgi-dining-hakkers

确保在稳定的标签上检查代码,例如v2.2.3,因此构建工具使用已发布的Akka稳定工件.

点赞