Eclipse Virgo OSGi Enthusiasts, like myself, can now switch from the Spring OSGi namespace to the Eclipse Gemini Blueprint namespaces for bundles.
Maven Dependencies
<!-- Gemini Blueprint OSGi -->
<properties>
<gemini.blueprint.version>1.0.0.RELEASE</gemini.blueprint.version>
</properties>
...
<dependency>
<groupId>org.eclipse.gemini</groupId>
<artifactId>org.eclipse.gemini.blueprint.extender</artifactId>
<version>${gemini.blueprint.version}</version>
<exclusions>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>org.springframework.beans</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>org.springframework.core</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>org.springframework.context</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.eclipse.gemini.blueprint</groupId>
<artifactId>gemini-blueprint-mock</artifactId>
<version>${gemini.blueprint.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.gemini</groupId>
<artifactId>org.eclipse.gemini.blueprint.core</artifactId>
<version>${gemini.blueprint.version}</version>
<exclusions>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>org.springframework.aop</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>org.springframework.beans</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>org.springframework.core</artifactId>
</exclusion>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>org.springframework.context</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.eclipse.gemini</groupId>
<artifactId>org.eclipse.gemini.blueprint.io</artifactId>
<version>${gemini.blueprint.version}</version>
</dependency>
Repositories
<repository> <id>com.springsource.repository.bundle.external</id> <name>SpringSource Enterprise Bundle Repository - External Bundle Releases</name> <url>http://repository.springsource.com/maven/bundles/external</url> </repository>
Eclipse Gemini Blueprint Config
| XML Tag | Attributes | Description |
|---|---|---|
| <bean /> | id, activation, depends-on, class, init-method, destroy-method, factory-method, factory-ref, scope | The type definition for a component. The bean’s attributes provide the characteristics for how to create the bean instance. Constructor arguments and injected properties are specified via child <argument> and <property> elements |
| <blueprint /> | default-activation, default-timeout, default-availability, | The root element for a blueprint configuration file with two sections. The first section (contained within the <type-converters> element) identifies components that are used for converting values into different target types. The type converters are optional. The second section contains component definitions. Components are <bean>, <service>, <reference>, and <reference-list> elements that identify the bundle components that will be managed by the blueprint service |
| <description /> | A generic element type to allow documentation to be added to the blueprint configuration | |
| <compendium:cm-properties /> | id, persistent-id, local-override, dynamic, init-lazy, init-timeout | Exposes the properties found in the Configuration Admin service under the given <persistent-id> |
| <compendium:managed-properties /> | persistent-id, autowire-on-update, update-method | Defines a bean based on the given class name and configuration, with properties autowired-by-name based on the configuration stored under the given <persistent-id> |
| <compendium:managed-service-factory /> | auto-export, autowire-on-update, context-class-loader, depends-on, factory-pid, interface, update-method | Defines a collection of beans based on the given class name, with properties <autowired-by-name> based on the configuration sets stored under the given factory <persistent-id> |
| <ref /> | component-id | Defines a required <component-id> for the reference component |
| <reference /> | id, activation, depends-on, interface, filter, component-name, availability | Defines the instances of a registered <service>, with a <timeout>. If the <timeout> is not specified, the <default-timeout> value is inherited from the encapsulating <blueprint> definition |
| <reference-list /> | id, activation, depends-on, interface, filter, component-name, availability, member-type | Builds in the characteristics of the <service> type to define characteristics of the <reference-list>. This adds in the characteristics that only apply to collections of references via <member-type>. Subnodes can be <description >, <compendium:cm-properties >, <compendium:managed-properties >, <compendium:managed-service-factory >, <reference-listener > |
| <reference-listener /> | ref, bind-method, unbind-method | A definition of a listener that will watch for bind/unbind events associated with the <service> reference. The listener can be a <ref> to a <bean> or <reference> element, or an inline <bean> or <reference> |
| <service /> | id, activation, depends-on, interface, ref, auto-export, ranking | Defines the type for services exported by this blueprint bundle. Services are sourced by either a <ref> to a <bean> component or an <inline> bean component |
| <type-converters /> | Defines a set of <bean>, <ref>, or <reference> elements that identify the type converter components |
Examples
<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0
http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd"
default-activation="eager">
<!-- import the DataSource from OSGi -->
<reference id="dataSource" interface="javax.sql.DataSource"/>
<!-- export the directory bean to OSGi under the Directory interface -->
<service ref="directory" interface="greenpages.Directory"/>
</blueprint>
<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:compendium="http://www.eclipse.org/gemini/blueprint/schema/blueprint-compendium"
xsi:schemaLocation="http://www.eclipse.org/gemini/blueprint/schema/blueprint-compendium
http://www.eclipse.org/gemini/blueprint/schema/blueprint-compendium/gemini-blueprint-compendium.xsd
http://www.osgi.org/xmlns/blueprint/v1.0.0
http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd"
default-activation="eager">
<compendium:cm-properties id="database.props"
persistent-id="greenpages.db.config"/>
<!-- Export the JDBC DataSource with the Service Name 'dataSource' -->
<service ref="dataSource" interface="javax.sql.DataSource"/>
</blueprint>
Resources
- Blueprint Migration – note: Repository referenced in article is not useful
- My Code Samples
- Gemini Blueprint
- Eclipse Virgo