Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Declaring component types

Code Block
xml
xml
titleXML
<component
    classname="my.Implementation"
    name="my-type"
>
</component>
Code Block
java
java
titleAnnotations
@Component(name="my-type")
public class Implementation {
  // ...
}

...

...

Creating component instances

Code Block
xml
xml
titleXML only
<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>

...

  • Instances can contains a configuration given under the key-value form. Properties can also by complex type.
  • How-to use iPOJO factories

...

Providing services

Code Block
xml
xml
titleXML
<component classname="my.service.implementation" name="my-service-impl">
   <provides/>
</component>
<instance name="my-service-impl"/>

...

Center

...

Using services with field injection

Code Block
xml
xml
titleXML
<component classname="my.consumer.Implementation">
    <requires field="fs" />
</component>
Code Block
java
java
titleAnnotations

@Component
public class Dependency {

    @Requires
    public FooService fs;
    
    //...
}
Center

Using services with method injection

Code Block
xml
xml
titleXML

<component classname="my.consumer.Implementation">
    <requires>
	<callback type="bind" method="bind" />
	<callback type="unbind" method="unbind" />
    </requires>	
</component>
Code Block
java
java
titleAnnotations
@Component
public class Dependency {

    @Requires@Unbind
    public FooService fs;
    
    @Unbind
    public synchronized void unbind(BazService bz) {
        //...
    }
    
    @Bind
    public synchronized void bind(BazService bz) {
        // ...
    }

  //...
}

...