THIS IS A TEST INSTANCE. ALL YOUR CHANGES WILL BE LOST!!!!
How to declare a component type
Section | ||||||
---|---|---|---|---|---|---|
Column | ||||||
| ||||||
Code Block | ||||||
| ||||||
<component
classname="my.Implementation"
name="my-type"
>
</component>
column | ||||||
|
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
@Component(name="my-type")
public class Implementation {
// ...
}
|
Center |
---|
How to declare instances
...
100% | ||||
Code Block | ||||
---|---|---|---|---|
| ||||
<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>
|
Attribute name | Required | Default value |
|
---|---|---|---|
component | yes |
| specifies the component type (either by using the name or the class name) |
name | no | generated | specifies the instance name. |
Center |
---|
- 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
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
<component classname="my.service.implementation" name="my-service-impl">
<provides/>
</component>
<instance name="my-service-impl"/>
|
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
@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
Center
Publishing service properties
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
<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/> |
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
@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;
// ...
}
|
Center |
---|