Aries 托管服务工厂也管理物业吗?
我在 Servicemix 4.3.1 中使用 Apache Aries 0.2 并创建 cm:managed-service-factory。使用 .cfg 文件创建服务工作正常(#ARIES-584 除外),但 .cfg 文件中的属性不会注入到服务对象中。它们确实在 ConfigAdmin 中得到了正确的设置,只是我的 bean setter 方法永远不会被调用来获取我的配置文件中的值。
我想我也许应该使用 cm:managed-properties 或类似的东西嵌套在我的托管服务工厂中,但这需要一个单独的 pid,所以看起来不对。
如果我不放入属性标签,则不会设置任何值。使用属性标签,则仅设置默认值,而不设置实际的配置文件值。
除了 blueprint-sample.xml,它不显示托管服务工厂内的托管属性。我确实一直在尝试使用 Servicemix,但到处都有文档缺失、功能损坏或缺失,或者影响核心功能的错误。
spring 和 gemini 文档表明他们的托管服务-工厂实现也应该充当托管属性。
foo.xml:
<blueprint>
<cm:managed-service-factory id="myfoo-msf" factory-pid="my.msf" interface="my.IFoo">
<cm:managed-component class="my.Foo">
<property name="name" value="default />
</cm:managed-component>
</cm:managed-service-factory>
</blueprint>
IFoo.java
package my;
public interface IFoo {
public String getName();
public void setName(String name);
}
Foo.java
package my;
public class Foo implements IFoo {
private String name;
public void setName(String name) {
this.name = name;
System.out.println("name set to: " + name);
}
public String getName() {
return name;
}
}
my.msf-1.cfg
name=name1
my.msf-2.cfg
name=name2
System.out
name set to default
name set to default
config:proplist
service.pid = my.msf.xxxxxxx-xx-xx-xxxxxxxxxxxxxxx
name = name1
service.factoryPid = my.msf
service.pid = my.msf.yyyyyyy-yy-yy-yyyyyyyyyyyyyyy
name = name2
service.factoryPid = my.msf
I'm using Apache Aries 0.2 in Servicemix 4.3.1 and creating a cm:managed-service-factory. Creation of the services with .cfg files works fine (except for #ARIES-584), but the properties from the .cfg file do not get injected into the service object. They do get set properly in ConfigAdmin, just my bean setter methods never get called for the values in my config file.
I was thinking I should maybe use a cm:managed-properties or something like that nested inside my managed-service-factory, but that would require a separate pid, so doesn't seem right.
If I don't put the property tag in, then no value ever gets set. With the property tag, then just the default value gets set, but never the actual config file value.
I can't find any documentation for usage of the Aries CM subproject, except for blueprint-sample.xml, which doesn't show managed properties inside a managed service factory. I've really been trying to use Servicemix, but around every corner there is missing documentation, broken or missing features, or bugs that affect core functionality.
Both the spring and gemini documentation indicate that their managed-service-factory implementations should also function as managed-properties.
foo.xml:
<blueprint>
<cm:managed-service-factory id="myfoo-msf" factory-pid="my.msf" interface="my.IFoo">
<cm:managed-component class="my.Foo">
<property name="name" value="default />
</cm:managed-component>
</cm:managed-service-factory>
</blueprint>
IFoo.java
package my;
public interface IFoo {
public String getName();
public void setName(String name);
}
Foo.java
package my;
public class Foo implements IFoo {
private String name;
public void setName(String name) {
this.name = name;
System.out.println("name set to: " + name);
}
public String getName() {
return name;
}
}
my.msf-1.cfg
name=name1
my.msf-2.cfg
name=name2
System.out
name set to default
name set to default
config:proplist
service.pid = my.msf.xxxxxxx-xx-xx-xxxxxxxxxxxxxxx
name = name1
service.factoryPid = my.msf
service.pid = my.msf.yyyyyyy-yy-yy-yyyyyyyyyyyyyyy
name = name2
service.factoryPid = my.msf
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我相信您必须在托管组件元素中添加一行。
默认值确实会被覆盖 cfg 文件中的任何内容。如果重要的话,将调用默认属性值设置器,然后调用具有 cfg 中的值的相同属性设置器。
在本例中,我使用容器管理的更新策略。但您可以使用组件管理。
这对我来说似乎有点多余,而且品味很差。当我在上面已经这样做时,为什么还需要在我的 bean 中设置另一个具有空白持久 id 的托管属性?也许有更好的方法,但这似乎有效。
此外,没有明显的方法来影响所公布的服务属性。例如,我们可能希望有一个约定,即任何以 service:xxx 开头的 cfg 属性都将传递到服务属性。
更新:Apache Aries 测试非常有帮助。它们可以在这里找到 http://aries.apache.org/downloads/currentrelease.html。特别看一下用于配置管理的 org.apache.aries.blueprint.cm 。在测试文件夹中有一些示例。它表明,除了上面显示的 cm:managed-component 中的 cm:managed-properties 子元素之外,还可以选择在 service-properties 中包含 cm:cm-properties 元素。
I believe you have to add one extra line within your managed-component element.
The default value will indeed be overwritten whatever is in your cfg file. If it matters,the default property value setter will be invoked, followed by the same property setter with the value from the cfg.
In this case I have used container-managed for update strategy. But you could use component managed.
This seems kind of redundant to me and in poor taste. Why do I need to set another managed-properties within my bean with a blank persistent id when I have already done so above? Maybe there is a better way but this seems to work.
Also, there is no obvious way to affect the Service Properties that are advertised. For example, we might want to have a convention that any cfg properties that start with service:xxx would be passed through to the Service properties.
Update: The Apache Aries tests are pretty helpful. They can be found here http://aries.apache.org/downloads/currentrelease.html. In particular take a look at the one for configuration management, org.apache.aries.blueprint.cm . In the test folder it has some examples. It shows that in addition to the cm:managed-properties child element within the cm:managed-component shown above, there is also an option to have a cm:cm-properties element within the service-properties.