Versions Compared

Key

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

...

A component type is a kind of instance template. If we compare component concepts with object oriented programming, component types are classes and component instances are objects. A component type is declared inside a metadata file (metadata.xml). The next snippet shows you a component type declaration:

Code Block
xml
xml
 
<component className="..." factory="MyFactory">
...
<!—handler configuration - ->
...
</component>

A component type is generally composed by:

...

The next snippet shows how to declare an instance in the metadata:

Code Block
xml
xml

<instance component="component factory name" name = "instance name" >
	<property name="a property name" value="a string form of the value"/

...

>
<property name="another property name" value="the string form of the wanted value"/>
</instance>

The component type attribute contains the targeted factory name. The name attribute declares the instance name. The instance configuration is set by declaring a set of properties. A property is composed by a name and a value. The value is the string form of the wanted value. The iPOJO runtime will create the property object with this string.
If an unacceptable configuration is set, the instance is not created, and an error message appears to the console (and in the Log Service if present).

...

A public factory is exposed as an org.apache.felix.ipojo.Factory service. This service is accessible as any other OSGiâ„¢ service, and could be an iPOJO dependency too. This service used the following interfaces:

Code Block
titleFactory.java
borderStylesolid

public interface Factory {
    /**
     * Create an instance manager (i.e. component type instance).
     * @param configuration : the configuration properties for this component.
     * @return the created instance manager.
     * @throw UnacceptableConfiguration if the given configuration is not consistent for the factory
     */
    ComponentInstance createComponentInstance(Dictionary configuration) throw UnacceptableConfiguration;

    /**
     * Create an instance manager (i.e. component type instance).
     * This has these service interaction in the scope given in argument.
     * @param configuration : the configuration properties for this component.
     * @param serviceContext : the service context of the component.
     * @return the created instance manager.
     * @throw UnacceptableConfiguration if the given configuration is not consistent for the factory
     */

...


    ComponentInstance createComponentInstance(Dictionary configuration, ServiceContext serviceContext) throw UnacceptableConfiguration;

    /**
     * Get the component type information containing provided service, configuration properties ...
     * @return the component type information.
     */
    ComponentDescription getComponentDescription();

    /**
     * Check if the given configuration is acceptable as a configuration of a component instance.
     * @param conf : the configuration to test
     * @return true if the configuration is acceptable
     */
    boolean isAcceptable(Dictionary conf);

    /**
     * @return the name of the factory.
     */
    String getName();

}

The factory service contains two methods to create instances:

...