<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>EclipseSource Blog &#187; rt</title>
	<atom:link href="http://eclipsesource.com/blogs/tag/rt/feed/" rel="self" type="application/rss+xml" />
	<link>http://eclipsesource.com/blogs</link>
	<description>Eclipse Equinox OSGi</description>
	<lastBuildDate>Fri, 18 May 2012 15:00:41 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Single-Sourcing with declarative services</title>
		<link>http://eclipsesource.com/blogs/2011/07/08/single-sourcing-with-declarative-services/</link>
		<comments>http://eclipsesource.com/blogs/2011/07/08/single-sourcing-with-declarative-services/#comments</comments>
		<pubDate>Fri, 08 Jul 2011 09:51:16 +0000</pubDate>
		<dc:creator>Holger Staudacher</dc:creator>
				<category><![CDATA[eclipse]]></category>
		<category><![CDATA[OSGi]]></category>
		<category><![CDATA[syndicate]]></category>
		<category><![CDATA[declarative services]]></category>
		<category><![CDATA[rap]]></category>
		<category><![CDATA[rcp]]></category>
		<category><![CDATA[rt]]></category>
		<category><![CDATA[Single Sourcing]]></category>

		<guid isPermaLink="false">http://eclipsesource.com/blogs/?p=6229</guid>
		<description><![CDATA[In my last blog post I introduced the idea of using OSGi services for single sourcing a RAP/RCP application. I think this approach is quite elegant, but it has one major drawback. When you use normal OSGi services in your application you will mix your application code with the OSGi Framework code everytime you reference [...]]]></description>
			<content:encoded><![CDATA[<p>In <a href="http://eclipsesource.com/blogs/2011/06/20/using-osgi-services-to-single-source-an-rcp-and-rap-application/">my last blog post</a> I introduced the idea of using <a href="http://osgi.org">OSGi</a> services for single sourcing a <a href="http://eclipse.org/rap">RAP</a>/RCP application. I think this approach is quite elegant, but it has one major drawback. When you use normal OSGi services in your application you will mix your application code with the OSGi Framework code everytime you reference or register a service. Not only does this look ugly, it&#8217;s also hard to test.</p>
<p>Luckily there is a lifesaver called Declarative Services. (For those of you who are familiar with declarative services, skip to the next paragraph.) The OSGi declarative services (ds) are specified in the <a href="http://www.osgi.org/Download/File?url=/download/r4v42/r4.cmpn.pdf">OSGi compendium</a> so they are standardized. It&#8217;s just a component framework on top of OSGi services. It gives you the ability to register and consume services in a declarative way using some xml files and simple accessors in your classes.</p>
<p>I&#8217;ll take the same example from in <a href="http://eclipsesource.com/blogs/2011/06/20/using-osgi-services-to-single-source-an-rcp-and-rap-application/">my last blog post</a> and use it to look at ds for single sourcing.  In that blog, we single sourced a themed button widget.  We can use the same interfaces and service implementations, and the only differences will be how the services will be registered and referenced.</p>
<p>First, let&#8217;s take a look at the service registration. In our example we need to register the services in the rap and rcp bundles. It&#8217;s common practice to put all service declarations in a folder called OSGI-INF in the root of your project. Once you&#8217;ve created this folder you can create a &#8220;component definition&#8221; using the wizard. After this you need to fill in three things: first, the filename of your choice, second, the component name which needs to be unique in the framework and third, the component itself.</p>
<p><a href="http://eclipsesource.com/blogs/wp-content/uploads/2011/07/componentWizard.png"><img class="aligncenter size-full wp-image-6232" title="componentWizard" src="http://eclipsesource.com/blogs/wp-content/uploads/2011/07/componentWizard.png" alt="componentWizard Single Sourcing with declarative services" width="537" height="570" /></a></p>
<p>The component is the fully qualified classname of your implementation. In the case of service registration, it&#8217;s your service implementation. To add the service registration, press &#8216;Finish&#8217; to open the component editor. We only want to register a service, so we jump to the service tab. In the bottom section you can add the service interface.</p>
<p>To understand what happens in the background let&#8217;s recap what we have declared. We defined a service interface, a service implementation, a component name and a filename. The component framework takes care of instantiating the service implementation and registering it as a service using the service interface. It registers the component using the component name. The filename will be automatically added to your bundle&#8217;s manifest. That&#8217;s all, the next time we start this bundle the service will be registered. Your component definition should look something like this:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;UTF-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;scr:component</span> <span style="color: #000066;">xmlns:scr</span>=<span style="color: #ff0000;">&quot;http://www.osgi.org/xmlns/scr/v1.1.0&quot;</span> <span style="color: #000066;">immediate</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;com.eclipsesource.app.rap.service.provider&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;implementation</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;com.eclipsesource.app.rap.RAPSingelSourcingService&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;service<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;provide</span> <span style="color: #000066;">interface</span>=<span style="color: #ff0000;">&quot;com.eclipsesource.app.ISingleSourcingService&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/service<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/scr:component<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>Now we get to the service referencing. As you recall, we need to reference the service in our app bundle. Therefore, we need to create a component in this bundle too. In this example I decided to reference the service in the bundle&#8217;s activator and provide it with a static accessor. But you can reference it wherever you want. In this case the component is our Activator. The only difference to the service registration is in the service tab of the component editor. Instead of providing a service, we are now referencing one. You can do this by clicking &#8216;Add&#8217; in the upper section of this tab.</p>
<p><a href="http://eclipsesource.com/blogs/wp-content/uploads/2011/07/serviceReferencing.png"><img class="aligncenter size-full wp-image-6233" title="serviceReferencing" src="http://eclipsesource.com/blogs/wp-content/uploads/2011/07/serviceReferencing.png" alt="serviceReferencing Single Sourcing with declarative services" width="521" height="315" /></a></p>
<p>After this you need to declare the Interface of the service you want to reference, in our case the ISingleSoucingService. The question is now, &#8220;how does this service finds its way to the Activator?&#8221; The answer is binding methods. In the reference you can specify a bind and an unbind method e.g. setService and unsetService. You need to add these methods to your activator with the service as a parameter. That&#8217;s all &#8211; we are referencing the service now. Your component should look something like this:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;UTF-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;scr:component</span> <span style="color: #000066;">xmlns:scr</span>=<span style="color: #ff0000;">&quot;http://www.osgi.org/xmlns/scr/v1.1.0&quot;</span> <span style="color: #000066;">enabled</span>=<span style="color: #ff0000;">&quot;true&quot;</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;com.eclipsesource.app.servic.consumer&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;implementation</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;com.eclipsesource.internal.app.Activator&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;reference</span> <span style="color: #000066;">bind</span>=<span style="color: #ff0000;">&quot;setSingleSourcingService&quot;</span> <span style="color: #000066;">cardinality</span>=<span style="color: #ff0000;">&quot;1..1&quot;</span> <span style="color: #000066;">interface</span>=<span style="color: #ff0000;">&quot;com.eclipsesource.app.ISingleSourcingService&quot;</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;ISingleSourcingService&quot;</span> <span style="color: #000066;">policy</span>=<span style="color: #ff0000;">&quot;dynamic&quot;</span> <span style="color: #000066;">unbind</span>=<span style="color: #ff0000;">&quot;unsetSingleSourcingService&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/scr:component<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>The last thing we need is a little bit of glue to bring these components together. The glue is in the <code>org.eclipse.equinox.ds</code> bundle. This bundle contains the component framework implementation, and to make everything work together you need to add this bundle to your launch configuration. It&#8217;s not included in the <a href="http://eclipse.org/rap">RAP</a> target components, but you can download it using the <a href="http://wiki.eclipse.org/Eclipse_Project_Update_Sites">Indigo release site</a> or the <a href="http://download.eclipse.org/equinox/">Equinox SDK</a>.</p>
<p>I added a branch called &#8220;ds&#8221; to the <a href="https://github.com/eclipsesource/rap-single-sourcing">repository on github</a> from the last blog. This branch represents an example implementation using ds for single sourcing.</p>
<p>Have fun declaring services <img src='http://eclipsesource.com/blogs/wp-includes/images/smilies/icon_wink.gif' alt="icon wink Single Sourcing with declarative services" class='wp-smiley' title="Single Sourcing with declarative services" /> </p>
]]></content:encoded>
			<wfw:commentRss>http://eclipsesource.com/blogs/2011/07/08/single-sourcing-with-declarative-services/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>EclipseRT Days and DemoCamps</title>
		<link>http://eclipsesource.com/blogs/2009/11/09/eclipsert-days-and-democamps/</link>
		<comments>http://eclipsesource.com/blogs/2009/11/09/eclipsert-days-and-democamps/#comments</comments>
		<pubDate>Mon, 09 Nov 2009 21:15:17 +0000</pubDate>
		<dc:creator>Jeff McAffer</dc:creator>
				<category><![CDATA[syndicate]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[rt]]></category>
		<category><![CDATA[talks]]></category>

		<guid isPermaLink="false">http://eclipsesource.com/blogs/?p=3339</guid>
		<description><![CDATA[Three weeks, two EclipseRT Days, three DemoCamps, 4 cities, three countries, two continents.]]></description>
			<content:encoded><![CDATA[<p>Autumn is in the air (wouldn&#8217;t know it here.  17C!) so it must be time for the Fall line up of &#8220;Eclipse days&#8221; and demo camps. This year I&#8217;ll be at two <a href="http://wiki.eclipse.org/EclipseRT_Day">Eclipse Days</a> and <a href="http://wiki.eclipse.org/Eclipse_DemoCamps_November_2009">three demo camps</a>!</p>
<p>First we have the <a href="http://wiki.eclipse.org/EclipseRT_Day">EclipseRT days</a> in Austin and Toronto. Are you in the area? Come on by and tell people about your use of Eclipse in runtime scenarios or find out how others are getting the power of Eclipse modularity and all that good stuff in their clients, servers and embedded devices. There are talks from the projects, talks from the community. Fun for kids of all ages.</p>
<p>Due to a happy coincidence of travel and cosmic forces I&#8217;ll also be at the <a href="http://wiki.eclipse.org/Eclipse_DemoCamps_November_2009">DemoCamps</a> in <a href="http://wiki.eclipse.org/Eclipse_DemoCamps_November_2009/Toronto">Toronto</a>, <a href="http://wiki.eclipse.org/Eclipse_DemoCamps_November_2009/Vienna">Vienna</a> and <a href="http://wiki.eclipse.org/Eclipse_DemoCamps_November_2009/Ottawa">Ottawa</a>. Should be very cool.  I&#8217;m particularly excited to see one of these fabled European DemoCamps in action.</p>
<p>Its going to be a busy few weeks. Hope to see you at one or more of these events.</p>
]]></content:encoded>
			<wfw:commentRss>http://eclipsesource.com/blogs/2009/11/09/eclipsert-days-and-democamps/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

