<?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>Peter Friese &#187; Computer</title>
	<atom:link href="http://www.peterfriese.de/category/computer/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.peterfriese.de</link>
	<description>Xtext, DSLs, Eclipse, iPhone</description>
	<lastBuildDate>Tue, 27 Jul 2010 21:36:19 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Don&#8217;t attend the Eclipse DemoCamp in Hamburg this Friday&#8230;</title>
		<link>http://www.peterfriese.de/dont-attend-the-eclipse-democamp-in-hamburg-this-friday/</link>
		<comments>http://www.peterfriese.de/dont-attend-the-eclipse-democamp-in-hamburg-this-friday/#comments</comments>
		<pubDate>Tue, 06 Jul 2010 22:36:08 +0000</pubDate>
		<dc:creator>Peter Friese</dc:creator>
				<category><![CDATA[Conferences]]></category>
		<category><![CDATA[Eclipse]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[democamp]]></category>
		<category><![CDATA[hamburg]]></category>

		<guid isPermaLink="false">http://www.peterfriese.de/?p=522</guid>
		<description><![CDATA[... if you're not interested in meeting local (and non-local) Eclipse enthusiasts and committers, learning something about Eclipse, Git, SWT, Qt, e4 and the iPhone, watching some nice Pixar short films in a cosy cinema, and frosty beverages.

On the other hand, if you are interested in at least one of those things, I encourage you[...]]]></description>
			<content:encoded><![CDATA[<p>... if you're not interested in meeting local (and non-local) Eclipse enthusiasts and committers, learning something about Eclipse, Git, SWT, Qt, e4 and the iPhone, watching some nice Pixar short films in a cosy cinema, and frosty beverages.<br />
<span id="more-522"></span><br />
On the other hand, if you <strong>are</strong> interested in at least one of those things, I encourage you to sign up for the DemoCamp <a href="http://wiki.eclipse.org/Eclipse_DemoCamps_Helios_2010/Hamburg">here</a> or <a href="http://www.twitter.com/peterfriese">ping me on Twitter</a> or just send me a mail so I can add you to the list.</p>
<p>Here's the detailed program:</p>
<ul>
<li>18:00 - 18:40 Welcome / Short films</li>
<li>18:45 - 19:15 <a href="http://twitter.com/vogella">Lars Vogel</a>, Developing with e4</li>
<li>19:20 - 19:50 <a href="http://twitter.com/szarnekow">Sebastian Zarnekow</a>, Xtext - A Language Development Framework, Live demo of new and noteworthy features in Xtext</li>
<li>19:50 - 20:20 Break + Surprise</li>
<li>20:20 - 20:35 <a href="http://www.xing.com/profile/Juergen_Becker">Jürgen Becker</a>, UI with style - a new SWT platform that is based on Qt</li>
<li>20:40 - 21:10 <a href="http://twitter.com/ralfebert">Ralf Ebert</a>, Introduction to distributed version control with Git</li>
<li>21:15 - 21:45 <a href="http://twitter.com/HBehrens">Heiko Behrens</a>, Build your own iPhone app within minutes - thanks to Eclipse</li>
<li>21:45 - open end Closing remarks / Frosty beverages</li>
</ul>
<p>The DemoCamp will take place in the <a href="http://www.magazinfilmkunst.de">MAGAZIN Cinema</a> in Hamburg (<a href="http://www.magazinfilmkunst.de/anfahrt.html">directions</a>) and yes, we will show some short films at the beginning of the camp for your entertainment.</p>
<p><a href="http://twitter.com/martinlippert">Martin Lippert</a> and I are happy to be able to present a great lineup of speakers and demos, so do yourself a favor and join us this Friday from 18:00 (6pm).</p>
<p>As always, the event if <strong>free of charge</strong> thanks to the generous support of <a href="http://www.it-agile.de/">it-agile</a>, <a href="http://www.itemis.com">itemis</a> and the <a href="http://www.eclipse.org">Eclipse Foundation</a>.</p>
<p>Looking forward to seeing you on Friday!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.peterfriese.de/dont-attend-the-eclipse-democamp-in-hamburg-this-friday/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>OSGi &amp; Servlets: Flexibility by Simplicity</title>
		<link>http://www.peterfriese.de/osgi-servlets-flexibility-by-simplicity/</link>
		<comments>http://www.peterfriese.de/osgi-servlets-flexibility-by-simplicity/#comments</comments>
		<pubDate>Mon, 26 Apr 2010 08:24:03 +0000</pubDate>
		<dc:creator>Peter Friese</dc:creator>
				<category><![CDATA[Eclipse]]></category>
		<category><![CDATA[OSGi]]></category>
		<category><![CDATA[cloud]]></category>
		<category><![CDATA[J2EE]]></category>
		<category><![CDATA[JEE]]></category>

		<guid isPermaLink="false">http://www.peterfriese.de/?p=426</guid>
		<description><![CDATA[Strangely enough, simple things tend to be more flexible than complex things. I bet you too have seen people go to great lengths to ensure a certain solution provides utmost flexibility. Often, this flexibility isn't needed, so you're introducing accidental complexity.
In a recent post, I showed you how to create a plain servlet and register[...]]]></description>
			<content:encoded><![CDATA[<p><strong>Strangely enough</strong>, simple things tend to be more flexible than complex things. I bet you too have seen people go to great lengths to ensure a certain solution provides utmost flexibility. <span id="more-426"></span>Often, this flexibility isn't needed, so you're introducing accidental complexity.</p>
<p>In <a href="http://www.peterfriese.de/osgi-servlets-a-happy-marriage/">a recent post</a>, I showed you how to create a plain servlet and register it in an OSGi environment. As both <a href="http://eclipsesource.com/blogs/author/jeff/">Jeff</a> and <a href="http://www.composent.com/">Scott</a> pointed out, my using a <em>ServiceTracker</em> to register and unregister the servlet is a little bit clumsy and can be improved by using Declarative Services.</p>
<p>I highly recommend reading chapter 15 in "<a href="http://my.safaribooksonline.com/9780321561510">OSGi and Equinox</a>", but in a nutshell Declarative Services allow you to define <em>components</em> which can provide and consume <em>services</em>. <em>Binding</em> and <em>unbinding</em> references between components and services is performed by the DS runtime (also known as the Service Component Runtime).</p>
<p>Without further ado, here are the changes I had to make to DS-ify my simple servlet:</p>
<ol>
<li>Remove the activator. Yes, that's true: we don't need an Activator any more. Delete the class and also remove it from <em>META-INF/MANIFEST.MF</em></li>
<li>Delete <em>HttpServiceTracker</em>. Registering the servlet with the <em>HTTPService</em> will be handled by the DS runtime.</li>
<li>Implement a <em>component</em> to register and unregister the servlet with the <em>HttpService</em>:
<pre class="java"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> SimpleComponent <span style="color: #66cc66;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">final</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AString+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">String</span></a> SERVLET_ALIAS = <span style="color: #ff0000;">&quot;/hellods&quot;</span>;
  <span style="color: #000000; font-weight: bold;">private</span> HttpService httpService;
&nbsp;
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #993333;">void</span> setHttpService<span style="color: #66cc66;">&#40;</span>HttpService httpService<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006600;">httpService</span> = httpService;
  <span style="color: #66cc66;">&#125;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #993333;">void</span> startup<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #66cc66;">&#123;</span>
      <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ASystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">System</span></a>.<span style="color: #006600;">out</span>.<span style="color: #006600;">println</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Staring up sevlet at &quot;</span> + SERVLET_ALIAS<span style="color: #66cc66;">&#41;</span>;
      SimpleServlet servlet = <span style="color: #000000; font-weight: bold;">new</span> SimpleServlet<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
      httpService.<span style="color: #006600;">registerServlet</span><span style="color: #66cc66;">&#40;</span>SERVLET_ALIAS, servlet, <span style="color: #000000; font-weight: bold;">null</span>, <span style="color: #000000; font-weight: bold;">null</span><span style="color: #66cc66;">&#41;</span>;
    <span style="color: #66cc66;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #66cc66;">&#40;</span>ServletException e<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
      e.<span style="color: #006600;">printStackTrace</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
    <span style="color: #66cc66;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #66cc66;">&#40;</span>NamespaceException e<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
      e.<span style="color: #006600;">printStackTrace</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
    <span style="color: #66cc66;">&#125;</span>
  <span style="color: #66cc66;">&#125;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #993333;">void</span> shutdown<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
    httpService.<span style="color: #006600;">unregister</span><span style="color: #66cc66;">&#40;</span>SERVLET_ALIAS<span style="color: #66cc66;">&#41;</span>;
  <span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre>
<p>As you can see, the <em>HttpService</em> will be injected into this component using it's setter method, <em>setHttpService</em>.</p>
</li>
<li>Register this component with the DS runtime by adding a component description:
<pre class="xml"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&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="font-weight: bold; color: black;">?&gt;</span></span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&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;">activate</span>=<span style="color: #ff0000;">&quot;startup&quot;</span>
  <span style="color: #000066;">deactivate</span>=<span style="color: #ff0000;">&quot;shutdown&quot;</span>
  <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;simple.ds.component&quot;</span><span style="font-weight: bold; color: black;">&gt;</span></span>
  <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;implementation</span>
    <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;simple.ds.servlet.SimpleComponent&quot;</span><span style="font-weight: bold; color: black;">/&gt;</span></span>
  <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;reference</span>
    <span style="color: #000066;">bind</span>=<span style="color: #ff0000;">&quot;setHttpService&quot;</span>
    <span style="color: #000066;">interface</span>=<span style="color: #ff0000;">&quot;org.osgi.service.http.HttpService&quot;</span><span style="font-weight: bold; color: black;">/&gt;</span></span>
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/scr:component<span style="font-weight: bold; color: black;">&gt;</span></span></span></pre>
<p>I saved this file in <em>OSGI-INF/component.xml</em> and added it to the <em>Service-Component</em> section of <em>META-INF/MANIFEST.MF</em>. In fact, as I used the <em>Create New OSGi Component</em> wizard, the wizard added the entry to the <em>ServiceComponent</em> section - it's really easy to forget this if you do it manually!</p>
</li>
</ol>
<p>That's it!</p>
<p><strong>Please note</strong> that I did not change the servlet implementation at all (apart form issuing a different text to make it easier to tell the servlets apart)!</p>
<p><strong>Before launching</strong>, please make sure to add <em>org.eclipse.equinox.ds</em> and <em>org.eclipse.equinox.util</em> to your launch config to enable Declarative Services.</p>
<p>The biggest advantage of this approach is that you do not have to take care of acquiring the <em>HTTPService</em>. The DS runtime will <em>only</em> activate your component when all prerequisites have been met, i.e., all dependencies are available. If the <em>HttpService</em> is not available for any reason, your component will not be started. This makes the code for registering the servlet simpler and cleaner.</p>
<p>You can <a href="http://code.google.com/p/peterfriese/source/browse/#svn/osgi/trunk/simple.ds.servlet">download the source for the DS-ified servlet</a> from my SVN repository on Google Code.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.peterfriese.de/osgi-servlets-flexibility-by-simplicity/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>OSGi &amp; Servlets: Deploying on Amazon EC2</title>
		<link>http://www.peterfriese.de/osgi-servlets-deploying-on-amazon-ec2/</link>
		<comments>http://www.peterfriese.de/osgi-servlets-deploying-on-amazon-ec2/#comments</comments>
		<pubDate>Thu, 15 Apr 2010 23:04:09 +0000</pubDate>
		<dc:creator>Peter Friese</dc:creator>
				<category><![CDATA[Eclipse]]></category>
		<category><![CDATA[OSGi]]></category>
		<category><![CDATA[Amazon EC2]]></category>
		<category><![CDATA[J2EE]]></category>
		<category><![CDATA[JEE]]></category>

		<guid isPermaLink="false">http://www.peterfriese.de/?p=422</guid>
		<description><![CDATA[Last week, I showed you how to create a very simple OSGi-based servlet and run it locally on Jetty. Today, I will show you how to deploy this servlet to an Amazon EC2 instance.

We will first set up an Amazon EC2 instance and then export the servlet and install it in this instance.
Setting up an[...]]]></description>
			<content:encoded><![CDATA[<p>Last week, <a href="http://www.peterfriese.de/osgi-servlets-a-happy-marriage/">I showed you how to create a very simple OSGi-based servlet</a> and run it locally on Jetty. Today, I will show you how to deploy this servlet to an Amazon EC2 instance.</p>
<p><span id="more-422"></span></p>
<p>We will first set up an Amazon EC2 instance and then export the servlet and install it in this instance.</p>
<h2>Setting up an Amazon EC2 instance</h2>
<p>Scott Lewis <a href="http://eclipseecf.blogspot.com/2010/03/osgieclipsert-in-amazon-cloud.html">was kind enough to prepare an Amazon EC2 Machine Image (AMI)</a> that already contains Jetty, Equinox and p2 - everything we need to get our servlet running. So let's use this AMI to provision our instance:</p>
<ol>
<li>Sign in to the <a href="https://console.aws.amazon.com/ec2/home">AWS web console</a></li>
<li>Click on <em>Launch instance</em> to create a new instance</li>
<li>In the <em>Request Instances Wizard</em>, jump over to the <em>Community AMIs</em> tab</li>
<li>Type <em>OSGi</em> in the search field to search for <strong><em>ami-69d93600</em></strong></li>
<li>Select the AMI</li>
<li>In the next step, you get to configure the instance. A small instance will do for now.</li>
<li>Leave the <em>Advanced Instance</em> options as-is</li>
<li>Next, you need to create a key pair (this will allow you to sign in to the instance using SSH). If you haven't created an EC2 instance before, select <em>Create a new Key Pair</em> and follow the instructions. Otherwise, select an existing key pair</li>
<li>To access the instance from outside using HTTP and SSH, you need to create and assign a <em>security group</em>. Make sure to add SSH and HTTP port configurations to this security group. Unfortunately, it is not possible to freely choose the port ranges, so we need to edit the security group after we're finished with the wizard.</li>
<li>On the summary page, review the configuration and click on <em>Launch</em> to actually start your instance.</li>
</ol>
<p>After a little while, the newly created instance will show up in the list of AMIs. You can test your instance by opening a terminal window and SSH'ing to your instance:</p>
<pre>
  ssh -i path/to/your/privatekey.pem root@ec2-xxx-xx-xx-xx.compute-1.amazonaws.com
</pre>
<p>You should be greeted with a prompt like this:</p>
<pre class="bash">        __|  __|_  <span style="color: #7a0874; font-weight: bold;">&#41;</span>  Fedora <span style="color: #000000;">8</span>
        _|  <span style="color: #7a0874; font-weight: bold;">&#40;</span>     /    <span style="color: #000000;">32</span>-bit
       ___|\___|___|
&nbsp;
Welcome to an EC2 Public Image
                      :- <span style="color: #7a0874; font-weight: bold;">&#41;</span>
   Base</pre>
<p>Start the EclipseRT server as follows:</p>
<pre class="bash"><span style="color: #7a0874; font-weight: bold;">cd</span> /<span style="color: #c20cb9; font-weight: bold;">env</span>/osgi_eclipsert36_sb_p2_jetty_7_0_1_linux_x86/jetty-distribution<span style="color: #000000;">-7.0</span><span style="color: #000000;">.1</span>.v20091125/
./eclipsert36.<span style="color: #c20cb9; font-weight: bold;">sh</span></pre>
<p>Your Eclipse RT Equinox server is now up and running. Time to export the servlet!</p>
<h2>Exporting the servlet</h2>
<p>We will export our simple servlet using a feature based update site, so it can be installed using p2.</p>
<p><strong>First,</strong> create a new feature project, naming it <em>simple.servlet.feature</em>. Provide the following details to the wizard:</p>
<ol>
<li><em>ID:</em> simple.servlet.feature</li>
<li><em>Version:</em> 1.0.0.qualifier</li>
<li><em>Name:</em> Simple Servlet Feature</li>
<li><em>Provider:</em> Your name</li>
</ol>
<p>Open the <em>Plug-ins</em> page and add <em>simple.servlet</em> to the list of packages plug-ins.</p>
<p><strong>Now,</strong> we can create the update site. It will only contain the feature we just created. Using the <em>New Update Site</em> wizard, create a new update site project, naming it <em>simple.servlet.updatesite</em>. Add the feature we just created to the list of features on the first page of the <em>site.xml</em> Update Site Map.</p>
<p><strong>When you're done with that, </strong>, you can build the update site by pressing the <em>Build All</em> button. This will build the servlet plug-in, the feature and finally the update site. After that, we're ready to deploy.</p>
<h2>Installing the servlet</h2>
<p>Installing the servlet into our Amazon EC2 instance is quite easy, as we can leverage p2:</p>
<p><strong>Using your favourite SFTP client,</strong> copy the entire update into the <em>/tmp</em> directory of your Amazon EC2 instance. When that's done, hop over to your terminal window that's connected to the OSGi console of your Eclipse RT server (remember, we started this server when setting up the Amazon EC2 instance). Issue the following commands:</p>
<pre class="bash">provaddrepo <span style="color: #c20cb9; font-weight: bold;">file</span>:/tmp/simple.servlet.updatesite
provliu
provinstall simple.servlet  <span style="color: #000000;">1.0</span><span style="color: #000000;">.0</span><span style="color: #000000;">.201004091446</span>
confapply</pre>
<p><strong>Make sure you use the correct version identifier, it is likely to be different from the one I used here!</strong></p>
<p>You can now list the installed bundles by invoking <em>ss</em>:</p>
<pre class="bash">ss
...
<span style="color: #000000;">38</span>      ACTIVE      org.eclipse.equinox.preferences_3<span style="color: #000000;">.3</span><span style="color: #000000;">.0</span>.v20100208
<span style="color: #000000;">39</span>      ACTIVE      org.eclipse.equinox.registry_3<span style="color: #000000;">.5</span><span style="color: #000000;">.0</span>.v20100301
<span style="color: #000000;">40</span>      ACTIVE      org.eclipse.equinox.security_1<span style="color: #000000;">.0</span><span style="color: #000000;">.200</span>.v20100301
<span style="color: #000000;">41</span>      ACTIVE      org.eclipse.equinox.server.examples.hello_1<span style="color: #000000;">.0</span><span style="color: #000000;">.0</span><span style="color: #000000;">.201003111015</span>
<span style="color: #000000;">42</span>      ACTIVE      org.eclipse.equinox.simpleconfigurator.manipulator_2<span style="color: #000000;">.0</span><span style="color: #000000;">.0</span>.v20100304
<span style="color: #000000;">43</span>      ACTIVE      org.eclipse.equinox.util_1<span style="color: #000000;">.0</span><span style="color: #000000;">.100</span>.v20090520<span style="color: #000000;">-1800</span>
<span style="color: #000000;">44</span>      RESOLVED    org.eclipse.osgi.services_3<span style="color: #000000;">.2</span><span style="color: #000000;">.100</span>.v20100108
<span style="color: #000000;">45</span>      RESOLVED    org.sat4j.core_2<span style="color: #000000;">.2</span><span style="color: #000000;">.0</span>.v20100225
<span style="color: #000000;">46</span>      RESOLVED    org.sat4j.pb_2<span style="color: #000000;">.2</span><span style="color: #000000;">.0</span>.v20100225
<span style="color: #000000;">47</span>      RESOLVED    simple.servlet_1<span style="color: #000000;">.0</span><span style="color: #000000;">.0</span><span style="color: #000000;">.201004081743</span></pre>
<p><strong>Start</strong> the servlet by typing <em>start 47</em> (again, please use the bundle ID issued by <em>ss</em>).</p>
<p><strong>Open a webbrowser</strong> and navigate to ec2-xxx-xx-xx-xx.compute-1.amazonaws.com:8080/simple (the DNS address is the same you used to SSH to your instance) and you should see the servlet output:</p>
<pre class="bash">Hello from the cloud!</pre>
<h2>Conclusion</h2>
<p>In this post, you saw how easy it is to create an Amazon EC2 instance and deploy an OSGi-based servlet on it. With this knowledge, you can now start sky-diving into the joys of cloud computing. Have fun!</p>
<p>Most of this information has been taken from the <a href="http://wiki.eclipse.org/EclipseRT_for_Amazon_EC2">Eclipse Wiki</a>. You are encouraged to add your own tips &amp; tricks to this <a href="http://wiki.eclipse.org/EclipseRT_for_Amazon_EC2">wiki page</a>. All you need is an Eclipse Bugzilla account. Setting one up is easy, start <a href="https://bugs.eclipse.org/bugs/createaccount.cgi">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.peterfriese.de/osgi-servlets-deploying-on-amazon-ec2/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>OSGi &amp; Servlets: A Happy Marriage</title>
		<link>http://www.peterfriese.de/osgi-servlets-a-happy-marriage/</link>
		<comments>http://www.peterfriese.de/osgi-servlets-a-happy-marriage/#comments</comments>
		<pubDate>Wed, 07 Apr 2010 10:40:41 +0000</pubDate>
		<dc:creator>Peter Friese</dc:creator>
				<category><![CDATA[Eclipse]]></category>
		<category><![CDATA[OSGi]]></category>
		<category><![CDATA[Amazon EC2]]></category>
		<category><![CDATA[cloud]]></category>
		<category><![CDATA[J2EE]]></category>
		<category><![CDATA[JEE]]></category>

		<guid isPermaLink="false">http://www.peterfriese.de/?p=415</guid>
		<description><![CDATA[In this post, I'll show you how to create a simple OSGI-based servlet. Later, we will deploy this servlet to an Amazon EC 2 instance - this should be fun!

Update: I updated the code sample to use Declarative Services, as suggested by Jeff and Scott in the comments of this post. After reading this article,[...]]]></description>
			<content:encoded><![CDATA[<p>In this post, I'll show you how to create a simple OSGI-based servlet. Later, we will deploy this servlet to an Amazon EC 2 instance - this should be fun!</p>
<p><span id="more-415"></span></p>
<blockquote><p><strong>Update</strong>: I updated the code sample to use Declarative Services, as suggested by Jeff and Scott in the comments of this post. After reading this article, <a href="http://www.peterfriese.de/osgi-servlets-flexibility-by-simplicity/">please refer to this other post to learn about</a> the changes.
</p></blockquote>
<p><strong>First of all</strong>, some preliminary steps. We need to create a new OSGi project and add some dependencies:</p>
<ol>
<li>Create a new plug-in project, naming it <em>simple.servlet</em>. Make sure to select <em>Equinox</em> as the target OSGI framework on the first page of the wizard. Also make sure you've got an activator (that option is on by default).</li>
<li>Open the manifest editor and add the following packages to the Imported Packages section on the Dependencies tab:
<ul>
<li>javax.servlet</li>
<li>javax.servlet.http</li>
<li>org.osgi.framework</li>
<li>org.osgi.service.http</li>
<li>org.osgi.util.tracker</li>
</ul>
</li>
</ol>
<p><strong>Next</strong>, let's create the servlet. Servlets are plain Java classes that implement the javax.servlet.Servlet interface. As we want to serve information over HTTP, we can just create a subclass of javax.servlet.http.HttpServlet which already does some of the heavy lifting for us. All we need to do is override the doGet() method. This method does not have a return value. Instead, we need to fill its second parameter, <code>HttpServletResponse resp</code> with the text we want the web browser to display. We could return HTML, but for simplicity's sake, let's just return plain text (so make sure to set the content type to <code>text/plain</code>):</p>
<pre class="java"><span style="color: #000000; font-weight: bold;">package</span> simple.<span style="color: #006600;">servlet</span>;
<span style="color: #a1a100;">import java.io.IOException;</span>
&nbsp;
<span style="color: #a1a100;">import javax.servlet.ServletException;</span>
<span style="color: #a1a100;">import javax.servlet.http.HttpServlet;</span>
<span style="color: #a1a100;">import javax.servlet.http.HttpServletRequest;</span>
<span style="color: #a1a100;">import javax.servlet.http.HttpServletResponse;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> SimpleServlet <span style="color: #000000; font-weight: bold;">extends</span> HttpServlet <span style="color: #66cc66;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #993333;">long</span> serialVersionUID = 1L;
&nbsp;
  <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #993333;">void</span> doGet<span style="color: #66cc66;">&#40;</span>HttpServletRequest req, HttpServletResponse resp<span style="color: #66cc66;">&#41;</span>
    <span style="color: #000000; font-weight: bold;">throws</span> ServletException, <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AIOException+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">IOException</span></a> <span style="color: #66cc66;">&#123;</span>
    resp.<span style="color: #006600;">setContentType</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;text/plain&quot;</span><span style="color: #66cc66;">&#41;</span>;
    resp.<span style="color: #006600;">getWriter</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">write</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Hello from the cloud!&quot;</span><span style="color: #66cc66;">&#41;</span>;
  <span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre>
</p>
<p><strong>In order for the servlet to be accessible</strong> via HTTP, we need to register it. If you have done some JEE/J2EE development, you know that servlets are registered using the <code>web.xml</code> servlet descriptor. As we're not in the JEE world any longer, we can't go down this road. Instead, we will register the servlet using a <code>org.osgi.util.tracker.ServiceTracker</code>. It's a little bit more code to write, but let me tell you: it's worth it as you'll see very soon.
</p>
<p>
The service tracker will be registered for a specific class - in our case that's <code>org.osgi.service.http.HttpService</code>:
</p>
<pre class="java"><span style="color: #000000; font-weight: bold;">package</span> simple.<span style="color: #006600;">servlet</span>;
&nbsp;
<span style="color: #a1a100;">import org.osgi.framework.BundleContext;</span>
<span style="color: #a1a100;">import org.osgi.framework.ServiceReference;</span>
<span style="color: #a1a100;">import org.osgi.service.http.HttpService;</span>
<span style="color: #a1a100;">import org.osgi.util.tracker.ServiceTracker;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> HttpServiceTracker <span style="color: #000000; font-weight: bold;">extends</span> ServiceTracker <span style="color: #66cc66;">&#123;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">public</span> HttpServiceTracker<span style="color: #66cc66;">&#40;</span>BundleContext context<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">super</span><span style="color: #66cc66;">&#40;</span>context, HttpService.<span style="color: #000000; font-weight: bold;">class</span>.<span style="color: #006600;">getName</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>, <span style="color: #000000; font-weight: bold;">null</span><span style="color: #66cc66;">&#41;</span>;
  <span style="color: #66cc66;">&#125;</span>
  <span style="color: #808080; font-style: italic;">// ...</span></pre>
<p>When the service tracker is asked to return the <code>HttpService</code>, we can register our servlet:</p>
<pre class="java">  <span style="color: #808080; font-style: italic;">// ...</span>
  <span style="color: #000000; font-weight: bold;">public</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AObject+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">Object</span></a> addingService<span style="color: #66cc66;">&#40;</span>ServiceReference reference<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
    HttpService httpService = <span style="color: #66cc66;">&#40;</span>HttpService<span style="color: #66cc66;">&#41;</span> <span style="color: #000000; font-weight: bold;">super</span>.<span style="color: #006600;">addingService</span><span style="color: #66cc66;">&#40;</span>reference<span style="color: #66cc66;">&#41;</span>;
    <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>httpService == <span style="color: #000000; font-weight: bold;">null</span><span style="color: #66cc66;">&#41;</span>
      <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000000; font-weight: bold;">null</span>;
&nbsp;
    <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #66cc66;">&#123;</span>
      <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ASystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">System</span></a>.<span style="color: #006600;">out</span>.<span style="color: #006600;">println</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Registering servlet at /simple&quot;</span><span style="color: #66cc66;">&#41;</span>;
      httpService.<span style="color: #006600;">registerServlet</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;/simple&quot;</span>, <span style="color: #000000; font-weight: bold;">new</span> SimpleServlet<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>, <span style="color: #000000; font-weight: bold;">null</span>, <span style="color: #000000; font-weight: bold;">null</span><span style="color: #66cc66;">&#41;</span>;
    <span style="color: #66cc66;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #66cc66;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AException+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">Exception</span></a> e<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
      e.<span style="color: #006600;">printStackTrace</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
    <span style="color: #66cc66;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">return</span> httpService;
  <span style="color: #66cc66;">&#125;</span>
  /...</pre>
<p>Likewise, we must make sure to unregister the servlet when the service tracker is asked to shut down the <code>HttpService</code></p>
<pre class="java">  <span style="color: #808080; font-style: italic;">// ..</span>
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #993333;">void</span> removedService<span style="color: #66cc66;">&#40;</span>ServiceReference reference, <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AObject+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">Object</span></a> service<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
    HttpService httpService = <span style="color: #66cc66;">&#40;</span>HttpService<span style="color: #66cc66;">&#41;</span> service;
&nbsp;
    <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ASystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">System</span></a>.<span style="color: #006600;">out</span>.<span style="color: #006600;">println</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Unregistering /simple&quot;</span><span style="color: #66cc66;">&#41;</span>;
    httpService.<span style="color: #006600;">unregister</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;/simple&quot;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
    <span style="color: #000000; font-weight: bold;">super</span>.<span style="color: #006600;">removedService</span><span style="color: #66cc66;">&#40;</span>reference, service<span style="color: #66cc66;">&#41;</span>;
  <span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #66cc66;">&#125;</span></pre>
<p><strong>Now</strong> that we've got the servlet in place, we need to make sure the service tracker is started and stopped when our bundle is started and stopped. Those of you familiar with OSGi know where we're heading now: we need to implement the <code>start()</code> and <code>stop()</code> methods of our activator:</p>
<pre class="java"><span style="color: #000000; font-weight: bold;">package</span> simple.<span style="color: #006600;">servlet</span>;
&nbsp;
<span style="color: #a1a100;">import org.osgi.framework.BundleActivator;</span>
<span style="color: #a1a100;">import org.osgi.framework.BundleContext;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AActivator+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">Activator</span></a> <span style="color: #000000; font-weight: bold;">implements</span> BundleActivator <span style="color: #66cc66;">&#123;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">private</span> HttpServiceTracker serviceTracker;
&nbsp;
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #993333;">void</span> start<span style="color: #66cc66;">&#40;</span>BundleContext context<span style="color: #66cc66;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AException+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">Exception</span></a> <span style="color: #66cc66;">&#123;</span>
    serviceTracker = <span style="color: #000000; font-weight: bold;">new</span> HttpServiceTracker<span style="color: #66cc66;">&#40;</span>context<span style="color: #66cc66;">&#41;</span>;
    serviceTracker.<span style="color: #006600;">open</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
  <span style="color: #66cc66;">&#125;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #993333;">void</span> stop<span style="color: #66cc66;">&#40;</span>BundleContext context<span style="color: #66cc66;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AException+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">Exception</span></a> <span style="color: #66cc66;">&#123;</span>
    serviceTracker.<span style="color: #006600;">close</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
    serviceTracker = <span style="color: #000000; font-weight: bold;">null</span>;
  <span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #66cc66;">&#125;</span></pre>
<p><strong>To test your servlet locally</strong>, create a new launch config:</p>
<ol>
<li>In the main menu, select <em>Run -> Run Configurations...</em></li>
<li>Double click on <em>OSGi Framework</em> in the tree on the left hand side to create a new OSGi-based launch config</li>
<p> and name it <em>Simple Servlet (OSGi)</em></p>
<li>Make sure you select the following <strong>eight (8)</strong> bundles on the <em>Bundles</em> tab:
<ol>
<li>simple.servlet</li>
<li>javax.servlet</li>
<li>org.eclipse.equinox.http.jetty</li>
<li>org.eclipse.equinox.http.servlet</li>
<li>org.eclispe.osgi</li>
<li>org.eclispe.osgi.services</li>
<li>org.mortbay.jetty.server</li>
<li>org.mortbay.jetty.util</li>
</ol>
</li>
<li>Head over to the <em>Arguments</em> tab, making sure the <em>VM arguments</em> text box reads <code>-Declipse.ignoreApp=true -Dosgi.noShutdown=true -Dorg.osgi.service.http.port=8080</code></li>
</ol>
<p><strong>You can now start the server</strong> by executing the launch config. After a very short time, the text <code>Registering servlet at /simple</code> should appear in the console window, indicating your OSGi-based server and your servlet have been started up (a lot faster that it would have taken on Tomcat or any other JEE server, for that matter).
</p>
<p><strong>Open your web browser</strong> at <a href="http://localhost:8080/simple">http://localhost:8080/simple</a> to observe your servlet in action:</p>
<div style="text-align:center;"><a class="lightbox" href="http://farm3.static.flickr.com/2775/4499763290_c0045c441b_o.jpg" title="OSGi SimpleServlet, local deployment"><img border="0" alt="OSGi SimpleServlet, local deployment" src="http://farm3.static.flickr.com/2775/4499763290_00e3405795_m.jpg" /></a></div>
</p>
<p><strong>Congratulations</strong>, you've just built your first OSGi-enabled servlet. In the next post, I'll show you how to deploy this servlet in an Amazon EC2 instance. You can <a href="http://code.google.com/p/peterfriese/source/browse/#svn/osgi/trunk/simple.servlet">download the source code</a> for this post from my SVN repository on Google code.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.peterfriese.de/osgi-servlets-a-happy-marriage/feed/</wfw:commentRss>
		<slash:comments>22</slash:comments>
		</item>
		<item>
		<title>iPhones on Mars</title>
		<link>http://www.peterfriese.de/iphones-on-mars/</link>
		<comments>http://www.peterfriese.de/iphones-on-mars/#comments</comments>
		<pubDate>Wed, 31 Mar 2010 10:42:06 +0000</pubDate>
		<dc:creator>Peter Friese</dc:creator>
				<category><![CDATA[Conferences]]></category>
		<category><![CDATA[Eclipse]]></category>
		<category><![CDATA[USA]]></category>
		<category><![CDATA[iPhone]]></category>

		<guid isPermaLink="false">http://www.peterfriese.de/?p=413</guid>
		<description><![CDATA[EclipseCon 2010 is over and as always has been a great chance to meet up with fellow committers and users of the software we build. Xtext has received a tremendous amount of attention: not only did we deliver several talks and tutorials on Xtext, but also did Xtext get mentioned in a number of talks[...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.eclipsecon.org/2010/">EclipseCon 2010</a> is over and as always has been a great chance to meet up with fellow committers and users of the software we build. <a href="http://www.xtext.org">Xtext</a> has received a tremendous amount of attention: not only did we deliver several talks and tutorials on Xtext, but also did Xtext get mentioned in a number of talks we were not involved in. Xtext even received the <a href="http://www.eclipse.org/org/press-release/20100322_awardswinners.php">Eclipse Community Award</a> in the category "Most Innovative New Feature of Eclipse Project".<br />
<span id="more-413"></span><br />
I presented on Xpand, the template engine we use in Xtext. Of course - as I've demonstrated in my 12 minutes lightning talk - it can be used to generate anything that can be expressed with text, so you can use it in your project, too! I uploaded my slides to Slideshare, <a href="http://www.slideshare.net/peterfriese/xpand-eclipsecon-2010">feel free to browse them</a>.</p>
<p>Right after my talk, <a href="http://www.heikobehrens.net">Heiko</a> showed how Xtext and Xpand can be used to generate native iPhone applications - something that he and I are currently working on as a part of our day-to-day job at <a href="http://www.itemis.com">itemis</a>. Heiko's slides <a href="http://www.slideshare.net/HeikoB/mdsd-on-iphone-eclipsecon-2010">also are available on Slideshare</a>. </p>
<p>Something which - originally - wasn't related to code generation or iPhones at all was the <a href="http://www.eclipse.org/community/e4RoverMars/challenge.php">e4 Mars Rover Challenge</a>. In this challenge, the goal was to control a Mars rover (built with <a href="http://mindstorms.lego.com">LEGO Mindstorms</a>) in a Mars-like environment by using an Eclipse e4 based client and a set of server components hosted on <a href="http://aws.amazon.com/ec2/">Amazon EC2</a>. In order to win, you either needed to score the highest score or improve the Eclipse e4 client. It was left to the developer's fantasy how to improve the client. In order to score the most points, you needed to drive the rover to certain places in the Mars arena and present one of two "tools" highlighted on the rover - see the <a href="http://www.eclipse.org/community/e4RoverMars/howtoplay.php">rules of the challenge</a>.</p>
<p>On the first day, I played some rounds with the basic e4 client (you needed to install it on your local machine) and scored quite OK. In the evening, after I dropped off my laptop in my room, it occurred to me that without my computer, I wouldn't be able to take the challenge that evening. "Wouldn't it be awesome to use my iPhone to control the Mars Rover", I thought? Compared to a laptop, an iPhone is a very small device so you can take it with you where ever you go. Also, as the Mars Rover Challenge was setup to be a completely distributed system, with the command server being hosted "in the cloud", delivering an image of the Mars arena to the clients, I should be able to connect to the rover from anywhere on the world (as long as I have access to the internet).</p>
<p>When I mentioned my thinking to <a href="http://www.twitter.com/HBehrens">Heiko</a>, he was equally thrilled as I was and we immediately set out to take the new challenge of writing an iPhone client for the Mars Rover.</p>
<p>We discussed quite a few interaction patterns we wanted to try out:</p>
<ol>
<li>Using buttons (much like the cursor pad on a keyboard) to "joystick" the rover</li>
<li>Using a touch interface to control the rover: use pinching to rotate the rover and pointing to make it move in a certain direction</li>
<li>Using the accelerometer to be able to control the Rover by tilting the iPhone</li>
</ol>
<p>Heiko took on the job of evaluating the human interaction interface, whereas I was busy implementing the interface between the iPhone app and the command server backend. The command server of the Mars Rover is implemented as a RESTful webservice, so I could use plain HTTP calls to send commands to the server and to retrieve telemetry and imagery data. At first, I used blocking calls and later replaced them with asynchronous calls - sometingh which I'll liekly blog about the next days, so stay tuned. In order to test my code, I implemented a very simple button-based UI. With this UI, I was able to score 2702 points - not too bad!</p>
<div style="text-align:center;"><a class="lightbox" href="http://farm3.static.flickr.com/2700/4478823448_963fe43271.jpg" title="iPhone Mars Rover Basic"><img border="0" alt="iPhone Mars Rover Basic" src="http://farm3.static.flickr.com/2700/4478823448_963fe43271_m.jpg" /></a></div>
<p>After just two nights of development time (we wanted to attend the sessions and also had to man the itemis booth), we finally had a slick iPhone app that was able to control the Mars Rover by using the accelerometer. In the nght just before we had to hand in our submission, we shot a video of us driving the Rover. You can watch this video on the <a href="http:/www.iphonemarsrover.com">iPhone Mars Rover website</a>.</p>
<p>Here is a little diagram outlining the controls of the application:</p>
<div style="text-align:center;"><a class="lightbox" href="http://farm5.static.flickr.com/4060/4473119658_105d444c56.jpg" title="iPhone Mars Rover"><img border="0" alt="iPhone Mars Rover" src="http://farm5.static.flickr.com/4060/4473119658_105d444c56_m.jpg"/></a></div>
<p>We knew right from the start that we wouldn't be able to match the competition criteria (the contest rules clearly state that the client has to be Eclipse e4-based in order to qualify). However, we still were eager to work on this project, as it fit very well with our current obsession with all things iPhones.</p>
<p>While it certainly is a fun idea to use an iPhone app to control a LEGO Mindstorms robot, we would not recommend using this approach for controlling real robots - especially if they're some 55 million km away on Mars! Signal latency from Mars to Earth is said to be around 15 to 20 minutes, which suggests to use a move-oriented approach to drive the rover.</p>
<p>Nevertheless it has been an exciting and fun project for Heiko and me. By the way, we're not only developing iPhone apps for fun, but also for profit: we're spearheading the <a href="http://www.itemis.com/itemis-ag/portfolio/language=en/29470/business-applications-for-mobile-devices">brand-new mobile development division of itemis</a>, so I'm pretty sure we will blog about mobile technology soon.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.peterfriese.de/iphones-on-mars/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Getting started with Code Generation with Xpand</title>
		<link>http://www.peterfriese.de/getting-started-with-code-generation-with-xpand/</link>
		<comments>http://www.peterfriese.de/getting-started-with-code-generation-with-xpand/#comments</comments>
		<pubDate>Wed, 17 Mar 2010 14:05:05 +0000</pubDate>
		<dc:creator>Peter Friese</dc:creator>
				<category><![CDATA[EMF]]></category>
		<category><![CDATA[Eclipse]]></category>
		<category><![CDATA[MDSD]]></category>
		<category><![CDATA[xpand]]></category>

		<guid isPermaLink="false">http://www.peterfriese.de/?p=390</guid>
		<description><![CDATA[Have you heard about model driven software development (MDD / MDSD) and are thinking "what's all this fuzz about models"? "Why should models help me to be more productive," might be another thought you have.
People have been asking how to leverage models on and off on the web and in meetings I attended, so I[...]]]></description>
			<content:encoded><![CDATA[<p>Have you heard about model driven software development (MDD / MDSD) and are thinking "what's all this fuzz about models"? "Why should models help me to be more productive," might be another thought you have.</p>
<p>People have been asking how to leverage models on and off on the web and in meetings I attended, so I thought I might share this little tutorial with you. In this tutorial, we will develop a little code generator that helps you to create (HTML) forms from models. </p>
<h2>A short Overview</h2>
<p>Xpand is a template engine, similar to FreeMarker, Velocity, JET and JSP. However, it features some very unique properties that makes using Xpand very well suited for generating code from models, such as <strong><a href="http://en.wikipedia.org/wiki/Type_safety">type safety</a></strong> and <strong>polymorphic dispatch</strong>. If you haven't heard those terms before, fear not! I'll show you how to use Xpand by way of an easy-to-follow example.</p>
<p><span id="more-390"></span></p>
<p>The usual process of writing a code generator with Xpand is as follows:</p>
<ol>
<li>Define the structure of the model you want to process. This is called a <em>metamodel</em></li>
<li>Define one or more template(s) that teach the code generator how to translate your model into code.</li>
</ol>
<p>Easy, isn't it?</p>
<p>Using the code generator is even easier:</p>
<ol>
<li>Create a model</li>
<li>Start the code generator</li>
</ol>
<p>It is worth mentioning that you can use Xpand to generate code for almost any known programming language. Everything you can express in text can be generated using Xpand. So, while we will be generating HTML and Java code in the following example, you can easily write code templates that generate code for C#, Basic, Lua, SmallTalk, ABAP, or any other programming language. You can also generate manuals and other documentation artifacts from your models using Xpand. I've successfully used Xpand to create DocBook files from models. Those DocBook files have then been converted to PDF files and online help files.</p>
<h2>Preparing your IDE</h2>
<ol>
<li>Grab and install a recent copy of Eclipse. At the time of writing, I am using <a href="http://download.eclipse.org/eclipse/downloads/drops/S-3.6M6-201003121448/index.php">Eclipse 3.6 M6</a>.</li>
<li>Install the latest version of Xpand (<em>Help -> Install New Software ...</em>)
<li>Add the Xpand update site (at the time of this writing, I am using Xpand 1.0 nightly builds from <a href="http://download.eclipse.org/modeling/m2t/xpand/updates/nightly/">http://download.eclipse.org/modeling/m2t/xpand/updates/nightly/</a>)</li>
<li>Add the MWE update site (<a href="http://download.eclipse.org/modeling/emft/mwe/updates/nightly/">http://download.eclipse.org/modeling/emft/mwe/updates/nightly/</a>)</li>
<li>Select MWE and Xpand:
<div style="text-align:center;"><a href="http://www.flickr.com/photos/81029262@N00/4439298864" title="View 'Install MWE and Xpand' on Flickr.com"><img border="0" width="488" alt="Install MWE and Xpand" src="http://farm5.static.flickr.com/4001/4439298864_40b913f0e5.jpg" height="500"/></a></div>
</li>
<li>After the obligatory restart, do yourself the favour and set the platform encoding to <strong>UTF-8</strong>!</li>
</ol>
<h2>Creating a Generator Project</h2>
<p>Xpand code generators are hosted in Eclipse plug-ins, mainly because this makes handling the classpath a lot easier. People have reportedly used Maven to run Xpand code generators, but we won't go down this road today. Let's create a simple generator project:</p>
<ol>
<li>Open the new project wizard and choose <em>Xpand Project</em> from the list</li>
<li>Choose a meaningful name for your project (e.g. <em>org.xpand.example.gettingstarted</em></li>
<li>Select <em>Create a sample EMF based Xpand project</em></li>
</ol>
<p>After clicking <em>Finish</em>, the wizard will create an sample generator project for you:</p>
<div style="text-align:center;"><a href="http://www.flickr.com/photos/81029262@N00/4439735747" title="View 'Xpand project layout' on Flickr.com"><img border="0" width="556" alt="Xpand project layout" src="http://farm3.static.flickr.com/2794/4439735747_e7385b2cef_o.png" height="394"/></a></div>
<p>Before we can start working with this project, we need to perform some clean-up actions:</p>
<ol>
<li>Open <em>src/metamodel/Checks.chk</em> and delete all its contents</li>
<li>Open <em>src/metamodel/Extensions.chk</em> and delete all its contents</li>
<li>Open <em>src/template/GeneratorExtensions.ext</em> and delete all its contents</li>
<li>Delete <em>src/Model.xmi</em></li>
<li>Don't forget to save all modified files</li>
</ol>
<h2>Creating the Metamodel</h2>
<p>As mentioned before, we need to define the structure of our models before we can actually start writing the code template.<br />
Xpand is capable of understanding a variety of metamodel types. For example, if you have an XML schema file, you can use this as a metamodel and thereby enable Xpand to use XML files which are compliant to your schema as input models. Or, if you already have a bunch of Java files making up your data model, you can use those to drive Xpand code generation. In this tutorial, however, we will be using an Ecore metamodel to define the structure of our models. The project has already been configured to support Ecore metamodels, so all we need to do is open <em>metamodel.ecore</em> and define the structure:</p>
<ol>
<li>Please open <em>src/metamodel/metamodel.ecore</em></li>
<p>.</p>
<li>Remove the following elements from the metamodel: <em>Feature</em>, <em>Entity</em>, <em>Datatype</em>, <em>Type</em>, <em>Model</em>. The metamodel should now be empty:
<div style="text-align:center;"><a href="http://www.flickr.com/photos/81029262@N00/4439788989" title="View 'Empty metamodel' on Flickr.com"><img border="0" width="500" alt="Empty metamodel" src="http://farm3.static.flickr.com/2555/4439788989_42665597db.jpg" height="105"/></a></div>
</li>
<li>Select package <em>metamodel</em> (as depicted in the screenshot above) and add a new <em>EClass</em> (<em>context menu -> New Child -> EClass</em>). Use the properties view to change the name of the newly created EClass to <em>Model</em>.</li>
<li>Create a new EClass <em>Form</em></li>
<li>Select the newly created EClass <em>Form</em> and add the following <em>EAttribute</em>s:
<ul>
<li><em>name</em>, set the EType to <em>EString</em></li>
<li><em>description</em>, EType = <em>EString</em></li>
<li><em>title</em>, EType = <em>EString</em></li>
</ul>
</li>
<li>Select EClass <em>Model</em> and add a new <em>EReference</em>, setting its attributes as follows:
<ul>
<li>name = <em>forms</em></li>
<li>EType = <em>Form</em></li>
<li>Containment = <em>true</em></li>
<li>Upperbound = <em>-1</em> (meaning: unlimited)</li>
</ul>
</li>
<li>Create a new EClass <em>Field</em> and add the following EAttributes to it:
<ul>
<li><em>name</em>, EType = <em>EString</em></li>
<li><em>label</em>, EType = <em>Estring</em></li>
</ul>
</li>
<li>Create another EClass <em>TextField</em>, setting its properties as follows:
<ul>
<li>name = <em>TextField</em></li>
<li>ESuper Types = <em>Field</em></li>
</ul>
</li>
<li>Add one EAttribute <em>text</em> to <em>Textfield</em>:
<ul>
<li>name = <em>text</em>, EType = <em>EString</em></li>
</ul>
</li>
<li>Add an EClass <em>MultiLineTextField</em> to the metamodel:
<ul>
<li>name = <em>MultiLineTextTield</em></li>
<li>ESuper Types = <em>TextField</em></li>
</ul>
</li>
<li>Now that we have everything in place, we finally need to add a reference from <em>Form</em> to <em>Field</em> so we can later add fields to a form. Select EClass <em>Form</em> and add an EReference to it, setting its properties as follows:
<ul>
<li>name = <em>fields</em></li>
<li>EType = <em>Field</em></li>
<li>Containment = <em>true</em></li>
<li>Upperbound = <em>-1</em> (meaning: unlimited)</li>
</ul>
</li>
</ol>
<h2>Creating a Model</h2>
<p>Let's now create a model that follows the structure of the metamodel:</p>
<ol>
<li>In <em>metamodel.ecore</em>, select EClass <em>Model</em></li>
<li>Create a model instance by choosing <em>Create Dynamic Instance...</em> from the context menu</li>
<li>Save the model file to <em>src/Model.xmi</em></li>
</ol>
<p>The model file editor will now open and you can use the tree editor to input the following model:</p>
<ul>
<li>Add a <em>Form</em> to the model, seeting the following properties:
<ul>
<li>Name: <em>context</em></li>
<li>Description: <em>Send your feedback</em></li>
<li>Title: <em>Contact form</em></li>
</ul>
</li>
<li>Add a <em>TextField</em> to the <em>Form</em>, setting the following properties:
<ul>
<li>Name: <em>name</em></li>
<li>Label: <em>Name</em></li>
</ul>
</li>
<li>Add another <em>TextField</em> to the <em>Form</em>, setting the following properties:
<ul>
<li>Name: <em>email</em></li>
<li>Label: <em>EMail</em></li>
</ul>
</li>
<li>Add a <em>MultiLineTextField</em> to the <em>Form</em>, setting the following properties:
<ul>
<li>Name: <em>message</em></li>
<li>Label: <em>Message</em></li>
</ul>
</li>
</ul>
<p>Your model should now look like this:</p>
<div style="text-align:center;"><a href="http://www.flickr.com/photos/81029262@N00/4440711442" title="View 'Contact model' on Flickr.com"><img border="0" width="500" alt="Contact model" src="http://farm3.static.flickr.com/2719/4440711442_354f817303.jpg" height="167"/></a></div>
<h2>Creating a Code Generator</h2>
<p>As mentioned before, we will create a code generator for simple forms. Nothing too fancy, but enough to give you an idea of how to create generator templates.</p>
<p>The result will look like this:</p>
<div style="text-align:center;"><a href="http://www.flickr.com/photos/81029262@N00/4440844786" title="View 'Contact Form' on Flickr.com"><img border="0" width="500" alt="Contact Form" src="http://farm3.static.flickr.com/2745/4440844786_46824ce7ea.jpg" height="403"/></a></div>
<p>Open <em>src/template/Template.xpt</em> and replace its contents with the following text:</p>
<pre>
«IMPORT metamodel»
«DEFINE main FOR Model»
«EXPAND form FOREACH forms»
«ENDDEFINE»
</pre>
<p>On the first line, we import the metamodel so that the generator (and the editor as well) knows about the structure of our model. On line 2 - 4 we define a code template named <em>main</em>, making sure it is bound to model elements of type <em>Model</em>. The template doesn't do much, except to call another template (which we will define in a minute) named <em>form</em> with the collection of <em>Form</em>s, contained in the reference <em>forms</em> of the current form.</p>
<p>Add the following lines to the template file, defining the template for the HTML file:</p>
<pre>
«DEFINE form FOR Form»
«FILE name + ".html"»
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <title>«this.title»</title>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" type="text/css" href="../static/style.css" />
</head>
</pre>
<p>In the first line, we start the template by specifying its name (<em>form</em>) and the type it is bound to (<em>Form</em>). On the next line, we use the <em>FILE</em> statement to specify the file the output is going to be written to. The name of the file is derived by concatenating the attribute <em>name</em> of the current <em>Form</em> and the string literal <em>".html"</em>.</p>
<p>Continue the template by appending the following text:</p>
<pre>
<body>
<div id="page-wrap">
<h1>«this.title»</h1>

«this.description»
<div id="form-area">
</pre>
<p>Obviously, this piece of template code will create part of the body of the HTML page. Again, we will access attributes of the current <em>Form</em> (as read from the model) and insert their values into the template (in this case, the title and the description). By the way, you can omit the <em>this.</em> prefix in front of the variable names.</p>
<p>The template goes on with the following text:</p>
<pre>
<form method="post" action="form.php">
        «EXPAND field FOREACH this.fields»
<input type="submit" name="submit" value="Submit" class="submit-button" />
      </form>
<div style="clear: both;"></div>
</div>
</div>

</body>
</html>
«ENDFILE»
«ENDDEFINE»
</pre>
<p>The <em>EXPAND</em> statement will invoke yet another subtemplate with the name <em>field</em>. This sub template will be called for each element in the <em>fields</em> attribute (reference) of the current <em>Form</em>.</p>
<p>You might recall that we we defined three different kinds of <em>>Field</em>s in the metamodel: </p>
<ol>
<li>Field (which is the super class for the other two field types</li>
<li>TextField</li>
<li>MultiLineTextField</li>
</ol>
<p>As their names imply, a <em>TextField</em> will be a single line text entry field, whereas <em>MultiLineTextField</em> will be a multiline text input field. We somehow need to be able to render different HTMNL code for each of these different text field types.</p>
<p>As mentioned in the introduction, Xpand is not only type safe, but also supports <strong>polymorphic dispatch</strong>. This basically means we will create three templates (one for each of the different field types) <em>with the same name</em>. When evaluating the code template, the Xpand generator will dispatch to the appropriate template by matching the most concrete type of the current model element.</p>
<p>Add the following code to the template file:</p>
<pre>
«DEFINE field FOR Field»
«ERROR "should not happen"»
«ENDDEFINE»
«DEFINE field FOR TextField»
        <label for="«this.name»">«this.label»:</label>
<input type="text" name="«this.name»" id="«this.name»" />
«ENDDEFINE»
«DEFINE field FOR MultiLineTextField»
        <label for="«this.name»">«this.label»:</label>
        <textarea name="«this.name»" id="«this.name»" rows="20" cols="20"></textarea>
«ENDDEFINE»
</pre>
<p>As you can see, all three templates have the same name. Only the type they are bound to differs. This is enough to let Xpand know which template to choose according to the type of the current model element. Let's suppose Xpand is iterating the model and the current model element is a <em>TextField</em>. Although <em>Field</em> is a direct super type of <em>TextField</em>, Xpand will not invoke the first template (<em>«DEFINE field FOR Field»</em>), but the second template (<em>«DEFINE field FOR TextField»</em>), as this is the most concrete match for the type of the model element.</p>
<h2>Running the Code Generator</h2>
<p>If you have followed the above steps, running the code generator is a piece of cake: </p>
<p>Open the context menu on <em>src/workflow/workflow.mwe</em> and select <em>Run As -> MWE Workflow</em></p>
<p>This will start the code generator. You will see some log messages in the console view. If all went well, the output in the console reads something like this:</p>
<pre>
...
1503 INFO  Generator          - Written 1 files to outlet [default](src-gen)
1503 INFO  WorkflowRunner     - workflow completed in 650ms!
</pre>
<p>The result of the code generation can be found in <em>src-gen/contact.html</em>. As this file has some dependencies to CSS/image files, please download the files from the <em>static</em> folder (<a href="http://code.google.com/p/peterfriese/source/browse/#svn/org.xpand.example.gettingstarted/trunk/org.xpand.example.gettingstarted/static">here</a>) and place them in your project before opening <em>contact.html</em> in your browser.</p>
<h2>Where to go from here</h2>
<p>If you want to learn more about Xpand, be sure to attend my talk <a href="http://www.eclipsecon.org/2010/sessions/?page=sessions&id=1129">Use models and let the computer do the grunt work with Xpand</a> at EclipseCon 2010. I'll show some more advanced topics in this talk (such as generator cartridges, using Xtend to augment your models, partitioning your code templates, using other metamodels to define your models).</p>
<p>Xpand comes with an extensive documentation (just go to <em>Help -> Help Contents -> Xpand Documentation</em> in Eclipse). You can also get help on Xpand in the <a href="http://www.eclipse.org/forums/index.php?t=tree&th=163643&">Eclipse Community Forums</a></p>
<p>Should you need help, <a href="http://www.itemis.com">itemis (the company I work with)</a> offers training and consulting for Xpand and a host of other modeling related technologies.</p>
<p>No doubt you have heard about <a href="http://www.xtext.org">Xtext</a>. Xpand and Xtext go together great: you can use Xtext to define the structure of your models and create great-looking text editors to edit your models. Then, use Xpand to create code generators that take your textual models and turn them into running software. Actually, Xtext comes with a wizard that you to create a code generator project for your DSL.</p>
<h2>Downwloads</h2>
<p>The code for this tutorial can be found in <a href="http://code.google.com/p/peterfriese/source/browse/#svn/org.xpand.example.gettingstarted/trunk/org.xpand.example.gettingstarted">my SVN repository on Google Code</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.peterfriese.de/getting-started-with-code-generation-with-xpand/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Running AppleScript from Java</title>
		<link>http://www.peterfriese.de/running-applescript-from-java/</link>
		<comments>http://www.peterfriese.de/running-applescript-from-java/#comments</comments>
		<pubDate>Mon, 08 Mar 2010 19:42:38 +0000</pubDate>
		<dc:creator>Peter Friese</dc:creator>
				<category><![CDATA[Apple]]></category>
		<category><![CDATA[Eclipse]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Mac]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[AppleScript]]></category>

		<guid isPermaLink="false">http://www.peterfriese.de/?p=387</guid>
		<description><![CDATA[In my current project, I need to launch an external application and maybe execute some additional commands on this external application. Due to the very nature of the project, the whole system will always be run on Mac OS X. So I thought, "why not use AppleScript"?
Turns out using AppleScript to launch applications is fairly[...]]]></description>
			<content:encoded><![CDATA[<p>In my current project, I need to launch an external application and maybe execute some additional commands on this external application. Due to the very nature of the project, the whole system will always be run on Mac OS X. So I thought, "why not use AppleScript"?<span id="more-387"></span><br />
Turns out using AppleScript to launch applications is fairly easy, all you have to do is </p>
<pre>tell application "name of your app" to launch</pre>
<p>If you want to try this from the command line, <em>osascript</em> comes in handy:</p>
<pre>osascript -e 'tell app "iTunes" to launch'</pre>
<p>So far so good. Should be easy to do this from Java, shouldn't it? Turns out it's not so easy at all. Let's try this:</p>
<pre class="java">  <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AString+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">String</span></a> launchCmd = <span style="color: #ff0000;">&quot;osascript -e 'tell application <span style="color: #000099; font-weight: bold;">\&quot;</span>iTunes<span style="color: #000099; font-weight: bold;">\&quot;</span> to play'&quot;</span>;
  process = <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ARuntime+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">Runtime</span></a>.<span style="color: #006600;">getRuntime</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">exec</span><span style="color: #66cc66;">&#40;</span>launchCmd<span style="color: #66cc66;">&#41;</span>;
&nbsp;
  <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ABufferedReader+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">BufferedReader</span></a> bufferedReader = <span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ABufferedReader+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">BufferedReader</span></a><span style="color: #66cc66;">&#40;</span>
    <span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AInputStreamReader+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">InputStreamReader</span></a><span style="color: #66cc66;">&#40;</span>process.<span style="color: #006600;">getErrorStream</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
  <span style="color: #b1b100;">while</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span>lsString = bufferedReader.<span style="color: #006600;">readLine</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> != <span style="color: #000000; font-weight: bold;">null</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
    <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ASystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">System</span></a>.<span style="color: #006600;">out</span>.<span style="color: #006600;">println</span><span style="color: #66cc66;">&#40;</span>lsString<span style="color: #66cc66;">&#41;</span>;
  <span style="color: #66cc66;">&#125;</span></pre>
<p>I'm not sure why, but it results in a nasty "<em>0:1: syntax error: A unknown token can't go here. (-2740)</em>" error message.</p>
<p>But there is another signature for Runtime.exec:</p>
<pre class="java">  <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AString+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">String</span></a><span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span> cmd = <span style="color: #66cc66;">&#123;</span> <span style="color: #ff0000;">&quot;osascript&quot;</span>, <span style="color: #ff0000;">&quot;-e&quot;</span>,	<span style="color: #ff0000;">&quot;tell app <span style="color: #000099; font-weight: bold;">\&quot;</span>iPhone Simulator<span style="color: #000099; font-weight: bold;">\&quot;</span> to launch&quot;</span> <span style="color: #66cc66;">&#125;</span>;
  process = <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ARuntime+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">Runtime</span></a>.<span style="color: #006600;">getRuntime</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">exec</span><span style="color: #66cc66;">&#40;</span>cmd<span style="color: #66cc66;">&#41;</span>;
&nbsp;
  <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ABufferedReader+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">BufferedReader</span></a> bufferedReader = <span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ABufferedReader+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">BufferedReader</span></a><span style="color: #66cc66;">&#40;</span>
    <span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3AInputStreamReader+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">InputStreamReader</span></a><span style="color: #66cc66;">&#40;</span>process.<span style="color: #006600;">getErrorStream</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
  <span style="color: #b1b100;">while</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span>lsString = bufferedReader.<span style="color: #006600;">readLine</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> != <span style="color: #000000; font-weight: bold;">null</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
    <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3ASystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #aaaadd; font-weight: bold;">System</span></a>.<span style="color: #006600;">out</span>.<span style="color: #006600;">println</span><span style="color: #66cc66;">&#40;</span>lsString<span style="color: #66cc66;">&#41;</span>;
  <span style="color: #66cc66;">&#125;</span></pre>
<p>... and this works out just fine!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.peterfriese.de/running-applescript-from-java/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>140 x 365 = 2659</title>
		<link>http://www.peterfriese.de/140-x-365-2659/</link>
		<comments>http://www.peterfriese.de/140-x-365-2659/#comments</comments>
		<pubDate>Sun, 31 Jan 2010 20:56:11 +0000</pubDate>
		<dc:creator>Peter Friese</dc:creator>
				<category><![CDATA[Tools]]></category>

		<guid isPermaLink="false">http://www.peterfriese.de/?p=382</guid>
		<description><![CDATA[It's exactly one year since I posted my first tweet on Twitter - time for a review.
Before I give some reasons why I use Twitter, let's have a look at some stats.
I sent out roughly 2660 tweets, on average 8.4 per day:

Looking at my tweet density, I hardly seem to be getting any sleep, which[...]]]></description>
			<content:encoded><![CDATA[<p>It's exactly one year since I posted <a href="http://twitter.com/peterfriese/status/1164566213">my first tweet</a> on Twitter - time for a review.</p>
<p>Before I give some reasons why I use Twitter, let's have a look at some stats.</p>
<p>I sent out roughly 2660 tweets, on average 8.4 per day:</p>
<div style="text-align:center;"><a href="http://www.flickr.com/photos/81029262@N00/4316305253" title="View 'TweetStats :: for peterfriese' on Flickr.com"><img border="0" width="602" alt="TweetStats :: for peterfriese" src="http://farm3.static.flickr.com/2703/4316305253_ec08e825af_o.jpg" height="289"/></a></div>
<p>Looking at my tweet density, I hardly seem to be getting any sleep, which is not entirely true <img src='http://www.peterfriese.de/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /><br />
<span id="more-382"></span></p>
<div style="text-align:center;"><a href="http://www.flickr.com/photos/81029262@N00/4316315167" title="View 'TweetStats :: for peterfriese' on Flickr.com"><img border="0" width="594" alt="TweetStats :: for peterfriese" src="http://farm5.static.flickr.com/4012/4316315167_c157b5410f_o.jpg" height="284"/></a></div>
<p>Over the last year, I tried quite a few twitter clients, but I like Tweetie the most (yes, I'm using a Mac):</p>
<div style="text-align:center;"><a href="http://www.flickr.com/photos/81029262@N00/4317057428" title="View 'TweetStats :: for peterfriese' on Flickr.com"><img border="0" width="352" alt="TweetStats :: for peterfriese" src="http://farm3.static.flickr.com/2684/4317057428_3b5487fdab_o.jpg" height="224"/></a></div>
<h3>Why I use Twitter</h3>
<ul>
<li>Twitter helps me to keep informed about topics I am interested in, while at the same time giving me the chance to get in touch with the sources of that information and give feedback.</li>
<li>Many vendors and dev teams have Twitter accounts and use them to twitter about what they're currently doing / developing, again helping me to keep up-to-date about current developments</li>
<li>Twitter helps me to "hear" what others are saying about the tools I and my teammates develop. Twitter clients like TweetDeck and Nambu allow you to define custom searches. E.g., I've got a search defined for "Xtext OR DSLs" so I will be informed each time someone tweets about either Xtext or DSLs. This allows me to give instant feedback to users needing help or ranting about <a href="http://twitter.com/xtext">Xtext</a> (actually, most users praise Xtext, so I'm mostly using this search to retweet that praise)</li>
<li>Twitter is like a big room in which everybody can hear what you're saying. You can use this fact to use Twitter as a marketing channel, and that's what we do with <a href="http://www.xtext.org">Xtext</a>, too. We get the word out on Xtext, e.g. by announcing cool new features or talks we're giving at upcoming conferences.</li>
<li>I also use Twitter to get / keep in touch with co-workers, friend and also clients. More often than not when meeting new clients, I hear people say "nice to meet you in person after we have been talking on Twitter". Sometimes, I use Twitter instead of my phone to ping people ("give me a call when you are available") - works great!</li>
<li>By using Twitter, you will actually feel much closer to your peers ("<a href="http://www.urbandictionary.com/define.php?term=tweep">tweeps</a>") than you did before. This holds true especially for the Eclipse crowd. Many of us follow each other on Twitter and thus know what we do in our day to day job (and in our spare time, too) better than before.</li>
</ul>
<h3>Some recommendations</h3>
<p>Whether you're new to Twitter or have been using it for years, here is my list of recommendations for Twitter. May it be inspirational for you:</p>
<ul>
<li>Find a decent client. The web interface is O.K., but in order to use all the power of Twitter, you need to use a real client. My main work horse is <a href="http://www.atebits.com/tweetie-mac/">Tweetie</a> (on the Mac), mostly because it allows me to view conversations in a really neat manner. <a href="http://www.tweetdeck.com/iphone/">On the iPhone I recommend TweetDeck</a> - you can easily define additional columns to display custom searches, DMs, tweets nearby and so on. <a href="http://www.nambu.com/">Nambu</a> also is very nice - and native! <a href="http://www.tweetdeck.com/">TweetDeck on the Mac</a> is also great, but eats a lot of resources, which is why I rarely use it any more. If you want to issue tweets without losing context, give <a href="http://code.google.com/p/qsb-mac/">Google Quick Search Bar</a> a try - <a href="http://code.google.com/p/qsb-mac/wiki/GettingStarted#How_do_I_tweet_with_Twitter">there's a plug-in that allows you</a> to tweet from QSB.</li>
<li>Do NOT protect your updates. After all, you want to get in touch with other people. So there really is no point in protecting your updates.</li>
<li>If you're new to Twitter, make sure to post some tweets before starting to follow other people. You want to make sure other people are following you too, but why should they follow you if you've got nothing to say?</li>
<li>We're not interested in disgusting details about you, your family or your friends, <a href="http://theoatmeal.com/comics/facebook_suck">so keep them for you</a>.</li>
<li>I follow people mostly for professional reasons. Tweeting personal stuff is perfectly OK and can add that grain of salt which makes you human, but you should try to keep a balance.</li>
</ul>
<h3>Summing up</h3>
<p>Summing up all things, using Twitter has helped me to get in touch with a huge amount of people I wouldn't have interacted with if I hadn't been using Twitter. </p>
<p>If you read all this, let me lift the secret about the obviously wrong mathematical equation in the title of this post: it's the number of characters you may use for one tweet (140), the number of days since I started using Twitter and the total number of tweets I sent out (2659). Actually, as I am using <a href="http://alexking.org/projects/wordpress">Twitter Tools for Wordpress</a>, this blog post will automatically be announced on Twitter and thus be <a href="http://twitter.com/peterfriese/status/8465879177">tweet number 2660</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.peterfriese.de/140-x-365-2659/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Eclipse DemoCamp Hamburg 11/2009</title>
		<link>http://www.peterfriese.de/eclipse-democamp-hamburg-112009/</link>
		<comments>http://www.peterfriese.de/eclipse-democamp-hamburg-112009/#comments</comments>
		<pubDate>Mon, 07 Dec 2009 23:15:29 +0000</pubDate>
		<dc:creator>Peter Friese</dc:creator>
				<category><![CDATA[Conferences]]></category>
		<category><![CDATA[Eclipse]]></category>
		<category><![CDATA[democamp]]></category>
		<category><![CDATA[hamburg]]></category>

		<guid isPermaLink="false">http://www.peterfriese.de/?p=361</guid>
		<description><![CDATA[The Eclipse DemoCamp in Hamburg was a huge success - more than 110 people signed up and most of them actually showed up at the event:

The program was packed with interesting talks and we were lucky to be able to present some very well known speakers:


Tom Schindl: E4 - A short overview
Jan Köhnlein: Combining graphics[...]]]></description>
			<content:encoded><![CDATA[<p>The Eclipse <a href="http://wiki.eclipse.org/Eclipse_DemoCamps_November_2009/Hamburg">DemoCamp in Hamburg</a> was a huge success - more than 110 people signed up and most of them actually showed up at the event:</p>
<div style="text-align:center;"><a href="http://www.flickr.com/photos/nossipova/4163775996/in/set-72157622946379026" title="'About 110 Attendees at the DemoCamp' on Flickr.com"><img border="0" width="500" alt="About 110 Attendees at the DemoCamp" src="http://farm3.static.flickr.com/2595/4163775996_5cff50538a.jpg" height="332"/></a></div>
<p>The program was packed with interesting talks and we were lucky to be able to present some very well known speakers:<br />
<span id="more-361"></span></p>
<ol>
<li>Tom Schindl: E4 - A short overview</li>
<li>Jan Köhnlein: Combining graphics and text in model editors</li>
<li>Jochen Krause: RAP</li>
<li>Nils Hartmann, Gerd Wütherich: Fifty ways to build your bundle...</li>
<li>ekke (Ekkehard Gentz):redView - dynamic views for business applications</li>
</ol>
<p>If you were not lucky enough to attend the DemoCamp, here is a short summary of the sessions:</p>
<h3>e4 - modeling meets runtime (Jochen Krause on behalf of Tom Schindl)</h3>
<p>Tom Schindl couldn't attend the DemoCamp due to heavy snow in Innsbruck (the airport was short of planes to fly out, actually). After a short vcon with Tom, Jochen Krause held the e4 demo on Tom's behalf.</p>
<table align="center" border="0">
<tr>
<td>
<div style="text-align:center;"><a href="http://www.flickr.com/photos/nossipova/4163772608/in/set-72157622946379026/" title="'A short video conf with Tom Schindl' on Flickr.com"><img border="0" width="240" alt="A short video conf with Tom Schindl" src="http://farm3.static.flickr.com/2593/4163772608_5148246c1e_m.jpg" height="159"/></a></div>
</td>
<td>
<div style="text-align:center;"><a href="http://www.flickr.com/photos/nossipova/4163011953/sizes/m/in/set-72157622946379026/" title="'Jochen Krause (for Tom Schindl) - e4' on Flickr.com"><img border="0" width="240" alt="Jochen Krause (for Tom Schindl) - e4" src="http://farm3.static.flickr.com/2685/4163011953_9bbbd9ce5d_m.jpg" height="159"/></a></div>
</td>
</tr>
</table>
<p>e4 has three principal aims: </p>
<ol>
<li>simplifying the Eclipse programming model</li>
<li>enabling the platform for use on emerging web-based runtime technologies</li>
<li>and broadening participation in development of the platform</li>
</ol>
<p>One of the measures to make programming Eclipse easier is to define a list of core services and make sure they have a really decent API. This list of services is called "The 20 Things" (see the Eclipse wiki for <a href="http://wiki.eclipse.org/E4/Eclipse_Application_Services">more information</a>).</p>
<p>You might have heard that EMF is playing an important role in e4 and I think it is one of the most amazing things about e4 that the entire workbench is modeled, of course using EMF. Actually, you can change the workbench at runtime by just modifying the underlying model at runtime. I think it is very exciting to see modeling and runtime technologies converge in this project.</p>
<p>e4 also makes massive use of dependency injection, which allows for a flat object model (Instead of providing a subclass for every special feature, you can just inject other classes providing that particular feature). We had a discussion about dependency injection. Jochen showed that several methods in e4 use String-based dependency injection, which of course leads to several problems. Sven pointed out that this is not a DI problem per se and suggested to use interfaces to alleviate the situation. </p>
<p><a href="http://twitter.com/HBehrens">Heiko</a> raised the question of whether we should have a dedicated session on dependency injection at one of the next democamps:</p>
<div style="text-align:center;"><a href="http://twitter.com/HBehrens/status/6344196851" title="View '@HBehrens asks "Do we need a DI session at the next DemoCamp?"' on Twitter"><img border="0" width="515" alt="@HBehrens asks "Do we need a DI session at the next DemoCamp?"" src="http://farm3.static.flickr.com/2559/4165228359_168886eee6_o.jpg" height="81"/></a></div>
<p>Jochen continued his session, explaining how the e4 UI is being rendered by a presentation engine which can be configured using various renderers, each one providing an individual look and feel.</p>
<p>e4 is the future of Eclipse, and Jochen concluded his talk by pointing out that in order to ensure e4 has a sustainable future, companies and individuals should participate in the development of e4. This can be done by:</p>
<ul>
<li>Playing around with e4 and providing feedback</li>
<li>Participating in the development process (see the <a href="http://www.eclipse.org/projects/project_summary.php?projectid=eclipse.e4">e4 project homepage</a> for more info)</li>
<li>Paying existing committers (see <a href="http://tomsondev.bestsolution.at/2009/12/04/e4-some-random-thoughts-2nd-iteration/">Tom's blog posting</a> to learn how to buy one and get one free)</li>
</ul>
<p>More info on e4 can be found <a href="http://wiki.eclipse.org/E4">on the Eclipse wiki</a>.</p>
<p>After the talk, we had a short break to set up the next presenter, enjoy some refreshments and, of course, socialize:</p>
<table align="center" border="0">
<tr>
<td>
<div style="text-align:center;"><a href="http://www.flickr.com/photos/nossipova/4163774122/in/set-72157622946379026/" title="View 'A short coffee break' on Flickr.com"><img border="0" width="240" alt="A short coffee break" src="http://farm3.static.flickr.com/2677/4163774122_deb8824525_m.jpg" height="159"/></a></div>
</td>
<td>
<div style="text-align:center;"><a href="http://www.flickr.com/photos/nossipova/4163774270/in/set-72157622946379026/" title="View 'A short coffee break' on Flickr.com"><img border="0" width="240" alt="A short coffee break" src="http://farm3.static.flickr.com/2629/4163774270_994158865a_m.jpg" height="159"/></a></div>
</td>
</tr>
</table>
<h3>Combining graphics and text in model editors (Jan Köhnlein)</h3>
<p>After the break, Jan Köhnlein took stage and told the audience that graphics and text and no different, but really are just two views on the same thing:</p>
<table align="center" border="0">
<tr>
<td>
<div style="text-align:center;"><a href="http://www.flickr.com/photos/nossipova/4163773536/in/set-72157622946379026/" title="'Jan Köhnlein - Combining graphics and text in model editors' on Flickr.com"><img border="0" width="240" alt="Jan Köhnlein - Combining graphics and text in model editors" src="http://farm3.static.flickr.com/2658/4163773416_d0ed0d2dc2_m.jpg" height="159"/></a></div>
</td>
<td>
<div style="text-align:center;"><a href="http://www.flickr.com/photos/nossipova/4163773536/in/set-72157622946379026/" title="'Jan Köhnlein - Combining graphics and text in model editors' on Flickr.com"><img border="0" width="240" alt="Jan Köhnlein - Combining graphics and text in model editors" src="http://farm3.static.flickr.com/2577/4163773536_22c3bcdab4_m.jpg" height="159"/></a></div>
</td>
</tr>
</table>
<p>Jan pointed out that both text and graphics have their relative virtues:</p>
<p><strong>Text...</strong></p>
<ul>
<li>provides a detailed view on things</li>
<li>can have a very formal syntax</li>
<li>can be typed using  standard text editors</li>
<li>can be managed using standard versioning mechanisms (merge / diff) </li>
<li>can be typed fast</li>
</ul>
<p><strong>Graphical representations on the other hand...</strong></p>
<ul>
<li>provides high-level views and a good overview</li>
<li>suggests non-formalism</li>
<li>requires custom editors for your graphical notation (i.e., you <em>need</em> to write them)</li>
<li>has no good support for merging / diffing</li>
<li>requires the user to use a mouse a lot, and thus is slower than a text editor</li>
</ul>
<p>Apparently, both have advantages, so why not use both?</p>
<p>In the following 5 minutes, Jan gave an ultra-quick introduction in how Xtext (as a representative of a textual modeling toolkit) and GMF (as a representative for a graphical modeling toolkit) work. The bottom line is both use Ecore metamodels, so we <em>should</em> be able to combine both.</p>
<p>It turns out, however, that Xtext and GMF metamodels are slightly different and you need to take some precautious steps in order to make them interoperable.</p>
<p>After this excursion into the theory behind the convergence of graphical and textual editors, Jan showed two editors, one graphical and one textual that synced live. Changing the model in one editor and saving it effected an immediate update in the other editor - really neat.</p>
<p>Jan pointed out that this is all very fine, but sometimes you really want to have a tight integration. As a proof of concept, he showed a GMF-based editor with an embedded Xtext editor: as soon as he pressed <em>F2</em> to edit a field in the graphical editor, an inline Xtext editor would pop up, featuring syntax highlighting, code completion and error markers - really awesome!</p>
<p>More information on <a href="http://www.xtext.org">Xtext</a> and <a href="http://www.eclipse.org/modeling/gmf/">GMF</a> can be found on their respective homepages. Jan works for <a href="http://www.itemis.com">itemis</a> and provides consulting and training for these technologies.</p>
<p>All these exciting things must have made people gasp for air, because the oxygen level in the room was very low at the end of the session, so we had another break. As always with gathering like this, hallway talks very equally important as the sessions, and people made good use of the break:</p>
<table align="center" border="0">
<tr>
<td>
<div style="text-align:center;"><a href="http://www.flickr.com/photos/nossipova/4163774372/in/set-72157622946379026/" title="'Another short coffee break' on Flickr.com"><img border="0" width="240" alt="Another short coffee break" src="http://farm5.static.flickr.com/4003/4163774372_191055b0d5.jpg" height="159"/></a></div>
</td>
<td>
<div style="text-align:center;"><a href="http://www.flickr.com/photos/nossipova/4163013089/in/set-72157622946379026/" title="View 'A short coffee break' on Flickr.com"><img border="0" width="240" alt="A short coffee break" src="http://farm3.static.flickr.com/2720/4163013089_038142a6ca_m.jpg" height="159"/></a></div>
</td>
</tr>
</table>
<h3>RAP (Jochen Krause)</h3>
<p>Jochen's presented his talk on RAP without a single slide - "in the tradition of the Karlsruhe DemoCamps", as he pointed out.</p>
<div style="text-align:center;"><a href="http://www.flickr.com/photos/nossipova/4163774844/in/set-72157622946379026/" title="'Jochen Krause - RAP' on Flickr.com"><img border="0" width="500" alt="Jochen Krause - RAP" src="http://farm3.static.flickr.com/2714/4163774844_0fa2daf90d.jpg" height="332"/></a></div>
<p>No technical session without some history and some theory, so Jochen first explained that RAP implements the <a href="http://javadesktop.org/articles/canoo/">Half Object Pattern</a> and demoed the very first version of RAP. While running an Eclipse UI in the browser is all very exciting, feedback from initial users wasn't too positive: "please spare us this look'n'feel in the browser!"</p>
<p>So the good people at innoopract (now EclipseSource) spent some time to implement custom styling for RAP UIs, which Jochen showed in his second demo, which he called "The Enterprise Look'n'Feel" due to it's feasibility for enterprise applications.</p>
<p>The third demo featured "rounded corners" (see <a href="http://www.eclipse.org/rap/noteworthy/news_13M1.php">RAP New & Noteworthy</a>). While this might seem like little gained, Jochen explained that implementing rounded corners was both important on an acceptance level and challenging on the implementation level. Would you have thought that rounded corners are implemented using CSS on FireFox and VML on Internet Explorer?</p>
<p>Of course, RAP is implemented as an Open Source project at Eclipse, welcoming any contribution from users worldwide. Jochen demonstrated how great the Open Source model works by showing off a ribbon-style command bar for RAP which is available on Google Code (see the <a href="http://code.google.com/p/rapit/">rapit project home page</a>)</p>
<p>In the next demo, Jochen showed how he integrated EMF and RAP. His goal was to RAPify the EMF tree editor for EMF models. It turned out that basically it is very simple to convert the EMF editor (or any other Eclipse plug-in for that matter) into a RAP application - only very little adjustments were needed. However, as web applications are multi-user applications by definition, additional care has to be taken when converting editors. As Eclipse is a single-user application, editors are not prepared to be executed in a multi-user environment. Jochen explained how he tried to use CDO to store the edited models on a remote server, but failed due to the complexities of CDO. He succeeded by using <a href="http://couchdb.apache.org/">CouchDB</a>, a database written in Erlang and with an HTTP interface (look ma - no JDBC driver needed!).</p>
<p>Jochen concluded his session with a few notes on features they've just completed (Drag'n'Drop) or which are not available (yet) like GC.paint.</p>
<p>After that, he took some of the audience's questions, e.g. "How many users can a RAP server take?". Of course, it depends, but you can roughly count 1MB per user and workbench.</p>
<p>Jochen thought it would be OK to continue without a break, but Martin decided we should rather have a short break to let in some air.</p>
<p>More information on RAP can be found on the <a href="http://wiki.eclipse.org/RAP">Eclipse wiki</a> and on the <a href="http://eclipse.org/rap/">project homepage</a>. Jochen's company <a href="http://eclipsesource.com/">EclipseSource</a> provides professional services, training and resources around RAP, so have a look at their website.</p>
<h3>50 ways to build your bundle (Gerd Wütherich & Nils Hartmann)</h3>
<p>After the "short" break, Gerd Wütherich and Nils Hartmann presented their view on build management: "Fifty Ways to Buid Your Bundle":</p>
<div style="text-align:center;"><a href="http://www.flickr.com/photos/nossipova/4163014129/in/set-72157622946379026/" title="'Gerd Wütherich and Nils Hartmann"><img border="0" width="500" alt="Gerd Wütherich and Nils Hartmann" src="http://farm3.static.flickr.com/2699/4163014129_8b53cf8923.jpg" height="332"/></a></div>
<p>Facing the fact that nobody seems to be too excited about build management these days, they decided to arrest people's attention by adapting the well-known story "<a href="http://en.wikipedia.org/wiki/A_Christmas_Carol">A Christmas Carol</a>" by <a href="http://en.wikipedia.org/wiki/Charles_Dickens">Charles Dickens</a>. A brilliant idea, which really made people laugh at various points throughout the presentation.</p>
<p>The presentation was subdivided in three parts:</p>
<p><strong>The Ghost of Build Past</strong><br />
Gerd and Nils explained how in the past, people have been building bundes using PDE build, using a <em>Manifest-First</em>-approach. Building bundles with PDE build is rather cumbersome: you have to setup map files in order to help PDE build to derive ANT build files which will then be executed by the AntRunner inside Eclipse. While this ensures the build process sees exactly what Eclipse sees when you develop your bundles in the workspace, this basically makes debugging your build process very complicated.</p>
<p><strong>The Ghost of Build Today</strong><br />
Today, we've got bundles everywhere and OSGi is being used not only for Eclipse plug-ins, but also for conventional applications. As good programers obeying the <a href="http://en.wikipedia.org/wiki/Don't_repeat_yourself">DRY</a> <a href="http://c2.com/cgi/wiki?DontRepeatYourself">principle</a>, we want to have a redundancy-free description of our build artifacts, i.e. derive build dependencies by looking at <em>MANIFEST.MF</em>. In the enterprise, things can get really nasty, as we often need to integrate various very different build systems: you might have to build an EJB client JAR (maybe using Maven) which then need to be integrated in an Eclipse RCP client application, which again needs to be built using PDE build.</p>
<p>Nils and Gerd showed a slide which listed all major build tools for bundles, among them:</p>
<ul>
<li>Springsource Tool Suite</li>
<li>PDE</li>
<li>Athena</li>
<li>PluginBuilder</li>
<li>Buckminster</li>
<li>Tycho</li>
<li>Maven</li>
<li>b3</li>
<li>Ant4Eclipse</li>
<li>PDE build</li>
<li>bnd</li>
<li>Ivy</li>
<li>Buildr</li>
<li>IDEA</li>
<li>Sigil</li>
<li>buildr4osgi</li>
<li>OsgiPlugin</li>
<li>ANT</li>
<li>Bundlr</li>
</ul>
<p>After which they showed three exemplary setups how to actually build bundles:</p>
<ol>
<li>ANT4Eclipse</li>
<li>Maven Tycho</li>
<li>Buckminster</li>
</ol>
<p>Please refer to their slide deck, slides 14 - 16 for detailed diagrams on these three setups:<br />
<center><object style="margin:0px" width="425" height="355"><param name="movie" value="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=fiftywaystobuildyourbundle-091205030107-phpapp02&rel=0&stripped_title=fifty-ways-to-build-your-bundle" /><param name="allowFullScreen" value="true"/><param name="allowScriptAccess" value="always"/><embed src="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=fiftywaystobuildyourbundle-091205030107-phpapp02&rel=0&stripped_title=fifty-ways-to-build-your-bundle" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="355"></embed></object></center><br />
<!--<br />
4 exemplary samples:<br />
1) ant4eclipse<br />
- write plain ant file<br />
- there is a task that can access eclipse artifacts such as manifest and plugin.xml<br />
- macros, e.g. buildbundle (does it all)<br />
- planned: support for p2 to provision target platform<br />
2) maven tycho<br />
- works on Eclipse artifacts<br />
- does not use traditional maven project layout<br />
- instead, uses Eclipse layout, looks at plugin.xml and manifest.mf to find your stuff<br />
3) buckminster<br />
- kind of "meta-maven"<br />
- can use various repositories at the same time<br />
- uses cqueries (component queries) to search for components and materialize them on local build workspace<br />
- materialized components will then be converted into required form<br />
- has gui<br />
- also support headless build<br />
--></p>
<p><strong>Ghost of Build Future</strong><br />
As things get more complicated, build management will also most likely become more complicated. Gerd and Nils pointed out that build management might be an unthankful job, but it must not be assigned to "people that aren't good at programming". Instead, they advocated making build management a first class citizen in computer sciences education.</p>
<p>More information on the tools and techniques presented are available at their respective home pages. In addition, you can contact <a href="http://www.nilshartmann.net/">Nils</a> and <a href="http://drupal.wuetherich.com/">Gerd</a> and bug them with your questions. They're consultants, so they can be hired.</p>
<h3>redView - dynamic views for business applications</h3>
<p>The final session was held by Ekkehard Gentz, better known as <em>ekke</em>. He showed a smart combination of Eclipse technologies: Riena, EMF, openArchitectureWare (Xpand, Xtend, MWE) and Xtext. Of course, being an Open Source advocate, Ekke and his team mate Florian provide this stack as an <a href="http://code.google.com/p/redview/">Open Source project on Google Code</a>.</p>
<div style="text-align:center;"><a href="http://www.flickr.com/photos/nossipova/4163014969/in/set-72157622946379026/" title="ekke (Ekkehard Gentz) - redView - dynamic views for business applications"><img border="0" width="500" alt="ekke (Ekkehard Gentz) - redView - dynamic views for business applications" src="http://farm3.static.flickr.com/2681/4163014969_3199649714.jpg" height="332"/></a></div>
<p>redView is <em>a declarative framework based on the Eclipse Modeling Framework (EMF), for creating RCP Views enriched with Riena Ridgets</em>. It uses EMF to describe the application with a model. An Xpand-based code generator will then transform the model into code for the application. Ekke states that their goal is not to limit developers' creativity, but instead relieve them from the burden of having to write all the boilerplate code.</p>
<p>redView supports the most important UI elements, including some Nebula widgets. One thing I fond very impressive was their UI editor. Ekke gave a demo in which he hosted the UI model on a CDO (which seems to be Eclipse's wunderkind) server on a virtual machine. He started a second virtual machine, running an instance of the application. Upon changing the UI model in the UI designer on one machine, the UI was updated immediately on the second machine. Ekke pointed out that this usage pattern is especially useful in prototyping scenarios: the developer changes the model on his PC in his office and the customer can immediately see the changes on his machine, hundreds of kilometers away.</p>
<p>More information on redView can be obtained from their <a href="http://redview.org">project homepage</a>. Ekkehard is a freelance consultant, so <a href="http://www.ekkehard.org/">you can hire him</a> if you've got any questions regarding the technologies presented.</p>
<h3>Gimmicks</h3>
<p>After the demos, we raffled off 20 Eclipse Keybinding Mugs (see <a href="http://relengofthenerds.blogspot.com/2009/11/good-eclipse-swag.html">Kim Moir's blog post</a> for a 360° shot of the mug) - congratulations to all winners! it-agile also provided a fine selection of agile swag: retrospective mugs, team calendars, post-its and what have you:</p>
<div style="text-align:center;"><a href="http://www.flickr.com/photos/nossipova/4163771282/in/set-72157622946379026/" title="Agile swag"><img border="0" width="500" alt="Agile swag" src="http://farm3.static.flickr.com/2709/4163771282_53db8e31f1.jpg" height="332"/></a></div>
<p>Despite the fact Ralph Müller couldn't attend the event, we eventually headed to the EAST bar for some frosty beverages.</p>
<p>All in all, it has been a very enjoyable event and from what I gathered, most attendees seem to have enjoyed the DemoCamp as well.</p>
<p>Thanks everyone for attending! Also, thank you to all speakers. Last but not least a big thank you to <a href="http://twitter.com/nossipova">Natalia</a> for taking pictures of the event!</p>
<p>Hope to see you again at the next DemoCamp in Summer 2010!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.peterfriese.de/eclipse-democamp-hamburg-112009/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Xtext Tricks #1: Enhancing Completion Proposals</title>
		<link>http://www.peterfriese.de/xtext-tricks-1-enhancing-completion-proposals/</link>
		<comments>http://www.peterfriese.de/xtext-tricks-1-enhancing-completion-proposals/#comments</comments>
		<pubDate>Tue, 27 Oct 2009 14:55:43 +0000</pubDate>
		<dc:creator>Peter Friese</dc:creator>
				<category><![CDATA[DSLs]]></category>
		<category><![CDATA[Eclipse]]></category>
		<category><![CDATA[MDSD]]></category>

		<guid isPermaLink="false">http://www.peterfriese.de/?p=337</guid>
		<description><![CDATA[Those of you who follow me on Twitter might have noticed I am working on an Xtext based DSL for Behaviour Driven Development. Part of the DSL allows the DSL user to define actors and the verbs these actors can execute. Actors can have a hierarchy (much like a class hierarchy), meaning an actor will[...]]]></description>
			<content:encoded><![CDATA[<p>Those of you who <a href="htp://twitter.com/peterfriese">follow me on Twitter</a> might have noticed <a href="http://twitter.com/peterfriese/status/4889552469">I am working on an Xtext based DSL</a> for <a href="http://en.wikipedia.org/wiki/Behavior_driven_development">Behaviour Driven Development</a>. Part of the DSL allows the DSL user to define actors and the verbs these actors can execute. Actors can have a hierarchy (much like a class hierarchy), meaning an actor will inherit all verbs of it's super actors. As the list of verbs can grow quite a bit, the content assist drop down menu becomes a bit overwhelming.</p>
<p><a href="http://www.flickr.com/photos/81029262@N00/4029808851" title="View 'XtextProposalProviderBefore' on Flickr.com">
<div style="text-align:center;"><img src="http://farm3.static.flickr.com/2581/4029808851_22fd514946.jpg" alt="XtextProposalProviderBefore" border="0" width="459" height="339" /></div>
<p></a></p>
<p>To alleviate  this situation, I decided to display the "owner" of a verb along with the name of the verb in the content assist drop down box. Here is my first try:<br />
<span id="more-337"></span></p>
<pre>
public class StoryDslProposalProvider extends AbstractStoryDslProposalProvider {
  @Override
  protected ICompletionProposal createCompletionProposal(EObject element, String proposal, String displayString, ContentAssistContext contentAssistContext)
  {
    if (element instanceof Verb) {
      Verb verb = (Verb) element;
      Subject owner = ((Subject)verb.eContainer());
      String myDisplayString = verb.getName() + ": " + owner.getName();
      return super.createCompletionProposal(element, proposal, myDisplayString, contentAssistContext);
    }
    return super.createCompletionProposal(element, proposal,  displayString, contentAssistContext);
  }
}
</pre>
<p>With this piece of code in place, the content assist proposals for verbs will now display the name of the "owner" to the right of the replacement text:</p>
<p><a href="http://www.flickr.com/photos/81029262@N00/4030575068" title="View 'XtextContentAssistAfter' on Flickr.com">
<div style="text-align:center;"><img src="http://farm4.static.flickr.com/3526/4030575068_2358208f22.jpg" alt="XtextContentAssistAfter" border="0" width="456" height="329" /></div>
<p></a></p>
<p><a href="http://zarnekow.blogspot.com/">Sebastian</a> pointed out that there is a <code>getDisplayString()</code> in <code>AbstractContentProposalProvider</code> that you should override in order to create a custom display string. It turned out, however, that this method will not be called as expected. I <a href="http://bugs.eclipse.org/bugs/show_bug.cgi?id=293380">filed a bug</a>, so expect to see a fix in one of the next milestones of the Xtext 0.8.0 stream.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.peterfriese.de/xtext-tricks-1-enhancing-completion-proposals/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
