THIS IS A TEST INSTANCE. ALL YOUR CHANGES WILL BE LOST!!!!
How to declare a component type
XML
<component classname="my.Implementation" name="my-type" > </component>
Annotations
@Component(name="my-type") public class Implementation { // ... }
How to declare instances
<instance component="my-type"/> <instance component="my.Implementation"/> <instance component="my-type" name="my-instance"/> <instance component="my-type" name="my-instance"> <property name="property1" value="value1"/> </instance> </component>
- Instances can contains a configuration given under the
key-value
form. Properties can also by complex type (refer to How-to use iPOJO factories)
How to provide a service
XML
<component classname="my.service.implementation" name="my-service-impl"> <provides/> </component> <instance name="my-service-impl"/>
Annotations
@Component @Provides public class Implementation implements FooService { ... }
- Only instances provides really services, so don't forget to declare an instance.
- Published service interfaces must be implemented by your component implementation
Publishing service properties
XML
<component classname="my.service.implementation" name="my-service-impl"> <provides> <property name="foo" field="m_foo" /> <property name="bar" field="m_bar" mandatory="true" /> <property name="baz" type="java.lang.String" /> <!-- Static property (do not change at runtime) --> </provides> </component> <instance name="my-service-impl"> <!-- The configuration has to inject value in unvalued mandatory properties --> <property name="bar" value="5"/> <property name="baz" value="my string"/> <instance/>
Annotations
@Component @Provides(specifications= {FooService.class, BarService.class}) public class ProvidesProperties implements FooService, BarService { @ServiceProperty(name = "foo") public int m_foo = 0; @ServiceProperty(name="bar", mandatory=true) public int m_bar; // ... }