<?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; eclipse</title>
	<atom:link href="http://eclipsesource.com/blogs/tag/eclipse/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>Eclipse Testing Day 2012 Submissions Open</title>
		<link>http://eclipsesource.com/blogs/2012/04/26/eclipse-testing-day-2012-submissions-open/</link>
		<comments>http://eclipsesource.com/blogs/2012/04/26/eclipse-testing-day-2012-submissions-open/#comments</comments>
		<pubDate>Thu, 26 Apr 2012 12:05:02 +0000</pubDate>
		<dc:creator>Matthias Kempka</dc:creator>
				<category><![CDATA[news]]></category>
		<category><![CDATA[OSGi]]></category>
		<category><![CDATA[syndicate]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[events]]></category>
		<category><![CDATA[jubula]]></category>
		<category><![CDATA[junit]]></category>
		<category><![CDATA[TDD]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://eclipsesource.com/blogs/?p=7573</guid>
		<description><![CDATA[This year marks the third Eclipse Testing Day, where the community gathers for a day focusing on testing with, for and at Eclipse. The event takes place on September 05 in Darmstadt. The general theme for this year&#8217;s testing day is &#8220;Testing and Beyond&#8221;. Topics of interest include: Testing Eclipse applications Testing within the Eclipse [...]]]></description>
			<content:encoded><![CDATA[<p>This year marks the third Eclipse Testing Day, where the community gathers for a day focusing on testing with, for and at Eclipse. The event takes place on September 05 in Darmstadt.</p>
<p>The general theme for this year&#8217;s testing day is &#8220;Testing and Beyond&#8221;. Topics of interest include:</p>
<ol>
<li>Testing Eclipse applications</li>
<li>Testing within the Eclipse Ecosystem</li>
<li>Testing on Eclipse Projects</li>
<li>Design for testability in Eclipse</li>
<li>Case studies of testing projects</li>
<li>Eclipse tooling and technology for the test process</li>
<li>Testing as a part of the application lifecycle</li>
<li>Continuous integration and testing for Eclipse applications</li>
</ol>
<p>The call for papers is open. If you would like give a talk on one of the given topics, or maybe if you have a visionary &#8216;beyond&#8217;, don&#8217;t hesitate to submit a talk.  The deadline for submissions is May 31st.</p>
<p>You&#8217;ll find more information on the wiki at <a href="http://wiki.eclipse.org/Eclipse_Testing_Day_2012">http://wiki.eclipse.org/Eclipse_Testing_Day_2012</a></p>
]]></content:encoded>
			<wfw:commentRss>http://eclipsesource.com/blogs/2012/04/26/eclipse-testing-day-2012-submissions-open/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using Key Events effectively in RAP</title>
		<link>http://eclipsesource.com/blogs/2012/03/08/using-key-events-effectively-in-rap/</link>
		<comments>http://eclipsesource.com/blogs/2012/03/08/using-key-events-effectively-in-rap/#comments</comments>
		<pubDate>Thu, 08 Mar 2012 09:46:12 +0000</pubDate>
		<dc:creator>Tim Buschtöns</dc:creator>
				<category><![CDATA[eclipse]]></category>
		<category><![CDATA[news]]></category>
		<category><![CDATA[syndicate]]></category>
		<category><![CDATA[juno]]></category>
		<category><![CDATA[Key Events]]></category>
		<category><![CDATA[Keybindings]]></category>
		<category><![CDATA[rap]]></category>

		<guid isPermaLink="false">http://eclipsesource.com/blogs/?p=7075</guid>
		<description><![CDATA[Good keyboard controls have become a staple of modern web applications, such as Google Mail, Github (press &#8220;?&#8221;) and Flickr. However, almost every browser implements key events slightly differently, all with some quirks, and none of them like in SWT. For this reason, key events in RAP had, until recently, several issues and limitations. That is [...]]]></description>
			<content:encoded><![CDATA[<p>Good keyboard controls have become a staple of modern web applications, such as <a href="http://goo.gl/pEaop">Google Mail</a>, <a href="http://www.github.com/">Github</a> (press &#8220;?&#8221;) and <a href="http://www.flickr.com/help/website/">Flickr</a>. However, almost every browser implements key events slightly differently, all with some quirks, and none of them like in SWT. For this reason, key events in RAP had, until recently, several issues and limitations. That is a thing of the past now, as the key events implementation has been largely rewritten in RAP 1.5M5, and now finally works reliably. This also brings some general changes to RAP key event handling.</p>
<ul>
<li>Some keys that didn’t work at all (like arrow-keys in Firefox), work fine now. This also fixes the JFace Content Proposal.</li>
</ul>
<ul>
<li>Several non-alphanumeric keys had the wrong keycode,  those are fixed.</li>
</ul>
<ul>
<li>Key events are no longer blocking the UI when sending the Ajax request to the server.</li>
</ul>
<ul>
<li>There is now a feature called “active keys”, which makes it possible to drastically reduce traffic traffic.  It was already present in RAP 1.4, but has been greatly improved.</li>
</ul>
<ul>
<li>Another new feature is called &#8220;cancel keys&#8221;. It allows to suppress the browsers and widgets default operations associated with any given key.</li>
</ul>
<ul>
<li><em>The &#8220;cancel keys&#8221; replace the now-defunct support for the <code>doit</code> flag on key events.</em></li>
</ul>
<p><span id="more-7075"></span></p>
<h3>The Active Keys</h3>
<p>One practical problem with key events was the high amount of network traffic they can generate, one request per pressed key. Especially when you add a listener to widgets like Text, there may be hundreds of requests per user per minute &#8211; even if only a few of them are relevant to your applications logic. To counter that, “active keys” allows you to limit the number of requests to the server to only those that are actually necessary. You simply attach a list of key combinations to the widget that has the key listener, and subsequently RAP will only fire key events on this widget that match any of the given combinations.</p>
<p>Example:</p>
<blockquote><p><code>widget.setData( RWT.ACTIVE_KEYS, new String[]{ "ALT+SHIFT+X", </code><code>"F1", "/"</code><code> );<br />
widget.addKeyListener( new KeyListener(){ ... } );<br />
</code></p></blockquote>
<p>The widgets and browsers behavior is not changed by this at all. Also, even if you would handle all active keys the same way in the listener, it would be good practice to still explicitly check the pressed key and modifiers on the event itself &#8211; especially if you are working on a multi-platform project. Then this approach is also Single Sourcing friendly.</p>
<p>Though the example limits the active key to the given widget, this feature can also be used to implement global key bindings. Just add the list to the display instead to a widget. RAP will send key events for these keys, no matter what widget is focused. (This aspect of  &#8220;active keys&#8221; already worked in RAP 1.4). Typically you want to use this feature together with a display filter, so you can also process them globally.</p>
<p>Example:</p>
<blockquote><p><code>display.setData( RWT.ACTIVE_KEYS, new String[]{ "CTRL+X",</code><code>"CTRL+Y",</code><code>"CTRL+Z" </code><code>);<br />
display.addFilter( SWT.KeyDown, new Listener(){ ... }</code> );</p></blockquote>
<h3>The Cancel Keys</h3>
<p>One issue specific to keyboard shortcuts in web applications  is that you are basically sharing your pool of possible key combos with the browser itself. For example, “CTRL+F” will bring up search dialog in almost every browser, so you can’t just use it to do the same in your application &#8211; you would have both dialogs pop up at the same time. Up until now RAP supported the <code>doit</code> flag on key events, which made it possible to suppress not only widget-specific behavior (like in SWT), but also some browser-native shortcuts. However, depending on the browser this was working only for some keys and shortcuts.</p>
<p>As time went on the <code>doit</code> support became an obstacle to us RAP developers. It was originally implemented to better support JFace cell editors. This worked well, but outside that use case it had &#8211; as mentioned &#8211; some limitations. It also prevented us to fix a number of bugs for key event handling, so for the first time in RAP history, we decided to remove a feature. It was not an easy decision to make, and we only did it after we had a solid replacement.</p>
<p>This replacement is called “cancel keys”. It works pretty much like “active keys”, and can also be combined with that. Like before you attach a list of keys or key-combinations to the widget, and those will all be “prevented”. That means that while the widget is focused, whatever the pressed keys default action is will not happen. <em>This is true for all RAP widget behavior, as well as for most browser features.</em> (Some browser features can not be prevented, like CTRL+TAB for switching tabs, or ALT to focus the menu bar.)</p>
<p>Example:</p>
<blockquote><p><code>widget.setData( RWT.CANCEL_KEYS, new String[]{ "CTRL+F", "CTRL+T" );</code></p></blockquote>
<p>You can also change the set of cancel keys at any time. All keys not on the list will still work, even if they are part of a listed combination. If the widget from the example is a Text, <em></em>pressing only &#8220;F&#8221; or &#8220;T&#8221; will still insert that character into the field. Again, this feature also works globally when setting the list on Display. You should keep in mind though that the user might be accustomed for certain shortcuts to trigger the default action, like CTRL+T to open a new browser tab, and might not appreciate it when its completely “overwritten” in your application. If you want your code to also work in SWT, you still need to set the <code>doit</code> flag to false.</p>
<h3>Showcase</h3>
<p>You can see those features in action in our updated <a href="http://rap.eclipsesource.com/rapdemo/examples#tableviewer">demo</a> on the “TableViewer” page. For example, pressing &#8220;CTRL+F&#8221; will switch to the filter textfield, and from there &#8220;Escape&#8221;, &#8220;Enter&#8221; or the down-arrow key will focus the Table again. You&#8217;ll notice that your browsers search field will not pop up if you press &#8220;CTRL+F&#8221;, as long as the table is focused. If you use Firebug or any other debugging tool, you can also see that no requests are sent if any other keys are pressed.</p>
<p>For the applications user to actually use the keyboard controls, he first has to know they exist. So as a UI designer/developer, you might want to place some hints. In the case of our demo I simply placed a short help-text below the Table in a small, grayish font, so it doesn&#8217;t distract form the rest of the UI. If there are too many shortcuts to list them all, the Link widget could be used in a similar manner, directing the user to a more comprehensive help dialog.</p>
]]></content:encoded>
			<wfw:commentRss>http://eclipsesource.com/blogs/2012/03/08/using-key-events-effectively-in-rap/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Eclipse Indigo SR2: Released in time</title>
		<link>http://eclipsesource.com/blogs/2012/02/24/eclipse-indigo-sr2-released-in-time/</link>
		<comments>http://eclipsesource.com/blogs/2012/02/24/eclipse-indigo-sr2-released-in-time/#comments</comments>
		<pubDate>Fri, 24 Feb 2012 16:40:45 +0000</pubDate>
		<dc:creator>Markus Knauer</dc:creator>
				<category><![CDATA[eclipse]]></category>
		<category><![CDATA[syndicate]]></category>
		<category><![CDATA[epp]]></category>
		<category><![CDATA[indigo]]></category>
		<category><![CDATA[new and noteworthy]]></category>
		<category><![CDATA[release]]></category>

		<guid isPermaLink="false">http://eclipsesource.com/blogs/?p=7064</guid>
		<description><![CDATA[Sure, you&#8217;ve been reloading the eclipse.org/downloads web page once every minute over the past hours, you&#8217;ve been clicking on &#8216;Help&#8217; &#62; &#8216;Check for Updates&#8217; in your Indigo Eclipse package, you&#8217;ve been monitoring the cross-project-issues-dev mailing list. Okay, then I cannot tell you any news, but the participating projects at Eclipse shipped another coordinated Simultaneous Release [...]]]></description>
			<content:encoded><![CDATA[<p>Sure, you&#8217;ve been reloading the <a href="http://eclipse.org/downloads/" target="_blank">eclipse.org/downloads</a> web page once every minute over the past hours, you&#8217;ve been clicking on &#8216;Help&#8217; &gt; &#8216;Check for Updates&#8217; in your Indigo Eclipse package, you&#8217;ve been monitoring the <a href="http://dev.eclipse.org/mhonarc/lists/cross-project-issues-dev/msg07343.html">cross-project-issues-dev</a> mailing list.</p>
<p>Okay, <em>then</em> I cannot tell you any news, but the participating projects at Eclipse shipped another coordinated Simultaneous Release in time! This Indigo SR2 release contains many improvements and bug fixes, e.g. an update of the underlying platform to 3.7.2. It&#8217;s worth an update!</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://eclipsesource.com/blogs/2012/02/24/eclipse-indigo-sr2-released-in-time/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>RAP mobile &#8211; iOS and Android apps written in Java</title>
		<link>http://eclipsesource.com/blogs/2012/01/31/rap-mobile-ios-and-android-apps-written-in-java/</link>
		<comments>http://eclipsesource.com/blogs/2012/01/31/rap-mobile-ios-and-android-apps-written-in-java/#comments</comments>
		<pubDate>Tue, 31 Jan 2012 17:28:00 +0000</pubDate>
		<dc:creator>Jochen Krause</dc:creator>
				<category><![CDATA[eclipse]]></category>
		<category><![CDATA[news]]></category>
		<category><![CDATA[syndicate]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[iOS]]></category>
		<category><![CDATA[mobile]]></category>
		<category><![CDATA[rap]]></category>
		<category><![CDATA[rap mobile]]></category>

		<guid isPermaLink="false">http://eclipsesource.com/blogs/?p=6989</guid>
		<description><![CDATA[Industry experts have predicted that mobile computing is going to have a huge impact on the software industry. I agree. That’s why we asked ourselves if OSGi, RAP and Eclipse RT can help overcome some of the challenges in mobile app development. Some of the most common problems involved in mobile development include dealing with [...]]]></description>
			<content:encoded><![CDATA[<p>Industry experts have predicted that mobile computing is going to have a huge impact on the software industry. I agree. That’s why we asked ourselves if <a href="http://eclipse.org/equinox/">OSGi</a>, <a href="http://eclipse.org/rap/">RAP</a> and Eclipse RT can help overcome some of the challenges in mobile app development.</p>
<p>Some of the most common problems involved in mobile development include dealing with multi-platform, security and maturity of the available platforms. But does multi-platform really matter with iOS breaking adoption records? I am sure that Google and Microsoft believe that their platforms will become breakthrough successes as well. While no one can make a definitive statement about their future success, I don’t think that anyone would bet a fortune on their failure either. This leaves us with three options for addressing multi-platform: <a href="http://www.html5rocks.com/en/">HTML5</a>, development for each platform or making a bet on which will be the most successful.</p>
<p>HTML5 is great technology &#8211; not only for mobile &#8211; but there is a growing body of <a href="http://www.nytimes.com/2012/01/02/technology/hewlett-packards-touchpad-was-built-on-flawed-software-some-say.html?_r=4&amp;pagewanted=all">lessons learned the hard way</a>. Our own experience revealed that it is easy to get started with HTML5 and that the state-of-the-art JavaScript libraries look really great. But when it comes to running and using the apps the excitement mostly turned into disillusion. The other two options did not seem like good solutions for us, so we decided to add another option: <a href="http://rapmobile.eclipsesource.com">RAP mobile</a>.</p>
<p style="text-align: center;"><a href="http://rapmobile.eclipsesource.com"><img class="size-full wp-image-6994 aligncenter" title="logo" src="http://eclipsesource.com/blogs/wp-content/uploads/2012/01/logo.png" alt="logo RAP mobile   iOS and Android apps written in Java" width="300" height="42" /></a></p>
<p style="text-align: left;">RAP mobile gives us some key advantages over the alternatives.  First, it allows multi-platform development in Java.  It uses the iOS and Android native widget toolkits for rendering the user interface with optimal performance and native look and feel.  And, it provides a mature and Open Source platform for writing and deploying business applications on standard JEE servers. It also provides a solution for common data security concerns with mobile devices.</p>
<p>Today we launched the RAP mobile developer preview program and the RAP mobile project site. If you are curious about how RAP mobile works and what it has to offer visit <a href="http://rapmobile.eclipsesource.com">http://rapmobile.eclipsesource.com</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://eclipsesource.com/blogs/2012/01/31/rap-mobile-ios-and-android-apps-written-in-java/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>Javascript validation with JSHint in Eclipse</title>
		<link>http://eclipsesource.com/blogs/2012/01/26/javascript-validation-with-jshint-eclipse/</link>
		<comments>http://eclipsesource.com/blogs/2012/01/26/javascript-validation-with-jshint-eclipse/#comments</comments>
		<pubDate>Wed, 25 Jan 2012 22:07:00 +0000</pubDate>
		<dc:creator>Ralf Sternberg</dc:creator>
				<category><![CDATA[eclipse]]></category>
		<category><![CDATA[news]]></category>
		<category><![CDATA[syndicate]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://eclipsesource.com/blogs/?p=6965</guid>
		<description><![CDATA[Besides all the Java code in the RAP project, we also have more than 250 JavaScript files which total up to 75k lines of code. For such an amount of code, you should have some kind of code analysis that detects common coding problems like unintentional global variables. We use the JSEclipse plug-in for JavaScript [...]]]></description>
			<content:encoded><![CDATA[<p>Besides all the Java code in the <a href="http://eclipse.org/rap">RAP</a> project, we also have more than 250 JavaScript files which total up to 75k lines of code. For such an amount of code, you should have some kind of code analysis that detects common coding problems like unintentional global variables. We use the JSEclipse plug-in for JavaScript editing which detects some, but not many JavaScript problems.</p>
<p>A while ago, we&#8217;ve tried to use <a href="http://jslint.com/">JSLint</a>, a tool written by JavaScript guru Douglas Crockford. Unfortunately, this tools produces several thousand warnings on our code base, many of them were not really problems but debatable coding style issues and there was no way to turn them off. JSLint&#8217;s lack of customizability recently lead to a <a href="http://anton.kovalyov.net/2011/02/20/why-i-forked-jslint-to-jshint/">fork</a> named <a href="http://www.jshint.com/">JSHint</a> that is going to provide more flexible <a href="http://www.jshint.com/options/">configuration options</a>.</p>
<p>Like JSLint, JSHint is written in JavaScript, but can be run on the command line using tools like <a href="http://www.mozilla.org/rhino/">Rhino</a> or JavaScriptCore. I tried JSHint on our codebase with good results using a shell script that runs it on top of Rhino. Unfortunately, checking all our 250+ *.js files keeps my machine busy for 5 minutes and 40 seconds and effectively turns it into a fan heater. This is not because JSHint itself is so demanding, but because for every file, a JVM has to be started, Rhino has to be loaded, then Rhino has to parse and load the JSHint JavaScript library, and then finally, jshint can parse and validate the source file.</p>
<p>Encouraged by the good results I tried to find a solution that doesn&#8217;t have this overhead. And as an Eclipse hacker and user, I certainly wanted to integrate the tool into my daily working environment. The result is a simple, yet efficient <a href="http://github.eclipsesource.com/jshint-eclipse/">JSHint Eclipse integration</a> that validates the same bunch of *.js files in less than 15 seconds.</p>
<p><a href="http://eclipsesource.com/blogs/wp-content/uploads/2012/01/jshint-eclipse-screenshot.png"><img class="aligncenter wp-image-6969" title="jshint-eclipse" src="http://eclipsesource.com/blogs/wp-content/uploads/2012/01/jshint-eclipse-screenshot.png" alt="jshint eclipse screenshot Javascript validation with JSHint in Eclipse" width="600" height="430" /></a></p>
<p>This speedup could be achieved by exploiting the way Eclipse builds projects: It uses the same builder instance to visit all files of the project recursively. That makes it possible to load and configure the JSHint library only once for the entire project and reuse it for all files being checked. Of course, validating all files of a project is only necessary for a full rebuild. During normal work, single files are being validated instantly when they have changed.</p>
<p>Although the configuration options are still somewhat basic, this integration proved to be very helpful already. I thought that it may be useful for others as well and decided to build and publish a first version. It&#8217;s available on the <a href="http://github.eclipsesource.com/jshint-eclipse/">jshint-eclipse page</a>. There&#8217;s an update site that let&#8217;s you install the plug-in right into your Eclipse IDE. If you find the plug-in useful, have ideas for improvements, find a problem or want to contribute, I&#8217;m happy to hear about it. To report problems, please use the <a href="https://github.com/eclipsesource/jshint-eclipse/issues">github issue tracker</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://eclipsesource.com/blogs/2012/01/26/javascript-validation-with-jshint-eclipse/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Eclipse Juno M4: RAP speaks JSON</title>
		<link>http://eclipsesource.com/blogs/2011/12/16/eclipse-juno-m4-rap-speaks-json/</link>
		<comments>http://eclipsesource.com/blogs/2011/12/16/eclipse-juno-m4-rap-speaks-json/#comments</comments>
		<pubDate>Fri, 16 Dec 2011 16:32:19 +0000</pubDate>
		<dc:creator>Ralf Sternberg</dc:creator>
				<category><![CDATA[eclipse]]></category>
		<category><![CDATA[news]]></category>
		<category><![CDATA[syndicate]]></category>
		<category><![CDATA[juno]]></category>
		<category><![CDATA[new and noteworthy]]></category>
		<category><![CDATA[protocol]]></category>
		<category><![CDATA[rap]]></category>

		<guid isPermaLink="false">http://eclipsesource.com/blogs/?p=6825</guid>
		<description><![CDATA[In the RAP framework, the widgets in a website are remotely controlled by the web server. The server does this by sending messages to the client in response to Ajax requests. Until now, those messages used to contain proprietary JavaScript that has been evaluated by the browser. Apart from the drawbacks of using eval to [...]]]></description>
			<content:encoded><![CDATA[<p>In the <a href="http://eclipse.org/rap">RAP</a> framework, the widgets in a website are remotely controlled by the web server. The server does this by sending messages to the client in response to Ajax requests. Until now, those messages used to contain proprietary JavaScript that has been evaluated by the browser. Apart from the drawbacks of using <em>eval</em> to process server responses, this tightly couples RAP to its default browser client. The messages were so specific that only this client could understand them.</p>
<p>One of our goals for RAP 1.5 is to open the framework for alternative client implementations. After all, the messages from the server contain precise rendering commands that are not at all specific to JavaScript. Commands like &#8220;create a button with text &#8216;<code>Ok</code>&#8216;, set its size to <code>190x25px</code>, and place it at pos <code>(23,42)</code>&#8221; or &#8220;change the text color of the label with id &#8216;<code>w47</code>&#8216; to &#8216;<code>#ff0000</code>&#8216;&#8221; can be rendered by any client that is able to create and manipulate widgets. It doesn&#8217;t have to be a JavaScript client, also clients written in other languages like Java or Objective C can implement it. Clients can render widgets with any UI technology, be it SVG or even a mobile device&#8217;s native widget set.</p>
<p>To allow for those cases, we exchanged the communication format with a simple <a href="http://wiki.eclipse.org/RAP/Protocol">predefined format</a> based on <a href="http://json.org/">JSON</a>. With the <a href="http://eclipse.org/rap/noteworthy/1.5/news_M4.php">M4 build published today</a>, all responses from a RAP server are now plain JSON. This also makes the debugging much easier, since developer tools like <a href="http://getfirebug.com">Firebug</a> display the structure of a message.</p>
<p><a href="http://eclipsesource.com/blogs/wp-content/uploads/2011/12/RAP-Firebug-JSON.png"><img class="aligncenter size-full wp-image-6828" title="RAP Session in Firebug (JSON)" src="http://eclipsesource.com/blogs/wp-content/uploads/2011/12/RAP-Firebug-JSON.png" alt="RAP Firebug JSON Eclipse Juno M4: RAP speaks JSON" width="600" height="301" /></a></p>
<p>When <a href="http://eclipsesource.com/blogs/tag/protocol/">designing the protocol</a>, we took great care not to limit the exchange format to widgets. Instead, we created a generic synchronization protocol for any kind of objects. Objects are identified with a unique id, and every operation is related to a target object that is referenced by its unique id. There are different types of operations: one to create an object, one to destroy it, one to change some properties on an object, etc. Every message from the server contains a list of operations, besides some meta information.</p>
<p>You&#8217;ve guessed that we already have some prototypes for alternative RAP clients in progress. We&#8217;ll write about them soon&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://eclipsesource.com/blogs/2011/12/16/eclipse-juno-m4-rap-speaks-json/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Effective Mockito Part 4</title>
		<link>http://eclipsesource.com/blogs/2011/10/17/effective-mockito-part-4/</link>
		<comments>http://eclipsesource.com/blogs/2011/10/17/effective-mockito-part-4/#comments</comments>
		<pubDate>Mon, 17 Oct 2011 07:55:31 +0000</pubDate>
		<dc:creator>Holger Staudacher</dc:creator>
				<category><![CDATA[craftsmanship]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[syndicate]]></category>
		<category><![CDATA[debugging]]></category>
		<category><![CDATA[Mocking]]></category>
		<category><![CDATA[Mockito]]></category>
		<category><![CDATA[test driven]]></category>
		<category><![CDATA[testing]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://eclipsesource.com/blogs/?p=6545</guid>
		<description><![CDATA[This Effective Mockito Post will be IDE specific again but related to the last post on Mockito&#8217;s spies. If you&#8217;ve read Part 3 you should now be familiar how to use them to &#8220;pseudo mock&#8221; statics. When writing code it often comes to a point where we want to debug using single step debugging. When [...]]]></description>
			<content:encoded><![CDATA[<p>This Effective Mockito Post will be IDE specific again but related to the <a href="http://eclipsesource.com/blogs/2011/10/13/effective-mockito-part-3/">last post</a> on <a href="http://docs.mockito.googlecode.com/hg/latest/org/mockito/Mockito.html#spy(T)">Mockito&#8217;s spies</a>. If you&#8217;ve read Part 3 you should now be familiar how to use them to &#8220;pseudo mock&#8221; statics. When writing code it often comes to a point where we want to debug using single step debugging. When using <a href="http://code.google.com/p/mockito/">Mockito</a> and especially when spies come into the game there is still something pretty annoying.</p>
<p>That is, when we want to debug our Object-Under-Test&#8217;s real method and the object is a spy. When we try to step into the object&#8217;s method we always land in internal Mockito code. After a little reading we can drill deeper but the next landing place is in java.lang.reflect code and so on. To be honest, this is really not the nicest way to debug code. What I want is that regardless of whether I use spies or not, when I step into an object&#8217;s method I land directly in this method. In the past my workaround was to set a breakpoint in the test at the method call and in the method itself. This enabled me to stop at the first point and resume the execution until it stops the second time in the method. But there is a much more elegant way. Let&#8217;s see how we can do this.</p>
<p>First of all, let&#8217;s take a look at an example. The code below shows a simple test from the <a href="http://eclipsesource.com/blogs/2011/10/13/effective-mockito-part-3/">last Effective Mockito post</a>. The test uses a spy to &#8220;pseudo mock&#8221; a static method. We set a breakpoint in the line of the <code>isPropertySet</code> call and debug this method. Sadly when doing this we run into the effect described above.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">@RunWith<span style="color: #009900;">&#40;</span> MockitoJUnitRunner.<span style="color: #000000; font-weight: bold;">class</span> <span style="color: #009900;">&#41;</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> MyObjectText <span style="color: #009900;">&#123;</span>
&nbsp;
  @Spy
  <span style="color: #000000; font-weight: bold;">private</span> MyObject objectUnderTest<span style="color: #339933;">;</span>
&nbsp;
  @Test
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> testIsPropertySet<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    doReturn<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&quot;some runtime property&quot;</span> <span style="color: #009900;">&#41;</span>.<span style="color: #006633;">when</span><span style="color: #009900;">&#40;</span> objectUnderTest <span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getProperty</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000066; font-weight: bold;">boolean</span> isPropertySet <span style="color: #339933;">=</span> objectUnderTest.<span style="color: #006633;">isPropertySet</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    assertFalse<span style="color: #009900;">&#40;</span> isPropertySet <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>When using <a href="http://www.eclipse.org/downloads/">Eclipse</a> there is a very simple way to avoid this called &#8220;Step Filtering&#8221;. We can add packages or classes to this Filterlist using the preferences. When filters are activated the classes will automatically be skipped during debugging. By setting a filter like the one in the screenshot below we can simply step over the Mockito and reflection code.</p>
<p><a href="http://eclipsesource.com/blogs/wp-content/uploads/2011/10/stepfilters.png"><img class="aligncenter size-full wp-image-6553" title="stepfilters" src="http://eclipsesource.com/blogs/wp-content/uploads/2011/10/stepfilters.png" alt="stepfilters Effective Mockito Part 4" width="652" height="599" /></a></p>
<p>If you are not using Eclipse there is probably a similar way to achieve this with your IDE. It would be cool if you would share this tip with us in a comment. Meantime, I hope that Step Filtering is as helpful to you as it is for me.  Finally, I want to thank <a href="http://eclipsesource.com/blogs/author/fwaibel/">Fluffi</a> and <a href="http://www.codeaffine.com/author/fappel/">Frank</a> for getting me to dive into this.</p>
<p><a href="http://twitter.com/hstaudacher"><img src="http://download.eclipsesource.com/~hstaudacher/followme.png" title="Follow @hstaudacher" width="191" height="58" border="0" alt="followme Effective Mockito Part 4" /></a></p>
<p><strong><em>Read the other Effective Mockito posts:</em></strong></p>
<ul>
<li><a href="http://eclipsesource.com/blogs/2011/09/19/effective-mockito-part-1/">Effective Mockito Part 1</a></li>
<li><a href="http://eclipsesource.com/blogs/2011/09/29/effective-mockito-part-2/">Effective Mockito Part 2</a></li>
<li><a href="http://eclipsesource.com/blogs/2011/10/13/effective-mockito-part-3/">Effective Mockito Part 3</a></li>
<li><a href="http://eclipsesource.com/blogs/2011/10/17/effective-mockito-part-4/">Effective Mockito Part 4</a></li>
<li><a href="http://eclipsesource.com/blogs/2011/11/16/effective-mockito-part-5/">Effective Mockito Part 5</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://eclipsesource.com/blogs/2011/10/17/effective-mockito-part-4/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Lightweight OSGi Applications using RAP&#8217;s Widget Toolkit</title>
		<link>http://eclipsesource.com/blogs/2011/08/29/lightweight-osgi-applications-using-raps-widget-toolkit/</link>
		<comments>http://eclipsesource.com/blogs/2011/08/29/lightweight-osgi-applications-using-raps-widget-toolkit/#comments</comments>
		<pubDate>Mon, 29 Aug 2011 20:04:06 +0000</pubDate>
		<dc:creator>Ralf Sternberg</dc:creator>
				<category><![CDATA[eclipse]]></category>
		<category><![CDATA[OSGi]]></category>
		<category><![CDATA[syndicate]]></category>
		<category><![CDATA[milestone]]></category>
		<category><![CDATA[new and noteworthy]]></category>
		<category><![CDATA[rap]]></category>

		<guid isPermaLink="false">http://eclipsesource.com/blogs/?p=6394</guid>
		<description><![CDATA[Update 2: The new interfaces have been renamed again in RAP 1.5M7. Please refer to this post for the details and check out the updated code example. Update: APIs have changed a bit meanwhile, so I updated the code below accordingly. Entry points are now registered by path, and JEE_COMPLATIBILTIY has become the default mode, [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Update 2:</strong> The new interfaces have been renamed again in RAP 1.5M7. Please refer to <a href="http://eclipsesource.com/blogs/2012/05/09/the-new-application-api-in-rap/">this post</a> for the details and check out the updated <a href="https://github.com/ralfstx/rap-helpers/tree/master/example.rwt.simple">code example</a>.</p>
<p><strong>Update:</strong> APIs have changed a bit meanwhile, so I updated the code below accordingly. Entry points are now registered by path, and JEE_COMPLATIBILTIY has become the default mode, which makes the main loop obsolete in this kind of applications.</p>
<p>RAP is well known as an &#8220;RCP for the web browser&#8221;, including workbench, extension points, and all that stuff. Indeed, one of the greatest features of RAP is its ability to reuse RCP code in web applications. But did you know that you can also use RAP&#8217;s widget toolkit (RWT) to create simple web UIs for your applications, without the heavy weight Eclipse UI stack?</p>
<p>With RAP 1.5, you can now simply include RWT in any OSGi application. You only need two bundles: <code>org.eclipse.rap.rwt</code> (the RAP widget toolkit itself) and <code>org.eclipse.rap.rwt.osgi</code> which integrates RWT with the OSGi HTTP service. There are no tie-ins with Equinox anymore, thus RAP also works with other OSGi containers.</p>
<p>To create a UI with RWT, you have to implement the interface <code>IEntryPoint</code>, here&#8217;s a simple example:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">int</span> createUI<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #666666; font-style: italic;">// Create a maximized top-level shell without trimmings that represents the main &quot;page&quot;</span>
    Display display <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Display<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    Shell page <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Shell<span style="color: #009900;">&#40;</span> display, SWT.<span style="color: #006633;">NO_TRIM</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    page.<span style="color: #006633;">setMaximized</span><span style="color: #009900;">&#40;</span> <span style="color: #000066; font-weight: bold;">true</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    page.<span style="color: #006633;">setLayout</span><span style="color: #009900;">&#40;</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">GridLayout</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// Create contents of main shell</span>
    <span style="color: #003399;">Label</span> label <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Label</span><span style="color: #009900;">&#40;</span> page, SWT.<span style="color: #006633;">NONE</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    label.<span style="color: #006633;">setText</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&quot;Hello&quot;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #003399;">Button</span> button <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Button</span><span style="color: #009900;">&#40;</span> page, SWT.<span style="color: #006633;">PUSH</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    button.<span style="color: #006633;">setText</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&quot;World&quot;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// Open the top-level shell and run the main loop to process events</span>
    page.<span style="color: #006633;">layout</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    page.<span style="color: #006633;">open</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span></pre></div></div>

<p>Now what&#8217;s new is that, instead of registering this entry point with an extension point, you can now implement the new <code>ApplicationConfigurator</code> interface like this:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> configure<span style="color: #009900;">&#40;</span> <span style="color: #003399;">Context</span> context <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    context.<span style="color: #006633;">addEntryPoint</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&quot;/simple&quot;</span>, SimpleEntryPoint.<span style="color: #000000; font-weight: bold;">class</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    context.<span style="color: #006633;">addBranding</span><span style="color: #009900;">&#40;</span> <span style="color: #000000; font-weight: bold;">new</span> AbstractBranding<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      @Override
      <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> getServletName<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #0000ff;">&quot;simple&quot;</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span>
      @Override
      <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> getTitle<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #0000ff;">&quot;Simple RWT Example&quot;</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span></pre></div></div>

<p>When this implementation is registered as an OSGi service, you can access the UI with a web browser:<br />
<a href="http://eclipsesource.com/blogs/wp-content/uploads/2011/08/RWTSimple.png"><br />
<img src="http://eclipsesource.com/blogs/wp-content/uploads/2011/08/RWTSimple.png" alt="RWTSimple Lightweight OSGi Applications using RAPs Widget Toolkit" title="RWT Simple Example" width="550" height="251" class="aligncenter size-full wp-image-6399" /></a><br />
You can check out the example project <code>example.rwt.simple</code> from my <a href="https://github.com/ralfstx/rap-helpers">rap-helpers repository on github</a>. Please note that for this example to run you need declarative services in your target platform, which are not included in the RAP 1.5M1 target but in the latest nightly build. Also be aware that the new API is still provisional and may change again until the final release.</p>
<p>Kudos to Frank Appel, who contributed the new OSGi integration. He has a more detailed introduction to the new OSGi integration and examples for configuration in <a href="http://www.codeaffine.com/2011/08/26/raprwt-osgi-integration/">his blog</a>. BTW, Frank and me plan to demo the possibilities of this approach in our talk <a href="http://www.eclipsecon.org/sessions/dynamic-web-applications-osgi-and-rap">Dynamic web applications with OSGi and RAP</a> at the EclipseCon Europe &#8211; vote for it if you&#8217;re interested!</p>
]]></content:encoded>
			<wfw:commentRss>http://eclipsesource.com/blogs/2011/08/29/lightweight-osgi-applications-using-raps-widget-toolkit/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<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>Using OSGi services to single-source an RCP and RAP Application</title>
		<link>http://eclipsesource.com/blogs/2011/06/20/using-osgi-services-to-single-source-an-rcp-and-rap-application/</link>
		<comments>http://eclipsesource.com/blogs/2011/06/20/using-osgi-services-to-single-source-an-rcp-and-rap-application/#comments</comments>
		<pubDate>Mon, 20 Jun 2011 08:18:23 +0000</pubDate>
		<dc:creator>Holger Staudacher</dc:creator>
				<category><![CDATA[eclipse]]></category>
		<category><![CDATA[OSGi]]></category>
		<category><![CDATA[syndicate]]></category>
		<category><![CDATA[GitHub]]></category>
		<category><![CDATA[rap]]></category>
		<category><![CDATA[rcp]]></category>
		<category><![CDATA[services]]></category>
		<category><![CDATA[Single Sourcing]]></category>

		<guid isPermaLink="false">http://eclipsesource.com/blogs/?p=6083</guid>
		<description><![CDATA[Probably one of RAP’s best known features is its single-sourcing capabilities. Some time ago we created a guide on Single-Sourcing RCP and RAP applications. The guide recommended a technique where a facade and fragments were used to invoke the RCP or RAP implementation during runtime. With this post I want to show you how to [...]]]></description>
			<content:encoded><![CDATA[<p>Probably one of <a href="http://eclipse.org/rap">RAP’s</a> best known features is its single-sourcing capabilities. Some time ago we created a <a href="http://eclipsesource.com/en/info/rcp-rap-single-sourcing-guideline/">guide on Single-Sourcing RCP and RAP applications</a>. The guide recommended a technique where a facade and fragments were used to invoke the RCP or RAP implementation during runtime. With this post I want to show you how to achieve the same the <a href="http://www.osgi.org/Main/HomePage">OSGi</a> way.</p>
<p>For single-sourcing a RAP or RCP application, its straightforward to use the power of <a href="http://www.osgi.org/Main/HomePage">OSGi </a>because it&#8217;s included in both platforms out-of-the-box. OSGi has a central concept called services which are simply POJOs and are used to allow communication between modules. And, you can register or resolve services at any time in your code.</p>
<p>The basic Idea behind using OSGi services for single-sourcing is as follows. We need to extract all the things that vary into separate, platform specific bundles. To use the different implementations, we have to create an interface in a “common” bundle that contains the methods we want to use. The platform specific bundles have to register an implementation of this interface as a service. In the “common” bundle we can reference the registered services and use them to get the platform specific stuff. More specifically, we register a <a href="http://eclipse.org/rap">RAP</a> implementation in a “rap” bundle and an RCP implementation in an “rcp” bundle. The only thing we need to do then is to start the right bundles on the associated platform to get the right service.</p>
<p>With this solution we can extract the platform specific stuff into separate bundles and we don&#8217;t have to rely on fragments. So enough talking. Let&#8217;s look at some code. I decided to create a very simple single-sourcing interface which can be used to get the WidgetUtil.CUSTOM_VARIANT constant value. This constant exists only in RAP so, it&#8217;s a good example for showing how to handle the differences.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">interface</span> ISingleSourcingService <span style="color: #009900;">&#123;</span>
  <span style="color: #003399;">String</span> getCustomVariantString<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>I have created three bundles: one that contains the application which is entitled &#8220;com.eclipsesource.app&#8221; and one for each platform. These are called &#8220;com.eclipsesource.app.rap&#8221; and &#8220;com.eclipsesource.app.rcp&#8221;. Both platform bundles implement the interface.<br />
RAP:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">  @Override
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> getCustomVariantString<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">return</span> WidgetUtil.<span style="color: #006633;">CUSTOM_VARIANT</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span></pre></div></div>

<p>RCP:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">  @Override
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> getCustomVariantString<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #666666; font-style: italic;">// There are no custom variants in RCP</span>
    <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span></pre></div></div>

<p>And both bundles are registering the service in their Activator during the start method call.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> start<span style="color: #009900;">&#40;</span> BundleContext bundleContext <span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">Exception</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #003399;">Activator</span>.<span style="color: #006633;">context</span> <span style="color: #339933;">=</span> bundleContext<span style="color: #339933;">;</span>
    registration <span style="color: #339933;">=</span> context.<span style="color: #006633;">registerService</span><span style="color: #009900;">&#40;</span> ISingleSourcingService.<span style="color: #000000; font-weight: bold;">class</span>.<span style="color: #006633;">getName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>,
                                            <span style="color: #000000; font-weight: bold;">new</span> RAPSingelSourcingService<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>,
                                            <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span></pre></div></div>

<p>When it comes to using the service in the common &#8220;app&#8221; bundle we can use a ServiceTracker to get the service implementation (<a href="http://eclipsesource.com/blogs/2009/05/12/osgi-declarative-services/">you can also use DS</a>).</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">  <span style="color: #000000; font-weight: bold;">private</span> ISingleSourcingService getSingleSourcingService<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #666666; font-style: italic;">// We use a tracker to get the service. We also can use DS to get it.</span>
    Bundle bundle <span style="color: #339933;">=</span> FrameworkUtil.<span style="color: #006633;">getBundle</span><span style="color: #009900;">&#40;</span> getClass<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    BundleContext context <span style="color: #339933;">=</span> bundle.<span style="color: #006633;">getBundleContext</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    ServiceTracker tracker
      <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ServiceTracker<span style="color: #009900;">&#40;</span> context,
                            ISingleSourcingService.<span style="color: #000000; font-weight: bold;">class</span>.<span style="color: #006633;">getName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>,
                            <span style="color: #000066; font-weight: bold;">null</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    tracker.<span style="color: #006633;">open</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    ISingleSourcingService service <span style="color: #339933;">=</span> tracker.<span style="color: #006633;">getService</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    tracker.<span style="color: #006633;">close</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000000; font-weight: bold;">return</span> service<span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span></pre></div></div>

<p>The only thing we have to do now is to create two launch configurations which contain the associated platform-specific bundle.</p>
<p>That’s it! You can find the sources in <a href="https://github.com/eclipsesource/rap-single-sourcing">this github repository</a>. Have fun using OSGi services to single-source applications.</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://eclipsesource.com/blogs/2011/06/20/using-osgi-services-to-single-source-an-rcp-and-rap-application/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

