The contents of this document are a work in progress
If you are familiar with libraries like xstream you will feel at home. If not, it's simple enough anyway.
The best way to understand how the plexus ComponentConfigurator functions is by example. Assuming that the auto-configuration mechanism is applied to class:
com.MyComponent
class com.MyComponent implements com.SomeInterface
{
private String propertyA;
private int propertyB;
...
}
with a plexus configuration like so:
<component>
<role>com.SomeInterface</role>
<implementation>com.MyComponent</implementation>
<configuration>
<propertyA>foo</propertyA>
<propertyB>1</propertyA>
</configuration>
</component>
The actions the plexus ComponentConfigurator would perform on the instance of component would be something like this:
com.SomeInterface component = new com.MyComponent(); component.propertyA = "foo"; component.propertyB = 1;
Component implementation:
class com.MyComponent
{
private Person person;
...
}
class com.Person
{
private String firstname;
private String lastname;
...
}
Component configuration :
<configuration>
<person>
<firstname>Baltzar<firstname>
<lastname>Gabka</lastname>
</person>
</configuration>
Actions taken by Component Configurator:
Person person = new Person(); person.firstname = "Baltazar"; person.lastname = "Gabka"; component.person = person;
TODO: Collections example.
Component implementation:
class com.MyComponent
{
private Properties propertiesA;
...
}
Component configuration :
<configuration>
<propertiesA>
<property>
<name>key1</name>
<value>value1</value>
</property>
<property>
<name>key2</name>
<value>value2</value>
</property>
</propertiesA>
</configuration>
Actions taken by Component Configurator:
com.MyComponent component; Properties properties = new Properties(); properties.put( "key1", "name1" ) properties.put( "key2", "name2" ) setFieldValue( component, "propertiesA", properties ); component.propertiesA = properties;
<foos elements="java.lang.String"/>
<id>ala</id>
<id>ala</id>
<id>ala</id>
</foos>
or possibly (pending implementation)
<foos elements="com.MyBean" implementation="java.util.LinkedList"/>
<bean>
<id>foo</id>
</bean>
<bean>
</id>ala</id>
</bean>
</foos>