简体   繁体   English

Aries管理服务工厂是否也管理物业?

[英]Does Aries managed-service-factory also manage properties?

I'm using Apache Aries 0.2 in Servicemix 4.3.1 and creating a cm:managed-service-factory. 我在Servicemix 4.3.1中使用Apache Aries 0.2并创建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. 使用.cfg文件创建服务工作正常( #ARIES-584除外),但.cfg文件中的属性不会注入服务对象。 They do get set properly in ConfigAdmin, just my bean setter methods never get called for the values in my config file. 它们确实在ConfigAdmin中正确设置,只是我的bean setter方法永远不会调用我的配置文件中的值。

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. 我以为我应该使用cm:托管属性或类似嵌套在我的托管服务工厂中的东西,但这需要一个单独的pid,所以似乎不对。

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. 我找不到任何使用Aries CM子项目的文档,但blueprint-sample.xml除外,它没有显示托管服务工厂内的托管属性。 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. 我一直在尝试使用Servicemix,但是在每个角落都缺少文档,功能损坏或丢失,或者影响核心功能的错误。

Both the spring and gemini documentation indicate that their managed-service-factory implementations should also function as managed-properties. springgemini文档都指出他们的托管服务工厂实现也应该作为托管属性。


foo.xml: 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 IFoo.java

package my;
public interface IFoo {
  public String getName();
  public void setName(String name);
}

Foo.java 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 my.msf-1.cfg

name=name1

my.msf-2.cfg my.msf-2.cfg

name=name2

System.out System.out的

name set to default
name set to default

config:proplist 配置: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 believe you have to add one extra line within your managed-component element. 我相信你必须在managed-component元素中添加一行。

<blueprint>
  <cm:managed-service-factory id="myfoo-msf" factory-pid="my.msf" interface="my.IFoo">
    <cm:managed-component class="my.Foo"> 
      <cm:managed-properties persistent-id="" update-strategy="container-managed"/>
      <property name="name" value="default />
    </cm:managed-component>
  </cm:managed-service-factory>
</blueprint>

The default value will indeed be overwritten whatever is in your cfg file. 确实会覆盖cfg文件中的默认值。 If it matters,the default property value setter will be invoked, followed by the same property setter with the value from the cfg. 如果重要,将调用默认属性值setter,然后使用cfg中的值调用相同的属性setter。

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? 为什么我需要在我的bean中使用空白持久性id设置另一个托管属性,而我已经在上面这样做了? 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. 例如,我们可能希望有一个约定,即以service:x​​xx开头的任何cfg属性都将传递给Service属性。

Update: The Apache Aries tests are pretty helpful. 更新:Apache Aries测试非常有用。 They can be found here http://aries.apache.org/downloads/currentrelease.html . 他们可以在这里找到http://aries.apache.org/downloads/currentrelease.html In particular take a look at the one for configuration management, org.apache.aries.blueprint.cm . 特别要看一下配置管理的一个,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. 它显示除了上面显示的cm:managed-component中的cm:managed-properties子元素之外,还有一个选项可以在service-properties中包含cm:cm-properties元素。

<service-properties>
    <entry key="key" value="foo3" />
    <cm:cm-properties persistent-id="" update="true"/>
</service-properties>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用Karaf功能为托管服务工厂创建配置? - How to create configuration for Managed Service Factory with Karaf features? 如果一个bean由Spring管理,是否意味着所有创建的bean也必须被管理 - If one bean is managed by Spring does this mean all created beans also have to be managed 春季:如何管理动态工厂? - Spring : How to manage a dynamic factory? Azure的服务管理API是否也适用于Windows Azure Pack? - Does service management API of azure also works for windows azure pack? 在企业的设备所有者应用中,标志。DISALLOW_FACTORY_RESET是否还会阻止硬重置恢复? - in device owner app for enterprise, does the flag.DISALLOW_FACTORY_RESET also prevent hard reset from recovery? 将属性传递给Factory方法 - Passing Properties to Factory method 如何使用aries蓝图将apache karaf软件包作为服务注入Web应用程序中? - How to inject apache karaf bundles as a service in the web application using aries blue print? 管理托管bean中的事务回滚 - Manage rollback on transaction in my managed bean 管理同一服务的实例 - Manage Instances of the same Service 默认的 Managed Executor Service 是否使用 Wildfly 中通用应用程序使用的相同线程池? - Does the default Managed Executor Service use the same thread pool used by the general application in Wildfly?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM