belaso.de — Java Blog

Eclipse Gemini Blueprint 2.0.0 Tutorial

Eclipse Gemini Blueprint is the Reference Implementation of the OSGi Blueprint Service defined in the OSGi 5.0 Enterprise Specification. It was originally called Spring DM (Dynamic Modules) before being donated to Eclipse and becoming Gemini Blueprint.

Installation

Installing Gemini Blueprint means including some OSGi bundles into your target platform. We are going to create a new target platform from scratch, but you can also take your existing target platform. OK let’s start:

You have now following folder structure in your gemini-blueprint-target project:

folder structure

Create a new target definition file named gemini-blueprint-target\tutorial.target, open it and include Equinox, Spring and Gemini Blueprint:

target definition

Don’t forget to set the target platform.

You can start Equinox containing Eclipse Gemini & Spring now. For a minimal configuration please use only the following bundles:

start equinox

The ss command in the OSGi console responds:

osgi> ss
id	State       Bundle
0	ACTIVE      org.eclipse.osgi_3.9.0.v20130529-1710
1	ACTIVE      org.springframework.transaction_3.2.3.RELEASE
2	ACTIVE      org.springframework.beans_3.2.3.RELEASE
3	ACTIVE      org.apache.felix.gogo.shell_0.10.0.v201212101605
4	ACTIVE      org.springframework.aspects_3.2.3.RELEASE
5	ACTIVE      org.springframework.context.support_3.2.3.RELEASE
6	ACTIVE      org.eclipse.gemini.blueprint.extender_2.0.0.M02
7	ACTIVE      org.apache.felix.gogo.command_0.10.0.v201209301215
8	ACTIVE      com.springsource.slf4j.api_1.6.1
	            Fragments=15
9	ACTIVE      org.eclipse.gemini.blueprint.io_2.0.0.M02
10	ACTIVE      org.eclipse.gemini.blueprint.core_2.0.0.M02
11	ACTIVE      com.springsource.org.aopalliance_1.0.0
12	ACTIVE      org.springframework.aop_3.2.3.RELEASE
13	ACTIVE      org.apache.felix.gogo.runtime_0.10.0.v201209301036
14	ACTIVE      org.eclipse.equinox.console_1.0.100.v20130429-0953
15	RESOLVED    com.springsource.slf4j.simple_1.6.1
	            Master=8
16	ACTIVE      com.springsource.slf4j.org.apache.commons.logging_1.6.1
17	ACTIVE      org.springframework.core_3.2.3.RELEASE
18	ACTIVE      org.eclipse.osgi.services_3.3.100.v20130513-1956
19	ACTIVE      org.springframework.context_3.2.3.RELEASE
20	ACTIVE      org.springframework.expression_3.2.3.RELEASE

Hello world! example

We have a running Gemini Blueprint environment now. How about the traditional Hello world! example? Create a new Eclipse plug-in named hello in your workspace. Add a new file named META-INF\spring\beans.xml into your plug-in with following content:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:osgi="http://www.eclipse.org/gemini/blueprint/schema/blueprint"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://www.springframework.org/schema/beans   
       http://www.springframework.org/schema/beans/spring-beans.xsd                  
       http://www.eclipse.org/gemini/blueprint/schema/blueprint 
       http://www.eclipse.org/gemini/blueprint/schema/blueprint/gemini-blueprint.xsd">
	<osgi:service interface="java.lang.String">
		<bean class="java.lang.String">
			<constructor-arg>
				<value>Hello world!</value>
			</constructor-arg>
		</bean>
	</osgi:service>
</beans>

Now start the above target platform togheter with your hello plug-in. Please start the hello plug-in:

osgi> ss hello
id	State       Bundle
21	ACTIVE      hello_1.0.0.qualifier

Type now services *String* in the Equinox console

osgi> services *String*
{java.lang.String}={Bundle-SymbolicName=hello, Bundle-Version=1.0.0.qualifier, service.id=49}
  "Registered by bundle:" hello_1.0.0.qualifier [21]
  "No bundles using service."

and voila you registred a OSGi service via Eclipse Gemini!

Please share this blog:

   Tweet

comments powered by Disqus