Versions Compared

Key

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

...

Code Block
<composite name="HelloComposition" factory="Hello">
    <import specification="org.apache.felix.ipojo.composition.ex1.person.Person" aggregate="true"/>
    <service specification="org.apache.felix.ipojo.composition.ex1.hello.Hello"/>
    <service specification="org.apache.felix.ipojo.composition.ex1.say.Dispatcher"/>
    <service specification="org.apache.felix.ipojo.composition.ex1.directory.Directory"/>
    <provides specification="org.apache.felix.ipojo.composition.ex1.compo.HelloDispatcher"/>
</composite>

...

Code Block
<instance component="HelloHelloComposition" name="hello-composition"/>

To avoid packaging issues, all referenced service specifications are imported by the bundle containing the composite.

Run Time

Imagine at run time you have:

...

A flash demo of this composition is available.

...

Composite Concepts and Features

The following subsections define the various concepts and features of iPOJO's composite components.

Service Import

The composite can import services from the parent composite. Each import is describe by an import <import> element in the composite description. An import needs to specify targeted imported sub-service must specify the target service specification. Moreover, an import can be:Additionally, imported sub-services can specify:

  • Cardinality: Indicates whether a single provider instance is imported or an aggregated set of the available providers instances is imported.
  • Optionality: Indicates whether the imported sub-service is optional or mandatory.
  • Filtering: Indicates how the services available in the parent composite can be further filtered using an LDAP expression evaluated over their service properties.
  • Simple / aggregate: one provider is imported / all available providers are imported
  • Mandatory /optional: if no providers are available, the composite is invalidated if the import is mandatory
  • Filtered: an import can filter providers
Code Block
<import specification="org.apache.felix.ipojo.test.scenarios.service.Hello"
 optional="true" aggregate="true" filter="(language=en)"/>

Service

...

Provisioning

The composite can provide services to its

If the mapping cannot be infered, the composition is considered as invalid and cannot be started.

The composite can provide services from the composite to the parent composite. Each provided service providing is described by an 'provides' a <provides> element in the composite description. A 'provides' needs to provide service must specify provided service specification.

The service providing Service provision is realized by delegating invocation method invocations on servuces contained in the composition. If the delegating mapping cannot be discoveredthe service interface to methods on the sub-service instances contained in the composition. A delegation mapping is automatically created by matching method names and arguments types. If a delegation mapping cannot be determined, the composition is invalidated.  Morevoer, if a specification used to delegate is optional (and so not necessary providied in the composition at runtime), the implicated method should be declared as optional. An optional method is a method which can be non implemented at runtime. To declare an optional method, the service specification need to declare : "throw UnsupportMethodException". If a non optional method is delegated on an optional specification, a warning message is fired

Service specifications can also declare certain methods as optional in the service interface; this is done by declaring that a method throws an UnsupportedOperationException. Optional methods need not have a mapping for delegation purposes. If a non-optional service method does not have a mapping for delegation, then a warning message is issued.

Code Block
<provides specification="org.apache.felix.ipojo.composition.ex1.service.HelloDispatcher"/>

Sub-Service Instantiation

A composite can instantiate a service inside the compositioncontain sub-services, which result in private service instances at run time. The composite will track Factories factories able to create targeted specification providers. The create created service is instances are accessible only inside the composite (except if the service is exported). Created instance can be composite too. Each . Sub-service instances may also be composites. Each sub-service to instantiate is represented in the composite description by a service element.

Instantiation can be simple or aggregate. In the first case, only one provider is instantiated inside the composition. For aggregate instantiation, each consistent factory is used to instantiate one instance in the composite.

Instantiation can be mandatory or optional. If the composite cannot instantiate a mandatory service, the composite is invalidated.

...

<service> element. The sub-services must specify the desired service specification for the sub-service. Additionally, the sub-service may specify:

  • Cardinality: Indicates whether a single provider instance is created or an aggregated set of the available provider instances is imported.
  • Optionality: Indicates whether the created sub-service instance is optional or mandatory.
  • Filtering: Indicates how the service factories available in the parent composite can be further filtered using an LDAP expression evaluated over their service properties.
Code Block
<composite name="composite.bar ">
    <service specification="org.apache.felix.ipojo.test.scenarios.service.Hello">
          <property name="language" value="en"/>
     </service>
</composite>

Architecture

...