使用 dmlambda 时不调用 Apache Felix 停止方法

Apache Felix stop method is not called when using dmlambda

我们在 DM Lambda (1.1.1) 中遇到了一个问题,即当捆绑包停止时,捆绑包的停止方法没有被调用。我有一个包含此问题的简单示例的可执行 jar。该示例包含两个自定义包,一个使用标准 DM 语法,其中按预期调用停止。第二个自定义包使用新的 DM Lambda 语法,下面包含激活器代码。第二个包 (org.syntech.examples.dmlambda) 不会导致停止调用。

我不得不认为我只是遗漏了一些明显的东西,但尽我所能,我无法调用启用 DM Lambda 的捆绑包的停止方法。任何帮助或指导将不胜感激。我们非常喜欢新的 DM Lambda 语法,并希望继续使用它。

示例:使用 DM Lambda 语法的简单激活器,它没有按预期调用“停止”方法。我试过使用默认值并明确指定回调,似乎没有任何效果。

@Override
protected void init(BundleContext ctx, DependencyManager dm) throws Exception {
    component(comp -> comp.impl(ExampleServiceUsingDmLambda.class)
            .start("start")
            .stop("stop")
            .provides(ExampleServiceUsingDmLambda.class));
}

以下是示例 JAR 中包含的包版本。

____________________________
Welcome to Apache Felix Gogo

g! lb
START LEVEL 1
   ID|State      |Level|Name
    0|Active     |    0|System Bundle (5.6.10)|5.6.10
    1|Active     |    1|osgi.core (6.0.0.201403061837)|6.0.0.201403061837
    2|Active     |    1|Apache Felix Log Service (1.0.1)|1.0.1
    3|Active     |    1|Apache Felix Metatype Service (1.1.6)|1.1.6
    4|Active     |    1|Apache Felix Configuration Admin Service (1.8.16)|1.8.16
    5|Active     |    1|Apache Felix Dependency Manager (4.4.1)|4.4.1
    6|Active     |    1|org.apache.felix.dependencymanager.lambda (1.1.1)|1.1.1
    7|Active     |    1|Apache Felix Gogo Command (1.0.2)|1.0.2
    8|Active     |    1|Apache Felix Gogo Runtime (1.0.10)|1.0.10
    9|Active     |    1|Apache Felix Gogo Shell (1.0.0)|1.0.0
   10|Active     |    1|Apache Felix Remote Shell (1.2.0)|1.2.0
   11|Active     |    1|Apache Felix Dependency Manager Shell (4.0.6)|4.0.6
   12|Active     |    1|org.syntech.examples.dmlambda (1.0.0)|1.0.0
   13|Active     |    1|org.syntech.examples.dmstandard (1.0.0)|1.0.0

我还有一个可执行 JAR 和示例项目,我可以发送它们来说明问题。任何帮助或指导将不胜感激。

您的示例似乎是正确的,但 org.apache.felix.dependencymanager.lambda 1.1.1 版本中存在错误。

我刚刚修复它 (see the felix JIRA issue)。

我也在jira问题中附上了补丁which you can find here.