Does Aries-service-factory also manage property management?

I use Apache Aries 0.2 in Servicemix 4.3.1 and create cm: managed-service-factory. Creating services with .cfg files works fine (except # ARIES-584 ), but the properties from the .cfg file are not entered into the service object. They are set correctly in ConfigAdmin, only my bean configuration methods are never called for values ​​in my configuration file.

I thought I should use the cm: managed-properties or something similar in my managed factory service, but that would require a separate pid, so it doesn't seem right.

If I do not put a property tag, then the value will never be set. With a property tag, then only the default value will be set, but the actual value of the configuration file will never be.

I can not find any documentation for using the Aries CM subproject, except blueprint-sample.xml , which does not show managed properties inside the factory managed service. I am really trying to use Servicemix, but around every corner there is no documentation, broken or missing functions or errors that affect the main functions.

Both spring and gemini documentation indicates that their factory-managed service 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 

configurations: 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 
+6
source share
1 answer

I believe that you need to add one extra line to your managed component element.

 <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 really overwrite everything in your cfg file. If it matters, the default property value installer will be called, followed by the same set of properties with the value from cfg.

In this case, I used a container-driven strategy for updating. But you can use a managed component.

It seems redundant to me and in bad taste. Why do I need to set other managed properties in my bean with an empty constant identifier when I already did this above? There may be a better way, but this seems to work.

In addition, there is no obvious way to influence the advertised properties of the service. For example, we may need an agreement that any cfg properties starting with the service: xxx will be passed to the service properties.

Update: Apache Aries tests are pretty useful. They can be found here http://aries.apache.org/downloads/currentrelease.html . In particular, look at the configuration to manage the org.apache.aries.blueprint.cm configuration. There are several examples in the test folder. It shows that in addition to the cm: managed-properties child element in the cm-managed component above, it is also possible to have the cm: cm-properties property element in the service properties.

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

Source: https://habr.com/ru/post/899803/


All Articles