I'm trying to figure out why a field in an iPOJO component is not
getting bound to a property in the Configuration that creates it. That
is, I create a Configuration with
ConfigurationAdmin.createFactoryConfiguration(), specifying some
properties, one of which is bound to field:

<iPOJO>
  <component className="..." factory="...">
    <provides>
      <property name="some.prop" field="someProp/>
    </provides>
    <properties>
      <property name="some.prop" field="someProp"/>
    </properties>
  </component>
</iPOJO>

My intention here is that the Configuration property "some.prop" will
be assigned to the component field "someProp", and the current value
of someProp will be exhibited back out as a service property.

If I'm understanding iPOJO correctly, when the component is getting
created, we wind up in ConfigurationHandler.configure(). Staring on
line 145, we see the following code, reformatted here for clarity:

,----
| // Check if the instance configuration contains value for the
| // current property :
| String name = m_configurableProperties[k].getName();
| String fieldName = m_configurableProperties[k].getField();
| if (name != null &&
|     configuration.get(name) != null &&
|     !(configuration.get(name) instanceof String))
|   { m_configurableProperties[k].setValue(configuration.get(name)); }
| else {
|   if (fieldName != null &&
|       configuration.get(fieldName) != null &&
|       !(configuration.get(fieldName) instanceof String))
|   { m_configurableProperties[k].setValue(configuration.get(fieldName)); } }
`----


Stepping through this code in the debugger, both "name" and
"fieldName" are non-null, "some.prop" and "someProp" respectively, and
configuration.get(name) returns a non-null String. But then we run
into the third condition, making sure that the configuration property
is /not a String/. Why does this matter? Why should String-valued
properties not be set here?

-- 
Steven E. Harris

Reply via email to