<?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>Anthony Dahanne&#039;s blog &#187; java</title>
	<atom:link href="http://blog.dahanne.net/category/java/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.dahanne.net</link>
	<description>Open Source Software, Java, Android, Continuous Integration</description>
	<lastBuildDate>Fri, 20 Jan 2012 02:32:20 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Run UI tests on a headless Jenkins / Hudson Continuous Integration server running Ubuntu</title>
		<link>http://blog.dahanne.net/2011/07/18/run-ui-tests-on-a-headless-jenkins-hudson-continuous-integration-server-running-ubuntu/</link>
		<comments>http://blog.dahanne.net/2011/07/18/run-ui-tests-on-a-headless-jenkins-hudson-continuous-integration-server-running-ubuntu/#comments</comments>
		<pubDate>Mon, 18 Jul 2011 03:43:59 +0000</pubDate>
		<dc:creator>anthony.dahanne</dc:creator>
				<category><![CDATA[continuous integration hudson jenkins]]></category>
		<category><![CDATA[eclipse]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[tycho]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://blog.dahanne.net/?p=535</guid>
		<description><![CDATA[<p>If you want to set up a ci build, running ui tests, on a box without any windowing system, you need to pay attention to a few details, here are some of  them :</p> Set up your ubuntu box and Jenkins/Hudson <p>On your ubuntu box :</p> <p># apt-get install vnc4server fluxbox</p> <p>Vnc4server is a free [...]]]></description>
			<content:encoded><![CDATA[<p>If you want to set up a ci build, running ui tests, on a box without any windowing system, you need to pay attention to a few details, here are some of  them :</p>
<h3>Set up your ubuntu box and Jenkins/Hudson</h3>
<p>On your ubuntu box :</p>
<p><code># apt-get install vnc4server fluxbox</code></p>
<p>Vnc4server is a free vnc server, that will act as your X environment, and fluxbox is a tiny window manager; more than enough for UI testing.</p>
<p>In Jenkins / Hudson, Manage Jenkins -&gt; Plugins -&gt; Install new plugins, choose the <a href="https://wiki.jenkins-ci.org/display/JENKINS/Xvnc+Plugin">xvnc plugin </a></p>
<p><a href="http://blog.dahanne.net/wp-content/uploads/S%C3%A9lection_001.png"><img class="alignnone size-medium wp-image-542" title="xvnc plugin" src="http://blog.dahanne.net/wp-content/uploads/S%C3%A9lection_001-300x38.png" alt="" width="300" height="38" /></a></p>
<div>In your job that launches UI tests (in my case it was Eclipse Equinox UI tests launched by a tycho build), tick the box &laquo;&nbsp;Run xvnc during build&nbsp;&raquo;</div>
<div>Now launch your job, you will run into this problem :</div>
<pre class="bash">Starting xvnc [workspace] $ vncserver :10 You will require a password to access your desktops. getpassword error: Invalid argument Password:Starting xvnc [workspace]</pre>
<div>etc&#8230; until vncserver :13</div>
<div>It is because you need to launch vncserver interactively, at least once, to setup a password; connect to your ubuntu box and:</div>
<pre class="bash"># su jenkins
$ vncserver :10You will require a password to access your desktops.

Password:
Verify:
Password too long - only the first 8 characters will be used
xauth:  creating new authority file /var/lib/jenkins/.Xauthority

New 'host:10 (jenkins)' desktop is host:10

Creating default startup script /var/lib/jenkins/.vnc/xstartup
Starting applications specified in /var/lib/jenkins/.vnc/xstartup
Log file is /var/lib/jenkins/.vnc/host:10.log</pre>
<div>
<div>Once this is done, re launch your job :</div>
<pre class="bash">[workspace] $ vncserver :14

New 'host:14 (jenkins)' desktop is host:14 Starting applications specified in /var/lib/jenkins/.vnc/xstartup Log file is /var/lib/jenkins/.vnc/host:14.log</pre>
<div>and your build goes on, able to create a UI during the tests !</div>
</div>
<h3>Have a look at the tested UI while the tests are running</h3>
<p>This can be very useful whenever your UI gets stuck (waiting on a dialog to be closed &#8230;, in my case I run into the issue of launching an eclipse runtime, and a plugin, Google ADT, was asking to confirm whether or not I wanted to upload usage data&#8211; hopefully only the first time) during the tests.</p>
<div>To do so, you first have to know what is the port xvnc is listening to :</div>
<pre class="bash"># ps aux |grep "vnc"
jenkins  29591  0.0  0.7  33192 14104 ?        S    21:10   0:00 Xvnc4 :14 -desktop host:14 (jenkins) -auth /var/lib/jenkins/.Xauthority -geometry 1024x768 -depth 16 -rfbwait 30000 -rfbauth /var/lib/jenkins/.vnc/passwd -rfbport 5914 -pn -fp /usr/X11R6/lib/X11/fonts/Type1/,/usr/X11R6/lib/X11/fonts/Speedo/,/usr/X11R6/lib/X11/fonts/misc/,/usr/X11R6/lib/X11/fonts/75dpi/,/usr/X11R6/lib/X11/fonts/100dpi/,/usr/share/fonts/X11/misc/,/usr/share/fonts/X11/Type1/,/usr/share/fonts/X11/75dpi/,/usr/share/fonts/X11/100dpi/ -co /etc/X11/rgb</pre>
<p>OK, looks like xvnc is listening on port 5914 in this case.<br />
You can then use a vnc viewer (on ubuntu, vinagre is a good choice) of your choice to connect to your ubuntu box on port 5914.<br />
If the ubuntu box has firewall rules impeding you to connect to 5914, then set up a ssh tunnel :</p>
<p><code>$ ssh -L 5914:localhost:5914 anthony@ubuntubox</code><br />
then connect your vnc viewer to localhost:5914 , and the magic begins !</p>
<p><a href="http://blog.dahanne.net/wp-content/uploads/S%C3%A9lection_002.png"><img class="alignnone size-medium wp-image-543" title="Seeing the UI tested in Hudson /  Jenkins through vnc" src="http://blog.dahanne.net/wp-content/uploads/S%C3%A9lection_002-215x300.png" alt="" width="215" height="300" /></a></p>
<p>&nbsp;</p>
<h3>A concrete example :  m2eclipse-android-integration in Jenkins</h3>
<p>I actually set up this configuration for the m2eclipse-android-integration project; this project is an eclipse plugin, that extends the capability of m2eclipse to android projects, here is the link to the<a href="http://ci.dahanne.net/"> Jenkins hosting this job</a></p>
<p>The author, <a href="http://rgladwell.wordpress.com/">Ricardo Gladwell</a>, designed exclusively integration tests on the UI, since most of the functionality of this eclipse plugin is UI contribution.</p>
<p>Here are the specific problems I met while setting up this job in Jenkins :</p>
<ul>
<li>as I previously mentioned, the first time I launched the job against this project, once all the tests passed, the tycho surefire plugin step would not stop&#8230; actually the Google ADT plugin in Eclipse, was asking to confirm whether or not I wanted to upload usage data, so I connected to the UI and clicked &laquo;&nbsp;ok&nbsp;&raquo;;  vnc saved the day&#8230;</li>
<li>the tests were relying on android projects, requiring to have among the latest Android libraries; to be up to date (so that the tests would not fail), I had to run the command :</li>
</ul>
<p><code>$ android update sdk --no-ui --obsolete --force</code></p>
<p>Overall, that was a good exercise to practice CI on a UI project.</p>
<p>Links :</p>
<div>
<ul>
<li><a href="https://wiki.jenkins-ci.org/display/JENKINS/Xvnc+Plugin">The Hudson / Jenkins xVNC plugin</a>\</li>
<li><a href="http://code.google.com/a/eclipselabs.org/p/m2eclipse-android-integration/">m2eclipse-android-integration on google code</a> and now <a href="http://rgladwell.github.com/m2e-android/">m2e-android on github</a></li>
</ul>
</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.dahanne.net/2011/07/18/run-ui-tests-on-a-headless-jenkins-hudson-continuous-integration-server-running-ubuntu/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>EclipseCon 2011 blog posts : talks I attended</title>
		<link>http://blog.dahanne.net/2011/04/13/eclipsecon-2011-blog-posts-talks-i-attended/</link>
		<comments>http://blog.dahanne.net/2011/04/13/eclipsecon-2011-blog-posts-talks-i-attended/#comments</comments>
		<pubDate>Wed, 13 Apr 2011 03:09:52 +0000</pubDate>
		<dc:creator>anthony.dahanne</dc:creator>
				<category><![CDATA[conferences]]></category>
		<category><![CDATA[eclipsecon2011]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[open source]]></category>

		<guid isPermaLink="false">http://blog.dahanne.net/?p=521</guid>
		<description><![CDATA[<p>From the 21st to the 24th of March, 2011, I was a lucky attendee of EclipseCon 2011.</p> <p>Lucky because it was my first time at EclipseCon, my first major conference in North America (it was located in Santa Clara, in the Californian Silicon Valley) and also because my employer, Compuware, agreed to let me go [...]]]></description>
			<content:encoded><![CDATA[<p>From the 21st to the 24th of March, 2011, I was a lucky attendee of <a href="http://www.eclipsecon.org/2011/">EclipseCon 2011</a>.</p>
<p>Lucky because it was my first time at EclipseCon, my first major conference in North America (it was located in Santa Clara, in the Californian Silicon Valley) and also because my employer,<a href="http://www.compuware.com/"> Compuware</a>, agreed to let me go there, along with 2 of my colleagues.</p>
<p>EclipseCon 2011 was great, because</p>
<ul>
<li>the main actors of the Eclipse community were there : people I may follow on twitter or ask questions to on several mailing lists; the committers of the projects I use everyday at work; being able to chat with them and ask them questions (even harass them ! no I&#8217;m kidding, I did not harass Jeff during 2 days! )</li>
<li>the talks were diversified and most of them were really interesting, you have below links to some of the talks I attended while there.</li>
</ul>
<p>Attending this conference made me also realize, maybe once more, that meeting with other developers working on the same technologies, is really inspiring, motivating, and it makes you grow technically.</p>
<p>Ok, you got the picture, I enjoyed the conf !</p>
<p>Here are some of the talks I attended:</p>
<ul>
<li>Under the provisioning (p2) and release engineering themes,</li>
</ul>
<ol>
<li><a title="Permanent Link to p2, your savior or your achilles heel? Everything an Eclipse team needs to know about p2 at EclipseCon 2011" rel="bookmark" href="http://blog.dahanne.net/2011/03/22/p2-your-savior-or-your-achilles-heel-everything-an-eclipse-team-needs-to-know-about-p2-at-eclipsecon-2011/">p2, your savior or your Achilles heel? Everything an Eclipse team needs to know about p2 at EclipseCon 2011</a></li>
<li><a title="Permanent Link to Discovering the P2 APIs at EclipseCon 2011" rel="bookmark" href="http://blog.dahanne.net/2011/03/22/discovering-the-p2-apis-at-eclipsecon-2011/">Discovering the P2 APIs at EclipseCon 2011</a></li>
<li><a title="Permanent Link to Tycho presentation and tutorial at EclipseCon 2011" rel="bookmark" href="http://blog.dahanne.net/2011/03/21/tycho-presentation-and-tutorial-at-eclipsecon-2011/">Tycho presentation and tutorial at EclipseCon 2011</a></li>
<li><a title="Permanent Link to Next Generation Development Infrastructure: Maven, m2eclipse, Nexus &amp; Hudson at EclipseCon 2011" rel="bookmark" href="http://blog.dahanne.net/2011/03/22/next-generation-development-infrastructure-maven-m2eclipse-nexus-hudson-at-eclipsecon-2011/">Next Generation Development Infrastructure: Maven, m2eclipse, Nexus &amp; Hudson at EclipseCon 2011</a></li>
<li><a title="Permanent Link to Growing an open source project one bugday at a time at EclipseCon 2011" rel="bookmark" href="../2011/03/22/growing-an-open-source-project-one-bugday-at-a-time-at-eclipsecon-2011/">Growing an open source project one bugday at a time at EclipseCon 2011</a></li>
</ol>
<ul>
<li>Under the architecture ,  performance and OSGI themes,</li>
</ul>
<ol>
<li><a title="Permanent Link to Stop the Architecture Erosion of Eclipse And Open Source Projects at EclipseCon 2011" rel="bookmark" href="http://blog.dahanne.net/2011/03/24/stop-the-architecture-erosion-of-eclipse-and-open-source-projects-at-eclipsecon-2011/">Stop the Architecture Erosion of Eclipse And Open Source Projects at EclipseCon 2011</a></li>
<li><a title="Permanent Link to Using and Extending Memory Analyzer into Uncharted Waters at EclipseCon 2011" rel="bookmark" href="http://blog.dahanne.net/2011/03/23/using-and-extending-memory-analyzer-into-uncharted-waters-at-eclipsecon-2011/">Using and Extending Memory Analyzer into Uncharted Waters at EclipseCon 2011</a></li>
<li><a title="Permanent Link to OSGi introduction and OSGi 4.3 at EclipseCon2011" rel="bookmark" href="http://blog.dahanne.net/2011/03/21/osgi-introduction-and-osgi4-3-at-eclipsecon2011/">OSGi introduction and OSGi 4.3 at EclipseCon2011</a></li>
<li><a title="Permanent Link to 10 signs you’re doing OSGi wrong at EclipseCon 2011" rel="bookmark" href="http://blog.dahanne.net/2011/03/22/10-signs-youre-doing-osgi-wrong-at-eclipsecon-2011/">10 signs you&#8217;re doing OSGi wrong at EclipseCon 2011</a></li>
</ol>
<ul>
<li>Under the Eclipse tooling theme,</li>
</ul>
<ol>
<li><a title="Permanent Link to Android Development with Eclipse at EclipseCon 2011" rel="bookmark" href="http://blog.dahanne.net/2011/03/22/android-development-with-eclipse-at-eclipsecon-2011/">Android Development with Eclipse at EclipseCon 2011</a></li>
<li><a title="Permanent Link to Getting Eclipse Preferences Under Control in Teams at EclipseCon 2011" rel="bookmark" href="http://blog.dahanne.net/2011/03/24/eclipse-preferences-under-control-in-teams-at-eclipsecon-2011/">Getting Eclipse Preferences Under Control in Teams at EclipseCon 2011</a></li>
</ol>
<ul>
<li>Other really cool talks</li>
</ul>
<ol>
<li><a title="Permanent Link to Keynote on Apache Hadoop at EclipseCon 2011" rel="bookmark" href="http://blog.dahanne.net/2011/03/24/keynote-on-apache-hadoop-at-eclipsecon-2011/">Keynote on Apache Hadoop at EclipseCon 2011</a></li>
<li><a title="Permanent Link to Virgo and RT playing together at EclipseCon 2011" rel="bookmark" href="http://blog.dahanne.net/2011/03/23/virgo-and-rt-playing-together-at-eclipsecon-2011/">Virgo and RT playing together at EclipseCon 2011</a></li>
<li><a title="Permanent Link to Effective Git tutorial at EclipseCon 2011" rel="bookmark" href="http://blog.dahanne.net/2011/03/21/effective-git-tutorial-at-eclipsecon-2011/">Effective Git Tutorial</a></li>
</ol>
<p>If you want my opinion, well, I&#8217;d say that Tycho, p2, Virgo, git along with gerrit, and Eclipse Memory Analyzer were predominant topics; you could definitely not ignore them.. and not like them neither !</p>
<p>If you did not, you&#8217;ll hear from these great technologies in the next few months !</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.dahanne.net/2011/04/13/eclipsecon-2011-blog-posts-talks-i-attended/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tycho presentation and tutorial at EclipseCon 2011</title>
		<link>http://blog.dahanne.net/2011/03/21/tycho-presentation-and-tutorial-at-eclipsecon-2011/</link>
		<comments>http://blog.dahanne.net/2011/03/21/tycho-presentation-and-tutorial-at-eclipsecon-2011/#comments</comments>
		<pubDate>Mon, 21 Mar 2011 19:23:44 +0000</pubDate>
		<dc:creator>anthony.dahanne</dc:creator>
				<category><![CDATA[conferences]]></category>
		<category><![CDATA[eclipsecon2011]]></category>
		<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://blog.dahanne.net/?p=422</guid>
		<description><![CDATA[Building plugins with Tycho <p>When I entered the room, I got handed over a usb stick with an archive named theinternet.zip (we&#8217;ll see what&#8217;s inside during the tutorial); the room is packed, the session is beginning in few minutes.</p> Presentation of Tycho; Jan first defined the audience what is Tycho about : a way to [...]]]></description>
			<content:encoded><![CDATA[<h3>Building plugins with Tycho</h3>
<p>When I entered the room, I got handed over a usb stick with an archive named theinternet.zip (we&#8217;ll see what&#8217;s inside during the tutorial); the room is packed, the session is beginning in few minutes.</p>
<h4>Presentation of Tycho;</h4>
<ul>
<li>Jan first defined the audience what is Tycho about : a way to build Eclipse/OSGi artifacts with Maven,</li>
<li>then who are the nowadays contributors : SAP, Sonatype and Intalio</li>
<li>who is using it : the contributors, for sure; and EGit, P2, JBoss tools, Eclipse Memory Analyzer, JRebel, etc&#8230;</li>
<li>the relation between Maven and Tycho : Tycho is solving dependencies from Manifest.MF, features.xml; and is working in a Manifest first approach compared to a pom.xml first.(but it can also be used in a pom first approach)</li>
<li>the relation between P2 and Tycho : Tycho produces P2 repositories; Tycho consumes P2 repositories and its metadata</li>
<li>the relation between PDE and Tycho : tycho uses the same artifacts (Manifest.mf, build.properties, feature.xml, site.xml) and is actually complementary to PDE UI; but is a competitor to PDE headless mode.</li>
<li>where is tycho : open source, incubating in Eclipse foundation, code base on github</li>
</ul>
<p>After those good words, Pascal demoed tycho</p>
<ul>
<li>Pascal showed some p2 projects being built with Tycho (all p2 projects contained their pom.xml, defining the name of the plugin, and the type : eclipse-plugin or eclipse-feature actually) ; he had also to add a parent pom to be able to build all at once : he cd&#8217;ed to to the p2 agregator project and a simple &laquo;&nbsp;mvn clean install&nbsp;&raquo;; later; tycho began the magic; during the compilation, Pascal talked about is PDE doing compared to tycho (for example the steps order is different) after 1min  and a half later; the crowd applauded Pascal : the p2 projects were built; pretty fast.</li>
<li>Then Pascal cd&#8217;ed to another project : eclipse webtools xml; he located the parent project and launched a pom.xml : to show how easy it is for a newcomer (since he did not know this project) to build a tycho based project : just run &laquo;&nbsp;mvn clean install&nbsp;&raquo; and you&#8217;re done : perfect for getting new contributors to join (no more &laquo;&nbsp;it does not work on my desktop&nbsp;&raquo; whining anymore.)</li>
<li>Adding more steps to the build; Pascal was able to demo Tycho executing the maven findbugs plugin during his build; just adding the maven plugin configuration step in the pom.xml</li>
<li>Moving on, Pascal showed us the integration of the Egit Tycho build in Hudson, with findbugs report</li>
</ul>
<h2>Questions :</h2>
<ul>
<li>is it using JDT compiler ? yes</li>
<li>can i exclude plugins or features from a build ? tycho does not checkout your sources; you can use hudson for that (no maps to define what is getting downloaded)</li>
<li>no possibility to build against different JDT versions; code coverage is not provided yet : Igor, Jan and Pascal answered that the API is opened and even though tycho is production ready; some aspects are not yet covered; but anybody can contribute to it to cover more particular aspects.</li>
<li>Releasing the p2 repository built by Tycho to Nexus is not available now : to publish p2 repos to Nexus Pro, Sonatype sends a zip file to Nexus that explodes and exposes it; during the year, some hooks will be added to do a better integration between p2 repos built with tycho and Nexus Pro.</li>
</ul>
<p>Coffee break : Pascal is announcing a book about tycho is coming soon (Yai!).<a href="http://blog.dahanne.net/wp-content/uploads/IMG_9605.jpg"><img class="alignnone size-medium wp-image-423" title="Pacal, Jan and Igor on Tycho at EclipseCon 2011" src="http://blog.dahanne.net/wp-content/uploads/IMG_9605-300x225.jpg" alt="" width="300" height="225" /></a></p>
<h4>The tutorial</h4>
<ul>
<li>Unzip the archive, backup your current .m2 settings folder; and create a new one with the given settings.xml present : the idea of those steps is to do everything offline, using settings that only consider local artifacts</li>
<li>Start the provided nexus : /var/tmp/eclipsecon2011/nexus/bin/jsw/linux-x86-64/nexus start</li>
<li>Access nexus pro (trial version) <a href="http://localhost:8081/nexus/">http://localhost:8081/nexus/</a> (admin/admin123)</li>
<li>unzip a custom built eclipse : unzip eclipsecon2011.tycho.tutorial.ide-linux.gtk.x86_64.zip</li>
<li>create a new rcp app; add to it the right pom.xml, and &laquo;&nbsp;mvn clean install &laquo;&nbsp;it from eclipse, using m2eclipse provided (and do not forget to use a good eclipse.ini because the permgenspace error popped in my face several times !); then we added a test (using a fragment), a feature, a repository and finally a product</li>
<li>Igor then added the build to Hudson : it built fast !</li>
</ul>
<h4>Lessons learned</h4>
<ul>
<li>stop using a site.xml; use a category.xml to define an eclipse-repository</li>
<li>talking to Jan and Pascal, integration testing is not totally obvious with Tycho; I could first create a product, and run those integration tests against a built product;  instead of launching integration tests during a normal build phase; anyway from their experiences, integration testing is not that mandatory for your projects; focus more on normal unit testing first</li>
<li>before defining a product, launch it a first time, and base your product definition on this launch configuration</li>
<li>in a UI based  product, add org.eclipse.rcp feature; so that you will be able to build your product for multiple platforms (this whole native library stuff, swt; actually on linux x64 I did not need to add this feature to make my product work)</li>
<li>Define aggregator : instead of putting all your modules in the parent pom, you can create an aggregator pom which will define your modules; so that your parent is free of modules dependencies (can be built alone); speaking with Igor, there is no &laquo;&nbsp;truth&nbsp;&raquo;about maven tycho layouts; actually m2eclipse supports nested projects in</li>
<li>Tycho 0.11 will be out when it is ready; ie the product is P2 updatable without hooks</li>
<li>Igor clearly recommends not using the -tycho.targetPlatfrom option; it just loads the jars in a basic way; if anything bad happens, impossible to debug</li>
<li>Nexus professional will add support for hosting custom P2 repos (containing your stuff; it will allow you tycho build to publish the built p2 repo to nexus) throughout the year &#8211;&gt; I can&#8217;t wait for this killer feature!</li>
</ul>
<p>Great presentation &amp; tutorial ! Kudos to Pascal, Jan, and Igor for sharing their knowledge and their patience during the tutorial !</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.dahanne.net/2011/03/21/tycho-presentation-and-tutorial-at-eclipsecon-2011/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>ReGalAndroid : the work behind the scenes</title>
		<link>http://blog.dahanne.net/2011/03/18/regalandroid-the-work-behind-the-scenes/</link>
		<comments>http://blog.dahanne.net/2011/03/18/regalandroid-the-work-behind-the-scenes/#comments</comments>
		<pubDate>Fri, 18 Mar 2011 03:05:58 +0000</pubDate>
		<dc:creator>anthony.dahanne</dc:creator>
				<category><![CDATA[android]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[open source]]></category>

		<guid isPermaLink="false">http://blog.dahanne.net/?p=410</guid>
		<description><![CDATA[<p>On Tuesday 21st of December 2010, I officially launched ReGalAndroid, the follow up of G2Android, aiming at providing G3 and Piwigo support.</p> <p>This article explains why I decided to create a new project, and also what I did differently for this new Android app.</p> Why creating a new project ? <p>First of all, the name [...]]]></description>
			<content:encoded><![CDATA[<p>On Tuesday 21st of December 2010, I officially launched <a href="http://code.google.com/p/regalandroid/">ReGalAndroid</a>, the follow up of <a href="http://code.google.com/p/g2android/">G2Android</a>, aiming at providing <a href="http://gallery.menalto.com/gallery_3.0.1_released">G3</a> and <a href="http://piwigo.org/">Piwigo</a> support.</p>
<p>This article explains why I decided to create a new project, and also what I did differently for this new Android app.</p>
<h3>Why creating a new project ?</h3>
<p>First of all, the name of the app (g2android) did not reflect what I wanted it to be: I wanted it not to be specific to a gallery type (G2) but also compatible with G3 and Piwigo.<br />
In the android world, an app is defined by its package name; since I wanted to change from net.dahanne.android.g2android to the new name net.dahanne.android.regalandroid I had to create a new app.<br />
Sure, I could have keep on using the old package name, but it did not make sense, and also I wanted to start refactoring the app modularizing it.</p>
<h3>Modularizing an Android app, using maven-android-plugin</h3>
<p>In G2Android, one of the things that frustrated me most was the way it  was built : it had dependencies on libraries (jars) not part of the  android runtime. So I had to include them in a lib directory; adding  them to the classpath so that the Android Developer tools knew that  G2Android needed them.<br />
Another problem was the modularity of the application : the Gallery2  client API code was mixed with the Android UI code; it could become a  nightmare for testing, as for plain Junit test cases, I had to remove  the android.jar lib from my classpath (and Android integration testing  was not an option as it takes really too long to launch; and does not  make sense to test an HTTP client api&#8230;)<br />
Starting ReGalAndroid, the first thing I did was modularizing the  application :</p>
<ul>
<li>one standard jar maven project for the commons classes (Pictures,  Albums, etc..) with its regular Junit tests</li>
</ul>
<ul>
<li>one standard jar maven project for each gallery client java api (one  for G2 extracted from g2android, and 2 new ones, one for G3 from  scratch, and one for Piwigo extracted from Jiwigo, an existing Java  Swing client for Piwigo) with their regular Junit tests</li>
</ul>
<ul>
<li>one android maven project with only android related classes, this project heavily depends on the common module and the 3 gallery implementations; this has been possible thanks to the <a href="http://code.google.com/p/maven-android-plugin/">maven android plugin</a></li>
</ul>
<p>To ease the process inside Eclipse, you can use <a href="http://code.google.com/a/eclipselabs.org/p/m2eclipse-android-integration/">Maven Integration for Android Development Tools</a> , it will allow you to launch your Android application from the IDE, just the same as before.</p>
<p>This way, I am now able to test the remote API implementations independently of the main Android app; and also if someone wants to reuse those implementations for any other Java projects, he can just check out those plain java projects.</p>
<h3>Logging an android app using slf4j-android</h3>
<p>If your Android application depends on plain java projects; those projects certainly do not use Android logging framework.</p>
<p>So if you want to log all your modules in your android app, you can use <a href="http://www.slf4j.org/">slf4j</a> : this is meta API where you can choose at compile time which logging API you will use.</p>
<p>For example, in all the logged classes of ReGalAndroid, I&#8217;m depending on org.slf4j.Logger and org.slf4j.LoggerFactory , even in the Android module.</p>
<p>But in my maven dependencies; I tell my android module to depend on slf4j-android :</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;groupid<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>org.slf4j<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/groupid<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;artifactid<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>slf4j-android<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/artifactid<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>1.6.1-RC1<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/version<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;type<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>jar<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/type<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;scope<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>compile<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/scope<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/dependency<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>That way, each call to LoggerFactory.getLogger(My.class)  in any of my modules will be wrapped to the android.util.log APIs</p>
<p>Cool thing is, if anyone wants to use any of the remote gallery implementations (G2, G3 or Piwigo client) in its Java app, he will be able to use Log4J or logback, or any other slf4j bridge he wants !</p>
<h3>Moving from Google code to GitHub for code hosting</h3>
<p>I&#8217;m quite satisfied with Google Code hosting; in fact I still use it as a wiki and a bug tracker; the truth, I wanted to become familiar with Git, to test its benefits.</p>
<p>As I was not starting from scratch, I wanted to be able to keep the history of my project</p>
<p>There is an easy way to do so in GitHub : create a new project, and then select &#8216;Importing a Subversion repo&#8217;; but unfortunately, it did not keep track of all my tags; so I chose to go with the manual way.</p>
<h4>Export google code svn repo to a local git repo</h4>
<p>I use this utility called svn2git, I had to check out from GitHub : <a href="http://github.com/nirvdrum/svn2git">svn2git</a></p>
<p>It is written in Ruby, so you have to make sure you have ruby and rubygems installed.</p>
<p>Then, according to your gems directory, you can run it :</p>
<p>/var/lib/gems/1.8/bin/svn2git https://g2android.googlecode.com/svn/  &#8211;verbose</p>
<p>All the svn tags are imported as git tags (git tag to check all the tags are there) but the authors are not imported (&laquo;&nbsp;(no author) author not found in authors.txt)</p>
<p>To manually change the authors name, I found the solution reading <a href="http://stackoverflow.com/questions/750172/how-do-i-change-the-author-of-a-commit-in-git">this post</a>.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">git</span> filter-branch <span style="color: #660033;">-f</span> <span style="color: #660033;">--env-filter</span> <span style="color: #ff0000;">&quot;GIT_AUTHOR_NAME='Newname';  GIT_AUTHOR_EMAIL='newemail'; GIT_COMMITER_NAME='Newname';  GIT_COMMITTER_EMAIL='newemail';&quot;</span> HEAD <span style="color: #000000; font-weight: bold;">&amp;</span>lt;<span style="color: #000000; font-weight: bold;">/</span>code<span style="color: #000000; font-weight: bold;">&amp;</span>gt;</pre></div></div>

<p>From now on, you have a local git repo with all your code  from your SVN (including the tags !) in a local git repo; let&#8217;s share this one !</p>
<p>First create a new repo on github (using the web interface), then set your local repo as the origin :</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">git</span> remote add origin <span style="color: #c20cb9; font-weight: bold;">git</span><span style="color: #000000; font-weight: bold;">@</span>github.com:anthonydahanne<span style="color: #000000; font-weight: bold;">/</span>ReGalAndroid.git</pre></div></div>

<p>Finally,<a href="http://help.github.com/remotes/"> sync the local and remote , including the tags of the master branch</a> :</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">git</span> push origin master <span style="color: #660033;">--tags</span></pre></div></div>

<p>And youŕe done migrating from Google code SVN to GitHub !</p>
<h3>Migrating your users from a previous android app to a new one</h3>
<p>The problem when you&#8217;re creating a new android application to replace a previous one, is that the users having the old app installed on their phone will not be notified of the availability of the new one, since the package name of your new application (referenced in your AndroidManifest.xml file) is different :</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;manifest</span> <span style="color: #000066;">xmlns:android</span>=<span style="color: #ff0000;">&quot;http://schemas.android.com/apk/res/android&quot;</span></span>
<span style="color: #009900;"><span style="color: #000066;">package</span>=<span style="color: #ff0000;">&quot;net.dahanne.android.g2android&quot;</span> <span style="color: #000066;">android:versionCode</span>=<span style="color: #ff0000;">&quot;15&quot;</span> <span style="color: #000066;">android:versionName</span>=<span style="color: #ff0000;">&quot;1.6.3&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/manifest<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;manifest</span> <span style="color: #000066;">xmlns:android</span>=<span style="color: #ff0000;">&quot;http://schemas.android.com/apk/res/android&quot;</span></span>
<span style="color: #009900;"><span style="color: #000066;">package</span>=<span style="color: #ff0000;">&quot;net.dahanne.android.regalandroid&quot;</span> <span style="color: #000066;">android:versionCode</span>=<span style="color: #ff0000;">&quot;2&quot;</span> <span style="color: #000066;">android:versionName</span>=<span style="color: #ff0000;">&quot;1.0.1&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/manifest<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>Then the market you&#8217;re using (let&#8217;s say Android Market) is not aware of your new application replacing the previous one.</p>
<p>For the particular case of the migration from G2Android to ReGalAndroid, I first, during a month, advertised the new app on Twitter, and on the dedicated G2, G3 and Piwigo forums and websites; so that I could have some early adopters.</p>
<p>Then, in a second step, to accelerate the migration, I updated G2Android, with a new activity, launched by default on startup to tell the user that the application is not maintained anymore and that he should tap on the button to download the new application.<br />
<a href="http://code.google.com/p/g2android/source/browse/trunk/g2android/src/net/dahanne/android/g2android/activity/FirstTime.java">Here is the source code to redirect users from the old android app to the new one</a></p>
<p>At the time of writing this blog post, here are the statistics reported by Android market about both apps :<br />
<a href="http://blog.dahanne.net/wp-content/uploads/android_market_17_03_2011.png"><img class="alignnone size-medium wp-image-416" title="android_market_17_03_2011" src="http://blog.dahanne.net/wp-content/uploads/android_market_17_03_2011-300x47.png" alt="" width="300" height="47" /></a><br />
It means that the migration is quite slow, since many users still have the old application installed on their phones; I may remove the old app from the market in the next few months to make sure they do not use it anymore (please note that  <a href="http://code.google.com/p/regalandroid/downloads/list">ReGalAndroid is also available via other markets and also via direct download</a>)</p>
<h3>The final words</h3>
<p>The application is open source and if I receive many issues and functional requirements via the <a href="http://code.google.com/p/regalandroid/issues/list">ReGalAndroid bug tracker</a> (and I thank the users for that, it clearly influences the path the application is taking) I would love to see new contributors and committers add some code <a href="http://github.com/anthonydahanne/ReGalAndroid">(see the ReGalAndroid github repository)</a>; because this is before all what makes the app <img src='http://blog.dahanne.net/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.dahanne.net/2011/03/18/regalandroid-the-work-behind-the-scenes/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Hosting a new maven project on Github, g3-java-client, a Gallery3 remote client library</title>
		<link>http://blog.dahanne.net/2010/09/20/hosting-a-new-maven-project-on-github-g3-java-client-a-gallery3-remote-client-library/</link>
		<comments>http://blog.dahanne.net/2010/09/20/hosting-a-new-maven-project-on-github-g3-java-client-a-gallery3-remote-client-library/#comments</comments>
		<pubDate>Mon, 20 Sep 2010 04:13:58 +0000</pubDate>
		<dc:creator>anthony.dahanne</dc:creator>
				<category><![CDATA[android]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[outils]]></category>

		<guid isPermaLink="false">http://blog.dahanne.net/?p=396</guid>
		<description><![CDATA[<p>I finally started a java library to implement Gallery3 REST remote API; g3-java-client (the name is not really original huh ?!)</p> <p>Here are the steps I followed to create this project.</p> The technical choices <p>Creating this project, I wanted a lightweight Java library, easily embeddable in an Android application  (G2Android not to name it, a [...]]]></description>
			<content:encoded><![CDATA[<p>I finally started a java library to implement <a href="http://codex.gallery2.org/Gallery3:API:REST">Gallery3 REST remote API</a>; <a href="http://github.com/anthonydahanne/g3-java-client">g3-java-client</a> (the name is not really original huh ?!)</p>
<p>Here are the steps I followed to create this project.</p>
<h3>The technical choices</h3>
<p>Creating this project, I wanted a lightweight Java library, easily embeddable in an Android application  (<a href="http://code.google.com/p/g2android/">G2Android not to name it, a Gallery2 client for Android</a>).</p>
<p>So I carefully designed my dependencies, in order to leverage Android already included libraries, such as Apache Http Client, org.json packages (by the way I initially wanted to use the jersey REST client API, but&#8230; I wanted to stay as close as possible to the Android platform&#8230;)</p>
<p>Finally, I&#8217;m developing this library using <a href="http://en.wikipedia.org/wiki/Test-driven_development">TDD</a>, and <a href="http://maven.apache.org/">Maven as a CI tool</a> :  I want a really reliable library, for 2 reasons : because it is motivating to create quality code, and also it is really painful to test an android application (you have to start an emulator or AVD and deploy the binary each time you launch a test, and each of these steps can take time) .</p>
<h3>The licensing</h3>
<p>I chose GPL v3 to make sure my work remains open source and not used in any commercial projects.</p>
<p>I&#8217;m using <a href="http://code.google.com/p/maven-license-plugin/wiki/HowTo">maven-license-plugin</a> to add the license to the source files.</p>
<h3>The hosting</h3>
<p>I chose <a href="http://github.com/">Github</a>, mainly because I wanted to get familiar with git : I have heard so many people happy using Git instead of SVN,  and I also wanted to be able to switch easily from trunk to another branch&#8230; sounded appealing to me !</p>
<p>To tag the sources, I decided to follow<a href="http://ulrichinaction.blogspot.com/2010/08/releaser-avec-maven-sur-github.html"> Ulrich&#8217;s steps using mvn-release-plugin to tag every new release</a> (in French, <a href="http://www.sonatype.com/people/2009/09/maven-tips-and-tricks-using-github/">but you can follow this link to have an equivalent article in English</a>)</p>
<p>And to host the binaries, <a href="http://cemerick.com/2010/08/24/hosting-maven-repos-on-github/">I created a maven repo out of  a new Github project following Chas&#8217;tutorial</a>; sure I could have asked <a href="https://docs.sonatype.org/display/Repository/Sonatype+OSS+Maven+Repository+Usage+Guide">to host my project on Sonatype&#8217;s Nexus for Open Source Software</a>, but as the project is actually really young, I prefer to use <a href="http://github.com/anthonydahanne/m2repo">my own repo</a>; I guess later on I&#8217;ll switch to this better solution.</p>
<h3>The commands used</h3>
<p>If I had to initialize the workspace from another computer, I would type the following commands :</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">mkdir</span> g3-java-client
<span style="color: #c20cb9; font-weight: bold;">git</span> clone <span style="color: #c20cb9; font-weight: bold;">git</span><span style="color: #000000; font-weight: bold;">@</span>github.com:anthonydahanne<span style="color: #000000; font-weight: bold;">/</span>g3-java-client.git
<span style="color: #7a0874; font-weight: bold;">cd</span> g3-java-client<span style="color: #000000; font-weight: bold;">/</span>
<span style="color: #666666; font-style: italic;">#to make sure everything (compilation, testing) is ok</span>
mvn clean <span style="color: #c20cb9; font-weight: bold;">install</span>
<span style="color: #666666; font-style: italic;">#to add the license header to the source files</span>
mvn license:check
mvn license:format
<span style="color: #666666; font-style: italic;">#to commit the changes to github</span>
<span style="color: #c20cb9; font-weight: bold;">git</span> commit <span style="color: #660033;">-a</span> <span style="color: #660033;">-m</span> <span style="color: #ff0000;">'commit message'</span>
<span style="color: #c20cb9; font-weight: bold;">git</span> push origin master
<span style="color: #666666; font-style: italic;">#to release a new version  (be careful there is no file named release.properties at the root of the project)</span>
mvn release:prepare</pre></div></div>

<p>We just added the license info, committed the snapshot version , committed the stable version and also created a new branch (mvn release:prepare)</p>
<p>Now, we can deploy it to a maven repo</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#to deploy the current version to a repository on my local file system :</span>
mvn <span style="color: #660033;">-DaltDeploymentRepository</span>=snapshot-repo::default::<span style="color: #c20cb9; font-weight: bold;">file</span>:..<span style="color: #000000; font-weight: bold;">/</span>..<span style="color: #000000; font-weight: bold;">/</span>m2repo<span style="color: #000000; font-weight: bold;">/</span>snapshots clean deploy
<span style="color: #666666; font-style: italic;">#to commit this repo to github (I created this Github repo to serve as a maven repo http://github.com/anthonydahanne/m2repo)</span>
<span style="color: #7a0874; font-weight: bold;">cd</span> ..<span style="color: #000000; font-weight: bold;">/</span>..<span style="color: #000000; font-weight: bold;">/</span>m2repo<span style="color: #000000; font-weight: bold;">/</span>snapshots
<span style="color: #c20cb9; font-weight: bold;">git</span> commit <span style="color: #660033;">-a</span> <span style="color: #660033;">-m</span> <span style="color: #ff0000;">'new snapshot for g3-java-client'</span>
<span style="color: #c20cb9; font-weight: bold;">git</span> push origin master</pre></div></div>

<p>Pretty clear and easy right ? (except the deploy phase&#8230;) all of this thanks to Maven and my <a href="http://github.com/anthonydahanne/g3-java-client/blob/master/pom.xml">pom configuration</a>.</p>
<h3>What&#8217;s next ?</h3>
<p>First, finish implementing all the Gallery3 REST remote API commands; and then, create a new android project (G3Android ?!) to consume this library; using &#8230; <a href="http://code.google.com/p/maven-android-plugin/">maven-android-plugin</a> of course !</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.dahanne.net/2010/09/20/hosting-a-new-maven-project-on-github-g3-java-client-a-gallery3-remote-client-library/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Asynchronous Tasks with Android</title>
		<link>http://blog.dahanne.net/2010/09/02/asynchronous-tasks-android/</link>
		<comments>http://blog.dahanne.net/2010/09/02/asynchronous-tasks-android/#comments</comments>
		<pubDate>Thu, 02 Sep 2010 02:35:12 +0000</pubDate>
		<dc:creator>anthony.dahanne</dc:creator>
				<category><![CDATA[android]]></category>
		<category><![CDATA[conferences]]></category>
		<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://blog.dahanne.net/?p=391</guid>
		<description><![CDATA[<p>Tonight I gave a presentation at Android Montreal about the AsyncTasks API, for the Android platform. Although the main content was &#171;&#160;said&#160;&#187; during the presentation, you can download the support :</p> Asynchronous Tasks with Android (OpenDocument format) Asynchronous Tasks with Android (PowerPoint format) Asynchronous Tasks with Android (PDF format) <p>or you can read it, Asynchronous [...]]]></description>
			<content:encoded><![CDATA[<p>Tonight I gave a presentation at <a href="http://www.android-montreal.com/">Android Montreal</a> about the AsyncTasks API, for the Android platform.<br />
Although the main content was &laquo;&nbsp;said&nbsp;&raquo; during the presentation, you can download the support :</p>
<ul>
<li><a href="http://blog.dahanne.net/wp-content/uploads/asynctasks.odp">Asynchronous Tasks with Android (OpenDocument format)</a></li>
<li><a href="http://blog.dahanne.net/wp-content/uploads/asynctasks.ppt">Asynchronous Tasks with Android (PowerPoint format)</a></li>
<li><a href="http://blog.dahanne.net/wp-content/uploads/asynctasks.pdf">Asynchronous Tasks with Android (PDF format)</a></li>
</ul>
<p>or you can read it, <a href="http://www.slideshare.net/anthonydahanne/asynctasks">Asynchronous Tasks with Android on slideshare</a>.</p>
<p>If you want to compare the different ways to deal with multi threading on the android platform, <a href="http://github.com/anthonydahanne/asynctasksdemo">you can also have a look at the project I created on Github, AsyncTasksDemo</a>.<br />
Also, you can have a look at the source code of <a href="http://code.google.com/p/g2android/">G2Android</a>, in this application I use a lot of AsyncTasks to be able to run worker threads fetching remote content over HTTP (<a href="http://code.google.com/p/g2android/source/browse/trunk/g2android/src/net/dahanne/android/g2android/tasks/AddPhotosTask.java">you can particularly have a look at AddPhotosTask</a>)<br />
Many thanks to the Android Montreal volunteers for hosting my presentation! It&#8217;s a really nice event with bright developers !</p>
<h3>References :</h3>
<p>if you&#8217;re interested in the AsyncTask API, you MUST read those blog posts from Android developers :</p>
<ul>
<li><a href="http://android-developers.blogspot.com/2009/05/painless-threading.html">Painless threading</a>, by Romain Guy</li>
<li><a href="http://android-developers.blogspot.com/2010/07/multithreading-for-performance.html">Multithreading For Performance</a>, by Gilles Debunne</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.dahanne.net/2010/09/02/asynchronous-tasks-android/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>G2Android 1.5.0 is available : major release !</title>
		<link>http://blog.dahanne.net/2010/07/20/g2android-1-5-0-is-available-major-release/</link>
		<comments>http://blog.dahanne.net/2010/07/20/g2android-1-5-0-is-available-major-release/#comments</comments>
		<pubDate>Tue, 20 Jul 2010 13:09:29 +0000</pubDate>
		<dc:creator>anthony.dahanne</dc:creator>
				<category><![CDATA[android]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[open source]]></category>

		<guid isPermaLink="false">http://blog.dahanne.net/?p=368</guid>
		<description><![CDATA[<p>Finally ! During a long period of calm, I finally released a new version (with new features) of the Android client for remote galleries Gallery2 (your photos on your website), G2Android. If you have a look at the G2Android project homepage, you will see that the following issues (bug and enhancements) have been closed : [...]]]></description>
			<content:encoded><![CDATA[<p>Finally !<br />
During a long period of calm, I finally released a new version (with new features) of the Android client for remote galleries Gallery2 (your photos on your website), G2Android.<br />
If you have a look at the <a href="http://code.google.com/p/g2android/"> G2Android project homepage</a>, you will see that the following issues (bug and enhancements) have been closed :<br />
Version 1.5.0, 19th of July 2010 Major release</p>
<ul>
<li>issue #33  Enable uploaded photo title modification</li>
<li>issue #41  Malformed Gallery 2 URL leads to G2Android forced close</li>
<li>issue #37  Uploaded photo looses .jpg file extension</li>
<li>issue #42  Feature Suggestion: Provide automatic login when started</li>
<li> issue #20  Share via camera app?</li>
<li>issue #15  Enhancement: Add multiple photo uploading </li>
</ul>
<p>The major new feature is clearly the &laquo;&nbsp;add photo to gallery&nbsp;&raquo; feature : I created a new Activity, <a href="http://code.google.com/p/g2android/source/browse/trunk/g2android/src/net/dahanne/android/g2android/activity/UploadPhoto.java">UploadPhoto</a> , which can be called from 2 external intents : </p>
<p><a href="http://code.google.com/p/g2android/source/browse/trunk/g2android/AndroidManifest.xml">AndroidManifest.xml </a></p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"> <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;activity</span> <span style="color: #000066;">android:name</span>=<span style="color: #ff0000;">&quot;.activity.UploadPhoto&quot;</span> <span style="color: #000066;">android:label</span>=<span style="color: #ff0000;">&quot;@string/upload_photo_title&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;</span></span>
                        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;intent</span> -filter<span style="color: #000000; font-weight: bold;">&gt;</span></span>
                                        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;action</span> <span style="color: #000066;">android:name</span>=<span style="color: #ff0000;">&quot;android.intent.action.SEND&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
                                        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;action</span> <span style="color: #000066;">android:name</span>=<span style="color: #ff0000;">&quot;android.intent.action.SEND_MULTIPLE&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
                                        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;category</span> <span style="color: #000066;">android:name</span>=<span style="color: #ff0000;">&quot;android.intent.category.DEFAULT&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
                                        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;data</span> <span style="color: #000066;">android:mimeType</span>=<span style="color: #ff0000;">&quot;image/*&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
                        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/intent<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
 <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/activity<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>So now the user can send a new photo or a batch of photos from another application, the android gallery app for example; the big work was then to decode the URIs of the photos to find the photo file on the phone, and then send it to the gallery; also I had to make sure that the user is still connected to the gallery, if not, he must login again.</p>
<p>Also, the user is now able to take a picture and send it to his gallery, without leaving g2android; this has been done adding the camera permission in the <a href="http://code.google.com/p/g2android/source/browse/trunk/g2android/AndroidManifest.xml">AndroidManifest.xml </a>:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;uses</span> -permission <span style="color: #000066;">android:name</span>=<span style="color: #ff0000;">&quot;android.permission.CAMERA&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;/uses<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>This is the easy part <img src='http://blog.dahanne.net/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /><br />
Then, when your app receive a photo from the Camera, it does not receive an URI pointing to a photo file; nope, you get a Bitmap  object you have transform into a file, to be able to send it to the remote gallery : </p>
<p><a href="http://code.google.com/p/g2android/source/browse/trunk/g2android/src/net/dahanne/android/g2android/activity/UploadPhoto.java">UploadPhoto</a></p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">                                                Bundle extras <span style="color: #339933;">=</span> intent.<span style="color: #006633;">getExtras</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                                                Bitmap bm <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span>
                                                <span style="color: #003399;">Object</span> o <span style="color: #339933;">=</span> extras.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;data&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                                                <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>o <span style="color: #339933;">!=</span> <span style="color: #000066; font-weight: bold;">null</span> <span style="color: #339933;">&amp;&amp;</span> o <span style="color: #000000; font-weight: bold;">instanceof</span> Bitmap<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                                                        bm <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>Bitmap<span style="color: #009900;">&#41;</span> o<span style="color: #339933;">;</span>
                                                        <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
                                                                StringBuilder stringBuilder <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> StringBuilder<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                                                                stringBuilder.<span style="color: #006633;">append</span><span style="color: #009900;">&#40;</span>Settings
                                                                                .<span style="color: #006633;">getG2AndroidPath</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                                                                stringBuilder.<span style="color: #006633;">append</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                                                                StringBuilder stringBuilderFileName <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> StringBuilder<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                                                                stringBuilderFileName.<span style="color: #006633;">append</span><span style="color: #009900;">&#40;</span>fileName<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                                                                stringBuilderFileName
                                                                                .<span style="color: #006633;">append</span><span style="color: #009900;">&#40;</span><span style="color: #003399;">System</span>.<span style="color: #006633;">currentTimeMillis</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                                                                stringBuilderFileName.<span style="color: #006633;">append</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;.jpg&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                                                                stringBuilder.<span style="color: #006633;">append</span><span style="color: #009900;">&#40;</span>stringBuilderFileName<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                                                                imageFromCamera <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">File</span><span style="color: #009900;">&#40;</span>
                                                                                stringBuilder.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                                                                <span style="color: #003399;">FileOutputStream</span> fos <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">FileOutputStream</span><span style="color: #009900;">&#40;</span>
                                                                                imageFromCamera<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                                                                bm.<span style="color: #006633;">compress</span><span style="color: #009900;">&#40;</span>CompressFormat.<span style="color: #006633;">JPEG</span>, <span style="color: #cc66cc;">100</span>, fos<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                                                                fos.<span style="color: #006633;">flush</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                                                                fos.<span style="color: #006633;">close</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
                                                                mImageUri<span style="color: #339933;">=</span>Uri.<span style="color: #006633;">fromFile</span><span style="color: #009900;">&#40;</span>imageFromCamera<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                                                                fileName <span style="color: #339933;">=</span> stringBuilderFileName.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
                                                        <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">FileNotFoundException</span> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                                                                ShowUtils.<span style="color: #006633;">getInstance</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">alertFileProblem</span><span style="color: #009900;">&#40;</span>e.<span style="color: #006633;">getMessage</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>,<span style="color: #000000; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                                                        <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">IOException</span> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                                                                ShowUtils.<span style="color: #006633;">getInstance</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">alertFileProblem</span><span style="color: #009900;">&#40;</span>e.<span style="color: #006633;">getMessage</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>,<span style="color: #000000; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                                                        <span style="color: #009900;">&#125;</span>
&nbsp;
                                                <span style="color: #009900;">&#125;</span></pre></div></div>

<p>I also optimized the application, issue #37 (Uploaded photo looses .jpg file extension) was in fact due to the fact that I re created the photo file before sending it; instead of using a projection of the URI to get its path on the phone :</p>
<p><a href="http://code.google.com/p/g2android/source/browse/trunk/g2android/src/net/dahanne/android/g2android/utils/UriUtils.java">UriUtils</a></p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #003399;">String</span> getFileNameFromUri<span style="color: #009900;">&#40;</span>Uri uri, Activity activity<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> projection <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span> MediaStore.<span style="color: #006633;">Images</span>.<span style="color: #006633;">ImageColumns</span>.<span style="color: #006633;">DISPLAY_NAME</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
                <span style="color: #003399;">String</span> fileName<span style="color: #339933;">=</span><span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span>
                <span style="color: #003399;">Cursor</span> c <span style="color: #339933;">=</span> activity.<span style="color: #006633;">managedQuery</span><span style="color: #009900;">&#40;</span>uri, projection, <span style="color: #000066; font-weight: bold;">null</span>, <span style="color: #000066; font-weight: bold;">null</span>, <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>c <span style="color: #339933;">!=</span> <span style="color: #000066; font-weight: bold;">null</span> <span style="color: #339933;">&amp;&amp;</span> c.<span style="color: #006633;">moveToFirst</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                        fileName <span style="color: #339933;">=</span> c.<span style="color: #006633;">getString</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #009900;">&#125;</span>
                <span style="color: #000000; font-weight: bold;">return</span> fileName<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Also shipping with this new version, <a href="http://goapk.com">Chinese i18n thanks to the chinese android market, GoAPK</a> and also new art from <a href="http://www.gdl3d.com/">Dan</a>, who just posted a comment to the blog proposing to add new art; thanks again to you both ! You make the application richer !</p>
<p>So now, what remains to be done ? well, the compatibility with Gallery3, as the G3 remote API is almost stable now, thanks to the work of Bharat, Tim, and many others; a java implementation is already under work, I will check if I can use it instead of&#8230; re inventing the wheel !<br />
More details to come, for sure !</p>
<p>You can download G2Android from the Android Market, SlideMe, Applibs, etc.. and also from the <a href="http://code.google.com/p/g2android/"> G2Android project homepage</a><br />
.<br />
Enjoy this app as much as I enjoy working on it, and if you like it, don&#8217;t forget to flattr me <img src='http://blog.dahanne.net/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />  !</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.dahanne.net/2010/07/20/g2android-1-5-0-is-available-major-release/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Debugging any Java Application</title>
		<link>http://blog.dahanne.net/2010/06/03/debugging-any-java-application/</link>
		<comments>http://blog.dahanne.net/2010/06/03/debugging-any-java-application/#comments</comments>
		<pubDate>Thu, 03 Jun 2010 18:18:47 +0000</pubDate>
		<dc:creator>anthony.dahanne</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[outils]]></category>

		<guid isPermaLink="false">http://blog.dahanne.net/?p=351</guid>
		<description><![CDATA[<p>As long as you&#8217;re using a java application (ie an application calling your JVM), you can enable the debug mode with these parameters :</p> <p>-Xdebug -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=y</p> <p>So for example, if you want to debug an ant launch (launched via &#171;&#160;ant -f myBuild.xml&#160;&#187; for example), you simply have to set ANT_OPTS; on windows :</p> <p>set ANT_OPTS=-Xdebug [...]]]></description>
			<content:encoded><![CDATA[<p>As long as you&#8217;re using a java application (ie an application calling your JVM), you can enable the debug mode with these parameters :</p>
<p><code>-Xdebug -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=y</code></p>
<p>So for example, if you want to debug an ant launch (launched via &laquo;&nbsp;ant -f myBuild.xml&nbsp;&raquo; for example), you simply have to set ANT_OPTS; on windows :</p>
<p><code>set ANT_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=y</code></p>
<p>Another example, with JBoss :</p>
<p><code>set JAVA_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=y</code></p>
<p>and then you can debug your launch with Eclipse, for example, creating a new debug configuration (remote java application on port 8787) !<br />
Option : you can choose whether or not the application should wait for your debugger setting suspend to y or n.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.dahanne.net/2010/06/03/debugging-any-java-application/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Analyse de trames HTTP : les outils</title>
		<link>http://blog.dahanne.net/2009/12/10/analyse-de-trames-http-les-outils/</link>
		<comments>http://blog.dahanne.net/2009/12/10/analyse-de-trames-http-les-outils/#comments</comments>
		<pubDate>Thu, 10 Dec 2009 09:31:01 +0000</pubDate>
		<dc:creator>anthony.dahanne</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[outils]]></category>
		<category><![CDATA[proxy]]></category>

		<guid isPermaLink="false">http://blog.dahanne.net/?p=252</guid>
		<description><![CDATA[<p>Régulièrement, je me trouve face au dilemme suivant :  &#171;&#160;Mais qu&#8217;est ce que mon application a bien pu envoyer au serveur ?&#160;&#187; Il existe des outils pour répondre à cette question , et voici ma sélection :</p> Wireshark (anciennement ethereal) / Linux Cet outil, c&#8217;est le couteau suisse de l&#8217;analyse réseau; et pas simplement HTTP [...]]]></description>
			<content:encoded><![CDATA[<p>Régulièrement, je me trouve face au dilemme suivant :  &laquo;&nbsp;Mais qu&#8217;est ce que mon application a bien pu envoyer au serveur ?&nbsp;&raquo;<br />
Il existe des outils pour répondre à cette question , et voici ma sélection :</p>
<ul>
<li><a href="http://www.wireshark.org/">Wireshark </a>(anciennement ethereal) / Linux<br />
Cet outil, c&#8217;est le couteau suisse de l&#8217;analyse réseau; et pas simplement HTTP : il peut analyser les trames TCP, UDP et tout ce qu&#8217;il y a au dessus (HTTP, FTP, SMTP, etc&#8230;)</li>
<li><a href="http://www.pocketsoap.com/tcptrace/">TCPTrace</a> / Windows<br />
Comme son nom l&#8217;indique, il permet d&#8217;analyser les trames TCP : spécifier un port d&#8217;écoute sur votre machine locale, un port de destination, une hôte de destination, configurer votre client HTTP que vous désirez tester; et le tour est joué : tous vos échanges seront loggés !</li>
<li>l&#8217;origine de TCPTrace, tcptunnelgui, très simple d&#8217;utilisation, <a href="http://www.redstream.nl/2011/04/08/tcptunnelgui-maybe-old-but-still-useful/">bien expliqué par Pascal</a></li>
<li><a href="http://www.rexswain.com/httpview.html">HttpViewer</a> , en ligne<br />
Il ne permet que d&#8217;analyser les trames HTTP, mais son gros avantage c&#8217;est qu&#8217;il n&#8217;y a aucune installation à effectuer, c&#8217;est un outil en ligne !</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.dahanne.net/2009/12/10/analyse-de-trames-http-les-outils/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>G2Android version 1.2.1 : bug fixes</title>
		<link>http://blog.dahanne.net/2009/10/15/g2android-version-1-2-1-bug-fixes/</link>
		<comments>http://blog.dahanne.net/2009/10/15/g2android-version-1-2-1-bug-fixes/#comments</comments>
		<pubDate>Thu, 15 Oct 2009 20:51:09 +0000</pubDate>
		<dc:creator>anthony.dahanne</dc:creator>
				<category><![CDATA[android]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[open source]]></category>

		<guid isPermaLink="false">http://blog.dahanne.net/?p=262</guid>
		<description><![CDATA[<p>You can now download the last G2Android update, version 1.2.1. What&#8217;s new ?</p> No more automatic connection at startup, the user has to push a button to connect to the gallery Galleries with port different than 80 now work I18n : the app now provide new languages, today only english and french are supported, I&#8217;m [...]]]></description>
			<content:encoded><![CDATA[<p>You can now download the last <a title="G2Android download page" href="http://code.google.com/p/g2android/downloads/list">G2Android update, version 1.2.1</a>.<br />
What&#8217;s new ?</p>
<ul>
<li> No more automatic connection at startup, the user has to push a button to connect to the gallery</li>
</ul>
<ul>
<li> Galleries with port different than 80 now work</li>
</ul>
<ul>
<li> I18n : the app now provide new languages, today only <a title="G2Android english strings file" href="http://code.google.com/p/g2android/source/browse/trunk/g2android/res/values/strings.xml">english</a> and <a title="G2Android french strings file" href="http://code.google.com/p/g2android/source/browse/trunk/g2android/res/values-fr/strings.xml">french</a> are supported, I&#8217;m expecting the community to provide new translations</li>
</ul>
<p>That&#8217;s all folks, expect better UIs and possibility to download pictures from the gallery to the phone soon.<br />
Have fun browsing your galleries !</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.dahanne.net/2009/10/15/g2android-version-1-2-1-bug-fixes/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>G2Android version 1.2.0 : photos upload and albums creation !</title>
		<link>http://blog.dahanne.net/2009/08/29/g2android-version-1-2-0-photos-upload-and-albums-creation/</link>
		<comments>http://blog.dahanne.net/2009/08/29/g2android-version-1-2-0-photos-upload-and-albums-creation/#comments</comments>
		<pubDate>Sat, 29 Aug 2009 01:33:12 +0000</pubDate>
		<dc:creator>anthony.dahanne</dc:creator>
				<category><![CDATA[android]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[open source]]></category>

		<guid isPermaLink="false">http://blog.dahanne.net/?p=241</guid>
		<description><![CDATA[<p>I&#8217;m writing this small post just to indicate that the new version of the open source Gallery2 client for the android platform, G2Android, is out !</p> <p>Now, you can still see your albums and pictures, but you can also :</p> upload photos create new albums <p>The ergonomy is not yet perfect, as you may have [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m writing this small post just to indicate that the new version of the open source <a href="http://gallery2.menalto.com">Gallery2</a> client for the android platform, <a href="http://code.google.com/p/g2android/">G2Android</a>, is out !</p>
<p>Now, you can still see your albums and pictures, but you can also :</p>
<ul>
<li>upload photos</li>
<li>create new albums</li>
</ul>
<p>The ergonomy is not yet perfect, as you may have already noticed, even though almost everything is multi threaded (using AsyncTask), meaning the ui won&#8217;t freeze anymore; the next features will probably will allow the user to insert a photo to his gallery from every picture context on the android platform (declaring a &laquo;&nbsp;share image&nbsp;&raquo; intent)</p>
<p>Stay tuned !</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.dahanne.net/2009/08/29/g2android-version-1-2-0-photos-upload-and-albums-creation/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>G2Android : a gallery2 client for the android platform</title>
		<link>http://blog.dahanne.net/2009/08/16/g2android-a-gallery2-client-for-the-android-platform/</link>
		<comments>http://blog.dahanne.net/2009/08/16/g2android-a-gallery2-client-for-the-android-platform/#comments</comments>
		<pubDate>Sun, 16 Aug 2009 14:58:31 +0000</pubDate>
		<dc:creator>anthony.dahanne</dc:creator>
				<category><![CDATA[android]]></category>
		<category><![CDATA[internet]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[open source]]></category>

		<guid isPermaLink="false">http://blog.dahanne.net/?p=225</guid>
		<description><![CDATA[<p>I recently started a new open source project : G2Android, for the android platform, and mainly for 3 reasons :</p> The main reason I Started this project was because there isn&#8217;t yet any gallery2 clients for the android platform and I needed one to access my galleries where I share photos with my family and [...]]]></description>
			<content:encoded><![CDATA[<p>I recently started a new open source project : <a title="G2android : a gallery2 client for Android" href="http://code.google.com/p/g2android">G2Android</a>, for the android platform, and mainly for 3 reasons :</p>
<ul>
<li>The main reason I Started this project was because there isn&#8217;t yet any <a title="Gallery2 project page" href="http://gallery2.menalto.com" target="_blank">gallery2</a> clients for the android platform and I needed one to access my galleries where I share photos with my family and friends</li>
</ul>
<p>Gallery2 is an open source project to easily share your photos with your friends and family : you can install it on Php/MySql enabled server : be it a shared server or dedicates server; Gallery2 is maybe the most popular project in this category ! (I know, Picasa and FlickR exist but&#8230; I&#8217;m not the kind of guy to upload 7 Gb of photos to companies I don&#8217;t know and I don&#8217;t trust&#8230;)</p>
<p>Well, there&#8217;s a client for uploading photos to a gallery2, picpush, but it&#8217;s not open source and it&#8217;s loaded with ads&#8230; And you can&#8217;t browse photos&#8230;</p>
<ul>
<li>I wanted to start a new Android project, to know better this platform !</li>
<li>Iwanted to compete on the <a title="ADC" href="http://code.google.com/android/adc/" target="_blank">ADC (Android Developer Challenge) 2009</a> : given the current features, I&#8217;m not sure I have a chance to win the competition, but, hey, the important is to particpate as we isay !</li>
</ul>
<p>As of version 1.0, G2Android can browse albums and pictures, for more details, you can check out the <a title="G2Android Features" href="http://code.google.com/p/g2android/wiki/SupportedFeatures" target="_blank">Features page of G2Android</a></p>
<p>Version 1.1, which will be out soon, will allow you to browse private galleries, ie gallery2 installations which need a password.</p>
<p>The project is open source, GPL v.2, so you want to join in, feel free to contact me !</p>
<p>Finally, you can download G2Android from the Android Market : just type &laquo;&nbsp;G2Android&nbsp;&raquo; in your search or <a title="G2Android on the Android market" href="market://search?q=pname:net.dahanne.android.g2android">simply click on this link if you&#8217;re browsing this page with an Android device</a> .</p>
<p>You can also <a title="Download G2Android" href="http://code.google.com/p/g2android/downloads/list" target="_blank">download it directly from the G2Android Google code site.</a></p>
<p>Have fun with it, and feel free to <a title="G2Android bug tracker" href="http://code.google.com/p/g2android/issues/list" target="_blank">submit new issues on the bugtracker</a> if you encounter a bug !</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.dahanne.net/2009/08/16/g2android-a-gallery2-client-for-the-android-platform/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Different ways to access HTTP resources from Android</title>
		<link>http://blog.dahanne.net/2009/08/16/how-to-access-http-resources-from-android/</link>
		<comments>http://blog.dahanne.net/2009/08/16/how-to-access-http-resources-from-android/#comments</comments>
		<pubDate>Sun, 16 Aug 2009 14:35:05 +0000</pubDate>
		<dc:creator>anthony.dahanne</dc:creator>
				<category><![CDATA[android]]></category>
		<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://blog.dahanne.net/?p=227</guid>
		<description><![CDATA[<p>In this article, I invite the reader to discover the different methods to access http resources from the Android platform. These methods can be adapted to access web services (using REST) or simply to download files !</p> First Method : getting an input stream given a simple url from Android using HttpURLConnection <p>This method is [...]]]></description>
			<content:encoded><![CDATA[<p>In this article, I invite the reader to discover the different methods to access http resources from the Android platform.<br />
These methods can be adapted to access web services (using REST) or simply to download files !</p>
<h3>First Method : getting an input stream given a simple url from Android using HttpURLConnection</h3>
<p>This method is the most basic one : it allows you, using the basic HttpUrlConnection, ( contained in java.net) to get an InputStream from an Url :</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">InputStream</span> downloadUrl<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> url<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #003399;">HttpURLConnection</span> con <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span>
		<span style="color: #003399;">URL</span> url<span style="color: #339933;">;</span>
		<span style="color: #003399;">InputStream</span> is<span style="color: #339933;">=</span><span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
			url <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">URL</span><span style="color: #009900;">&#40;</span>url<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			con <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">HttpURLConnection</span><span style="color: #009900;">&#41;</span> url.<span style="color: #006633;">openConnection</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			con.<span style="color: #006633;">setReadTimeout</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">10000</span> <span style="color: #666666; font-style: italic;">/* milliseconds */</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			con.<span style="color: #006633;">setConnectTimeout</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">15000</span> <span style="color: #666666; font-style: italic;">/* milliseconds */</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			con.<span style="color: #006633;">setRequestMethod</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;GET&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			con.<span style="color: #006633;">setDoInput</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			con.<span style="color: #006633;">addRequestProperty</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Referer&quot;</span>, <span style="color: #0000ff;">&quot;http://blog.dahanne.net&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #666666; font-style: italic;">// Start the query</span>
			con.<span style="color: #006633;">connect</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			is <span style="color: #339933;">=</span> con.<span style="color: #006633;">getInputStream</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span><span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">IOException</span> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                        <span style="color: #666666; font-style: italic;">//handle the exception !</span>
			e.<span style="color: #006633;">printStackTrace</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #000000; font-weight: bold;">return</span> is<span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #009900;">&#125;</span></pre></div></div>

<p>You can also use the Post method, sending data in the HTTP POST payload :</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">InputStream</span> downloadUrl<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> url<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #003399;">InputStream</span> myInputStream <span style="color: #339933;">=</span><span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span>
		StringBuilder sb <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> StringBuilder<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #666666; font-style: italic;">//adding some data to send along with the request to the server</span>
		sb.<span style="color: #006633;">append</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;name=Anthony&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #003399;">URL</span> url<span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
			url <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">URL</span><span style="color: #009900;">&#40;</span>url<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #003399;">HttpURLConnection</span> conn <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">HttpURLConnection</span><span style="color: #009900;">&#41;</span> url.<span style="color: #006633;">openConnection</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			conn.<span style="color: #006633;">setDoOutput</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			conn.<span style="color: #006633;">setRequestMethod</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;POST&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #003399;">OutputStreamWriter</span> wr <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">OutputStreamWriter</span><span style="color: #009900;">&#40;</span>conn
					.<span style="color: #006633;">getOutputStream</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                        <span style="color: #666666; font-style: italic;">// this is were we're adding post data to the request</span>
                        wr.<span style="color: #006633;">write</span><span style="color: #009900;">&#40;</span>sb.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			wr.<span style="color: #006633;">flush</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			myInputStream <span style="color: #339933;">=</span> conn.<span style="color: #006633;">getInputStream</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			wr.<span style="color: #006633;">close</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">Exception</span> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                        <span style="color: #666666; font-style: italic;">//handle the exception !</span>
			Log.<span style="color: #006633;">d</span><span style="color: #009900;">&#40;</span>TAG,e.<span style="color: #006633;">getMessage</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
                <span style="color: #000000; font-weight: bold;">return</span> myInputStream<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>But there are better ways to achieve that, using Apache HttpClient, included in android.jar (no need to add another jar, it&#8217;s included in android core)</p>
<h3>Second Method : getting an input stream given a simple url from Android using HttpClient</h3>
<p>Why is it a better to do it ? because the simpler, the better ! See by yourself :</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #003399;">InputStream</span> getInputStreamFromUrl<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> url<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #003399;">InputStream</span> content <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
			HttpGet httpGet <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> HttpGet<span style="color: #009900;">&#40;</span>url<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			HttpClient httpclient <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> DefaultHttpClient<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #666666; font-style: italic;">// Execute HTTP Get Request</span>
			HttpResponse response <span style="color: #339933;">=</span> httpclient.<span style="color: #006633;">execute</span><span style="color: #009900;">&#40;</span>httpGet<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			content <span style="color: #339933;">=</span> response.<span style="color: #006633;">getEntity</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getContent</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">Exception</span> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #666666; font-style: italic;">//handle the exception !</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #000000; font-weight: bold;">return</span> content<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>But you maybe wondering if it&#8217;s still easy with HTTP Post method ? You won&#8217;t be deceived !</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #003399;">InputStream</span> getInputStreamFromUrl<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> url<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #003399;">InputStream</span> content <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
          		HttpClient httpclient <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> DefaultHttpClient<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			HttpPost httpPost <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> HttpPost<span style="color: #009900;">&#40;</span>url<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #003399;">List</span> nameValuePairs <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">ArrayList</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                        <span style="color: #666666; font-style: italic;">//this is where you add your data to the post method</span>
                        nameValuePairs.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> BasicNameValuePair<span style="color: #009900;">&#40;</span>
			<span style="color: #0000ff;">&quot;name&quot;</span>, <span style="color: #0000ff;">&quot;anthony&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			httpPost.<span style="color: #006633;">setEntity</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> UrlEncodedFormEntity<span style="color: #009900;">&#40;</span>nameValuePairs<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #666666; font-style: italic;">// Execute HTTP Post Request</span>
			HttpResponse response <span style="color: #339933;">=</span> httpclient.<span style="color: #006633;">execute</span><span style="color: #009900;">&#40;</span>httpPost<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			content <span style="color: #339933;">=</span> response.<span style="color: #006633;">getEntity</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getContent</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		        <span style="color: #000000; font-weight: bold;">return</span> content<span style="color: #339933;">;</span>
	        <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>But what if you want to read a cookie from the response ? And how can you send a cookie back to the server for the next request ?</p>
<h3>Reading / Sending a cookie along with the requests</h3>
<p>Using Apache HttpClient, it&#8217;s easy to retrieve cookies ! Everything is in the headers after all !</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #009900;">&#91;</span>...<span style="color: #009900;">&#93;</span>
Cookie sessionCookie <span style="color: #339933;">=</span><span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span>
HttpResponse response <span style="color: #339933;">=</span> httpclient.<span style="color: #006633;">execute</span><span style="color: #009900;">&#40;</span>httpPost<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
Header<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> allHeaders <span style="color: #339933;">=</span> response.<span style="color: #006633;">getAllHeaders</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
CookieOrigin origin <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> CookieOrigin<span style="color: #009900;">&#40;</span>host, port,path, <span style="color: #000066; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span>Header header <span style="color: #339933;">:</span> allHeaders<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #003399;">List</span> parse <span style="color: #339933;">=</span> cookieSpecBase.<span style="color: #006633;">parse</span><span style="color: #009900;">&#40;</span>header, origin<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span>Cookie cookie <span style="color: #339933;">:</span> parse<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #666666; font-style: italic;">// THE cookie</span>
				<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>cookie.<span style="color: #006633;">getName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">equals</span><span style="color: #009900;">&#40;</span>COOKIE_I_WAS_LOOKING_FOR<span style="color: #009900;">&#41;</span>
						<span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;&amp;</span>amp<span style="color: #339933;">;</span> cookie.<span style="color: #006633;">getValue</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!=</span> <span style="color: #000066; font-weight: bold;">null</span> <span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;&amp;</span>amp<span style="color: #339933;">;</span> cookie.<span style="color: #006633;">getValue</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
					sessionCookie <span style="color: #339933;">=</span> cookie<span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</span>
			<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>To send a cookie along with your request, keep it simple :</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">HttpPost httpPost <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> HttpPost<span style="color: #009900;">&#40;</span>url<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
CookieSpecBase cookieSpecBase <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> BrowserCompatSpec<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003399;">List</span> cookies <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">ArrayList</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
cookies.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span>sessionCookie<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003399;">List</span> cookieHeader <span style="color: #339933;">=</span> cookieSpecBase.<span style="color: #006633;">formatCookies</span><span style="color: #009900;">&#40;</span>cookies<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">// Setting the cookie</span>
httpPost.<span style="color: #006633;">setHeader</span><span style="color: #009900;">&#40;</span>cookieHeader.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>What about the resulting InputStream ? You definitely want to transform it into a String or an Drawable (to set it to an ImageView for example !) don&#8217;t you ?</p>
<h3>Converting the InputStream into a Drawable in Android</h3>
<p>The Drawable class already handles that for you :</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">Drawable d <span style="color: #339933;">=</span> Drawable.<span style="color: #006633;">createFromStream</span><span style="color: #009900;">&#40;</span>myInputStream, <span style="color: #0000ff;">&quot;nameOfMyResource&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<h3>Converting the InputStream into a String in Android</h3>
<p>This is some classic java stuff (don&#8217;t tell about how easier it is in Ruby.. I know <img src='http://blog.dahanne.net/wp-includes/images/smilies/icon_sad.gif' alt=':-(' class='wp-smiley' />  &#8230; but hey ! Java SE7 at the rescue with NIO !!! maybe one day in 2010 ! )</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #003399;">BufferedReader</span> rd <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">BufferedReader</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">InputStreamReader</span><span style="color: #009900;">&#40;</span>myInputStreamToReadIntoAString<span style="color: #009900;">&#41;</span>, <span style="color: #cc66cc;">4096</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003399;">String</span> line<span style="color: #339933;">;</span>
StringBuilder sb <span style="color: #339933;">=</span>  <span style="color: #000000; font-weight: bold;">new</span> StringBuilder<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>line <span style="color: #339933;">=</span> rd.<span style="color: #006633;">readLine</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		sb.<span style="color: #006633;">append</span><span style="color: #009900;">&#40;</span>line<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
rd.<span style="color: #006633;">close</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003399;">String</span> contentOfMyInputStream <span style="color: #339933;">=</span> sb.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
&nbsp;
That<span style="color: #0000ff;">'s it folks ! If you have any other methods to achieve these goals, feel free to share them sending a comment !</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://blog.dahanne.net/2009/08/16/how-to-access-http-resources-from-android/feed/</wfw:commentRss>
		<slash:comments>58</slash:comments>
		</item>
		<item>
		<title>Jboss and java.lang.OutOfMemoryError: PermGen space</title>
		<link>http://blog.dahanne.net/2009/08/12/jboss-and-java-lang-outofmemoryerror-permgen-space/</link>
		<comments>http://blog.dahanne.net/2009/08/12/jboss-and-java-lang-outofmemoryerror-permgen-space/#comments</comments>
		<pubDate>Wed, 12 Aug 2009 15:14:50 +0000</pubDate>
		<dc:creator>anthony.dahanne</dc:creator>
				<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://blog.dahanne.net/?p=212</guid>
		<description><![CDATA[<p>Once again, this infamous exception blew at my face when starting JBoss 4.2.3.GA today ! In fact, JBoss had to deploy 2 wars, one of them being a Web Service deploying war. This exception occurred for one simple reason : the permgenspace is where class properties, such as methods, fields, annotations, and also static variables, [...]]]></description>
			<content:encoded><![CDATA[<p>Once again, this infamous exception blew at my face when starting JBoss 4.2.3.GA today !<br />
In fact, JBoss had to deploy 2 wars, one of them being a Web Service deploying war.<br />
This exception occurred for one simple reason : the permgenspace is where class properties, such as methods, fields, annotations, and also static variables, etc. are stored in the Java VM, but this space has the particularity to not being cleaned by the garbage collector.<br />
So if your webapp uses or creates a lot of classes (I&#8217;m thinking dynamic generations of classes), chances are you met this problem.<br />
Here are some solutions that helped me get rid of this exception :</p>
<ul>
<li>-XX:+CMSPermGenSweepingEnabled : this setting enables garbage collection in the permgenspace</li>
<li>-XX:+CMSClassUnloadingEnabled : allows the garbage collector to remove even classes from the memory</li>
<li><span style="font-size: x-small;">-XX:PermSize=64M<span> </span> -XX:MaxPermSize=128M : raises the amount of memory allocated to the permgenspace</span></li>
</ul>
<p>These options must be included in the JAVA_OPTS part of your Jboss run.bat or run.sh startup file.</p>
<p>Thank you <a href="http://www.linkedin.com/pub/stephane-malbequi/1/512/538" target="_blank">Stephane</a> for giving me the solution !</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.dahanne.net/2009/08/12/jboss-and-java-lang-outofmemoryerror-permgen-space/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Eclipse Galileo 3.5 : problèmes de connexion à travers un proxy&#8230;</title>
		<link>http://blog.dahanne.net/2009/07/01/eclipse-galileo-3-5-problemes_proxy/</link>
		<comments>http://blog.dahanne.net/2009/07/01/eclipse-galileo-3-5-problemes_proxy/#comments</comments>
		<pubDate>Wed, 01 Jul 2009 09:10:17 +0000</pubDate>
		<dc:creator>anthony.dahanne</dc:creator>
				<category><![CDATA[java]]></category>
		<category><![CDATA[open source]]></category>

		<guid isPermaLink="false">http://blog.dahanne.net/?p=175</guid>
		<description><![CDATA[<p>En installant Eclipse Galileo, sur un poste de travail en entreprise (donc utilisant derrière un proxy pour l&#8217;accès à internet) j&#8217;ai rencontré quelques problèmes pour me connecter aux update sites (via Help -&#62; install new software&#8230;). En fait, même en ayant bien régler les coordonnées du proxy dans Window -&#62; Preferences -&#62; general-&#62;network connections , [...]]]></description>
			<content:encoded><![CDATA[<p>En installant Eclipse Galileo, sur un poste de travail en entreprise (donc utilisant derrière un proxy pour l&#8217;accès à internet) j&#8217;ai rencontré quelques problèmes pour me connecter aux update sites (via Help -&gt; install new software&#8230;).<br />
En fait, même en ayant bien régler les coordonnées du proxy dans Window -&gt; Preferences -&gt; general-&gt;network connections , dès que j&#8217;essayais d&#8217;installer des plugins via l&#8217;update manager, j&#8217;avais l&#8217;erreur suivante : (à peu près) :<br />
<code>!ENTRY org.eclipse.core.net 1 0 2009-04-16 18:12:18.427<br />
!MESSAGE System property socksProxyPort is not set but should be .<br />
</code><br />
Pas génial&#8230;<br />
EN fait, le bug est référencé sur cette page :</p>
<p>https://bugs.eclipse.org/bugs/show_bug.cgi?id=281472#c7</p>
<p>et en particulier, le moyen de contournement, à savoir ne pas utiliser Apache HTTPClient pour se connecter au réseau se trouve sur cette page :</p>
<p>http://wiki.eclipse.org/ECF_Filetransfer_Support_for_NTLMv2_Proxies</p>
<p>Il suffit de modifier son eclipse.ini et rajouter les valeurs suivantes :</p>

<div class="wp_syntax"><div class="code"><pre class="ini" style="font-family:monospace;">-Dorg.eclipse.ecf.provider.filetransfer.excludeContributors<span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;">org.eclipse.ecf.provider.filetransfer.httpclient</span>
-Dhttp.proxyPort<span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;">8080</span>
-Dhttp.proxyHost<span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;">myproxy</span>
-Dhttp.proxyUser<span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;">mydomain\myusername</span>
-Dhttp.proxyPassword<span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;">mypassword</span>
-Dhttp.nonProxyHosts<span style="color: #000066; font-weight:bold;">=</span><span style="color: #000066; font-weight:bold;"><span style="color: #660066;">localhost|127.0.0.1</span></span></pre></div></div>

<p>Vous n&#8217;etes pas obligés de rajouter un utilisateur/mot de passe si votre proxy n&#8217;en a pas besoin.<br />
<strong>Attention ! bien placer ces propriétés juste en dessous de -vmargs !</strong><br />
Ainsi, au prochain redémarrage, vous aurez accès aux update sites eclipse à travers votre proxy (malgré 1 message d&#8217;erreur la première fois !)</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.dahanne.net/2009/07/01/eclipse-galileo-3-5-problemes_proxy/feed/</wfw:commentRss>
		<slash:comments>24</slash:comments>
		</item>
		<item>
		<title>Jazoon 09 : third and last day, Thursday 25th of June</title>
		<link>http://blog.dahanne.net/2009/06/25/jazoon-09-third-and-last-day-thursday-25th-of-june/</link>
		<comments>http://blog.dahanne.net/2009/06/25/jazoon-09-third-and-last-day-thursday-25th-of-june/#comments</comments>
		<pubDate>Thu, 25 Jun 2009 20:35:15 +0000</pubDate>
		<dc:creator>anthony.dahanne</dc:creator>
				<category><![CDATA[android]]></category>
		<category><![CDATA[conferences]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[jazoon 09]]></category>

		<guid isPermaLink="false">http://blog.dahanne.net/?p=170</guid>
		<description><![CDATA[<p>Vous pouvez lire cet article en français sur le blog de valtech.</p> The Changing Nature of Enterprise Java Application Development, 9:00 &#8211; 9:45 by Adrian Colyer <p>During his talk, the speaker described the audience the future of a Java platform, because it is actually going to be there for a long time now. He mentioned [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://blog.valtech.fr/wordpress/2009/06/25/jazoon-3eme-et-dernier-jour-jeudi-25-juin/">Vous pouvez lire cet article en français sur le blog de valtech.</a></p>
<h3>The Changing Nature of Enterprise Java Application Development, 9:00 &#8211; 9:45 by Adrian Colyer</h3>
<p>During his talk, the speaker described the audience the future of a Java platform, because it is actually going to be there for a long time now.<br />
He mentioned the dynamic languages compatible with the JVM : Groovy, JRuby, Scala, and Clojure.<br />
He mainly focused on Groovy (which belongs to SpringSource by the way), even if he was not sure if whether JRuby or Groovy would win the &laquo;&nbsp;war of dynamic languages&nbsp;&raquo;.<br />
For the web platform, he mentioned Grails, built on top of Groovy, Rails running on top of Ruby, and Lift built on top of Scala.<br />
He finished his talk introducing OSGi and Spring DM; the future of enterpise is application may be in the cloud : easily to deploy and scale applications are to come.</p>
<h3>The android runtime environment, 10:30 &#8211; 11:20, by Joerg Pleumann</h3>
<p>The speaker first made an introduction to the Android system, as a platform competing windows mobile and palm.<br />
More technically speaking, it is based on a Linux kernel (along with necessary drivers : display, camera, sound, etc&#8230;).<br />
On top of it come the Android Runtime and libraries; the talk is about the Android Runtime and its Dalvik VM.<br />
Dalvik VM : CPU between 250 and 500 MHz, RAM >=64 (equivalent to a 1999 PC), but low power consumption is critical.<br />
The Dalvik VM is really efficient, using explicit registers to keep temporary values: the immediate benefit is the number of lines of the bytecode resulting from the DalvikVM compilation : nearly 30% less than a standard VM compilation.<br />
A dex file (Dalvik Executable) contains several files, and is not compressed.<br />
JNI is ready, a sdk for using JNI is about to come out in the next days; also an Android Debug Bridge is available from the beginning.<br />
The core libraries<br />
dalvik vm specific libraries : dalvik.*<br />
java compatibility libraries : java.* and javax.*<br />
and some apache libraries(mainly for http) : org.apache.*<br />
The core libraries are partly taken from Apache Harmony (a JDK implementation by Apache), partly written from scratch; and some of them have been optimized (using JNI)<br />
The core libraries are mostly compatible to a subset of J2SE 5.0.<br />
JDBC 2.0 is supported, but the SQLite driver is limited., but one can use the alternative in android.database.sqlite which are better integrated.<br />
To conclude with, with Android you can reuse your java knowledge and tools.</p>
<h3>Android Application Model, 11:30 &#8211; 12:20, by Dominik Gruntz</h3>
<p>4 main components :activities, services, content providers and broadcast receivers.<br />
A single class, uses intents to communicate with the other activities; when you launch an activity, you can (or not) expect a result; if this is the case, the method onIntentResult will be called.<br />
You can also define intent filters to describe the intents an activity can handle.<br />
An intent specification is on its way : http://www.openintents.org<br />
An application is packaged using an APK (Android package).<br />
Every activity has a lifecycle containing 4 steps : new, running, paused,  stopped, killed and the corresponding methods (onCreate, onStop etc..)<br />
For each activity a new process (with a single thread) is created.<br />
The Looper.loop() dispathes the actions to a queue.<br />
If an activity does not conume events in 5sec, the system issue a warning message.<br />
A service is running background and can communicate with an activity (in process if it&#8217;s the same application (APK)) or via AIDL.<br />
Finally, a content provider is the only way to share date between  Android applications; it can using SQLite, a file, or a remote storage. </p>
<h3>Scalable Agile Web Development: REST meets JCR meets OSGI, by Michael Marth</h3>
<p>JCR : JSR 270 for accessing content repository : located on a file or database; can be versioned; node ahave read/write group properties, etc&#8230;<br />
Apache Sling is a web framework, on top of REST/Scripting (Ruby, Groovy, etc&#8230;)/OSGi(in this case Apache Felix Container, to switch on/off part of the frameework live)/JCR.<br />
So basically Apache Sling allows the user to create/edit/read/update content in a restful manner (http methods), the data being created is then stored on the JCR repository, organized in a very similar WebUrlFriendly way (and then you can manipulate the data through rest or webdav and so on, thanks to JCR)<br />
The demo was really smooth and interesting !</p>
<h3>The charm of Mockito: Test Spies in action, 14:30 &#8211; 15:20, by Szczepan Faber</h3>
<p>The speaker begins asking who uses JMock : 2 or 3 people among an audience of 60 people, half of the audience using EasyMock.<br />
So let&#8217;s start with EasyMock : coding in TDD a dictionnary, (and its history) depending on a translator : the translator is mocked.<br />
With easymock the speaker keeps it old fadhioned : createMock/expect/replay/assert/verify , (his test extends Assert) and then refactor a bit in the @Before and @After test methods, nothing special here.<br />
Then Mockito : mock/when/assert/verify : it&#8217;s a lighter syntax indeeed!<br />
Szczepan insisted on the fact that usually developers using easymock create replayAll and verifyAll methods called in the @After method; which make Easymok fail when many behaviours are attached.<br />
The speaker uses BDD style template (given/when/then) in eclipse, when creating a test.<br />
Mockito eases the use of a given/when/then syntax when writing a test.<br />
Has good point of failure ?<br />
The failure trace in mockito is linked to the source code and more explicit about the error, it does not whow internal classes exceptions<br />
Mockito or mockito-like for python, flex, javascript, C++; there are mockito extensions<br />
He concluded with : &laquo;&nbsp;Do TDD and write great tests with whatever tools that work for you&nbsp;&raquo;<br />
May the force be with you !</p>
<h3>Eclipse Galileo and JBoss Tools, 16:30 &#8211; 16:50, by Max Andersen</h3>
<p>Galileo (3.5) is a huge release.<br />
Must-sees : Eclipse Memory Analyser (to see which plugin consumes all the memory for example), using jmap<br />
XML and XSL editor is really better.<br />
P2 (eclipse update manager) works for real; you shouldn&#8217;t use dropins anymore (single zip files to unpackage in /plugins and /features), for offline installation plugins providers should suggest copies of the update site, then you may use P2 to explore these files, as if you were online).</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.dahanne.net/2009/06/25/jazoon-09-third-and-last-day-thursday-25th-of-june/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Jazoon 09 : First day, first sessions</title>
		<link>http://blog.dahanne.net/2009/06/23/jazoon-09-first-day-first-sessions/</link>
		<comments>http://blog.dahanne.net/2009/06/23/jazoon-09-first-day-first-sessions/#comments</comments>
		<pubDate>Tue, 23 Jun 2009 08:55:08 +0000</pubDate>
		<dc:creator>anthony.dahanne</dc:creator>
				<category><![CDATA[conferences]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[jazoon 09]]></category>

		<guid isPermaLink="false">http://blog.dahanne.net/?p=157</guid>
		<description><![CDATA[<p>The following sessions were given during Jazoon 09, on Tuesday the 23rd of June 2009, vous pouvez lire la traduction en français sur le blog de Valtech</p> James Gosling keynote : 9:50 to 10:45 <p>First a nice little video from Java One, introducing the history of Java ! Very funny how Java conquered the world [...]]]></description>
			<content:encoded><![CDATA[<p>The following sessions were given during <a href="http://jazoon.com/en/conference/tuesday.html">Jazoon 09, on Tuesday the 23rd of June 2009</a>, <a href="http://blog.valtech.fr/wordpress/2009/06/23/jazoon-09-sessions-du-mardi-23-juin/">vous pouvez lire la traduction en français sur le blog de Valtech</a></p>
<h3>James Gosling keynote : 9:50 to 10:45</h3>
<p>First a nice little video from Java One, introducing the history of Java ! Very funny how Java conquered the world !<br />
Then James Gosling begins his speech.<br />
Today there are more JREs installed than people on earth ! It can be be smart cards, desktops, phones&#8230; 6M Java developers today in the world &#8230; 15M JRE downloads / week.<br />
You can now view Java as &laquo;&nbsp;Learn One, Work everywhere&nbsp;&raquo; because it&#8217;s really spread everywhere now !<br />
James Gosling then describes the brazilian healthcare, where every piece of paper is now on the network : prescriptions, x rays, everything is now on the network (thanks to Java !), ebay, metropolitan networks cards, web apps, games&#8230; Java is everywhere !<br />
But the main thing is not java as the language, but the JVM that now hosts Ruby, Scala, JavaScript, etc&#8230;<br />
James then showed us a bit of java code : a servlet for Java EE6 running on GlashFish v3, changed, saved and instantly shown just refreshing the browser ! No more deployment bottleneck !<br />
He also introduced Netbeans, as the best IDE ! version 6.7 now integrates with project kenai, a sourceforge like (you can check in/out merge your files, etc&#8230; from Netbeans to kenai), also some better maven support.<br />
Java is also used in the real time world, even in a car that James turns into electric : a lincoln (lincvolt.org) which is hybrid, connected to the internet, running java code for measurement and control.<br />
Now down to the performance part :  Java is highly optimized, genrally beats C/C++, GC is a lot faster than malloc/free !<br />
Multithreading is the future of software designing : because the processors speed is not evolving anymore, we&#8217;ve got to think multicore !<br />
Java is also running on cellphones, JSR 248, Mobile Service Architecture aggregates all Java mobile specs.<br />
JDK7 will be modular (see Mark Reinhold&#8217;s blog), dynamic language support will be available too (JSR 292?); waiting for Java 7, there are still Java SE 6 updates : better browser and desktop integration are on their way !<br />
Of course, we got a few slides about JavaFX, which can run on desktops, mobile phones, set top boxes, etc&#8230;<br />
To finish his speech, James reminded us with all the java communities : netbeans.org, java.net, glassfish.org, etc&#8230;</p>
<h3>Java EE 6 11:00 &#8211; 11:50 by Roberto Chinnici from Sun</h3>
<p>Java EE6 was too complicated, so they decided to make it more easy to use, more powerful, and more flexible.<br />
That&#8217;s why they created the profiles, letting the users choose the features they need.<br />
For example the web profile includes everything for the web development, including the EJB 3.1 lite, and bean validation.</p>
<h4>Servlet 3.0</h4>
<p>New annotations @WebServlet, @WebFilter, @WebListener, the possibility to register new web components just adding them to WEB-INF/lib directory, a new async mode using just a single thread for many requests</p>
<h4>JAX-RS 1.1 : RestFul webservices</h4>
<p>This API is there to abstract low level HTTP details : using @GET and @POST (etc..) you can define your retrieval and creation REST operations, JAX-RS translates the XML to the java entities (and back) automatically for you (you can also use JSON)</p>
<h4>Bean Validation 1.0 (JSR-303)</h4>
<p>This API is here to validate fields (text inputs for example)<br />
Seems to be really verbose just to define constraints&#8230; We&#8217;ll see&#8230;</p>
<h4>EJB 3.1</h4>
<p>No intefaces anymore ! One source file per bean.<br />
New timer annotation @Schedule allowing some cron-like scheduling in the container : a great example provided is the case of a cache refreshing ! No more Mbeans called externally with crons, everything can be integrated in the application code !<br />
EJB 3.1 lite can run on Java SE, great for testing and also in a war file !<br />
Oups, we&#8217;re running out of time, the speaker skipped JPA 2.0</p>
<h3>&laquo;&nbsp;Design Patterns&nbsp;&raquo; in Dynamic Languages 12:00 &#8211; 12:50 by <a href="http://www.nealford.com">Neal Ford from ThoughtWorks</a> (nealford.com)</h3>
<p>After comparing mixing dynamic languages with whisky blending, Neal Ford reminded us about the history of Design Patterns : basically for &laquo;&nbsp;making C++ code suck less&nbsp;&raquo; !<br />
But the point is : the design pattern designed in 1994 are not always useful today : for example the iterator is quite complicated, whereas today in dynamic languages, like Ruby a collection.each{[x| puts x} is so much more&#8230; efficient !<br />
Command design pattern is already built in closures !<br />
The same for strategy, template, interpreter (the example showed how easy it is to implement a DSL in Groovy, defining new behaviors in the Integer class), decorator, recorder, adapter<br />
Then Neal described some other desgn pattern for dynamic languages : the null pattern (?. in groovy) and the aridifier pattern.<br />
To conclude with, Neal suggest that we should try the tools provided with the languages we&#8217;re using instead of blindly trying to copy the patterns designed for older, other languages !</p>
<h3>Gradle : A build system for Java 14:00 &#8211; 14:50, by Hans Dockter</h3>
<p>First the speaker reminds us of Ant and Maven.<br />
With Ant, it&#8217;s always been repetitive, with a lot of copy and paste when a new project starts, due to Ant limited domain model (resources, target, properties,)<br />
There is no place for listener in an Ant build&#8230;<br />
A gradle script can import old ant build scripts.<br />
With Gradle, you can call ant tasks, and even implement listeners on your ant task&#8230; An ant task called in a gradle scrip can even be aware of the next task that will be called !<br />
Maven, on its side is a build by convention framework, which has introduced dependency management.<br />
But Maven uses XML, and 25 lines of XML are required to launch a simple build !<br />
Maven uses transitive dependency whereas Gradle is able to skip tasks (which can be handy when a Maven dependency is broken&#8230;)<br />
Gradle aims to be a build language rather than a build framework; because when a framework does not implement a functionality, you spend your time fighting against the framework to make him do something it was not intended to do.<br />
You can define your maven build with a groovy script using gradle.<br />
With gradle, it becomes easy to define usually manual and entreprise specific tasks like release management or deployment.<br />
Grandle can use Apache Ivy or Maven dependencies, it can even deploy a build to a maven repository.<br />
There is also a Gradle Wrapper to start using Gradle without installing it : the Continuous integration machine will download Gradle for you and execute the gradle script (which is a shell script downloading gradle) !<br />
What&#8217;s next? Gradle 1.0 will be out in Autumn.<br />
Q&#038;A :<br />
What open source projects are already using Gradle ?<br />
Grails, but others are to come.</p>
<h3>Next Generation Enterprise Builds: Maven, Mercury, and Tycho (for OSGi builds) by Jason van Zyl from Sonatype</h3>
<h4>Maven 3.0 </h4>
<p>Better integration in IDEs, faster, rewritten artifact resolution system, etc&#8230;<br />
Maven 3.0 is more focused on integration tests, provides a new version of the plugin manager, a queryable lifecycle to make the tools able to predict what&#8217;s going to be done and also able to ask to execute a particular step.<br />
Maven 3.0 uses Mercury : a new repository and transport layer, that can be used with others systems (Ruby gems, Eclipse P2 dependency management)</p>
<h4>M2eclipse</h4>
<p>M2eclipse has also been improved, now m2eclipse won&#8217;t call every maven tasks on a a save action, it will only call the appropriate ones.<br />
The m2eclipse team would like the users to be able to resolve every maven operations from Eclipse,<br />
M2eclipse is now compatible with Flex (out by october 2009).</p>
<h4>Nexus</h4>
<p>Only 5% of the maven users use a repository manager.<br />
Nexus is also for binary sharing inside the enterprise, it a repository manager, it&#8217;s like a source control management, but for binaries !<br />
Nexus main advantage is also the caching system it provides.<br />
Nexus can be queryed through m2eclipse, Nexus API can be used through REST, which makes it very easy to use.</p>
<h4>Hudson</h4>
<p>For its next version, hudson will integrate :d rools workflow integration (with a workflow editor), a rest layer to query hudson, unifying hudson m2eclipse, nexus better maven integration</p>
<h3>Testing Zen 16:00 &#8211; 16:20 by Thomas Mueller, Day</h3>
<p>In this session Thomas gave us the reasons why we should test our code.<br />
Then he continued giving us an example of fuzz testing (data generation to test)<br />
Code coverage (with Emma) to find untested and dead code.<br />
Database testing is often hard : a pain to install&#8230; so you can use a Java SQL Database like HSQL (a good one), H2 (the best, and also the one the speaker is working on ! <img src='http://blog.dahanne.net/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />  ) or Derby (the worse).</p>
<h3>Creating Performance Test Data with benerator, by Volker Bergmann</h3>
<p>Usually performance testers prefer testing with production data, but sometimes it is not possible (for privacy reasons or if the system is new).<br />
In those cases, you have to use a data generator, like Benerator that can create and anonymize data, to DB, file, LDAP,  JCR, etc&#8230;</p>
<p>To finish the day, we had a really nice speech from Neal Ford, about technology predictability, that was real fun !</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.dahanne.net/2009/06/23/jazoon-09-first-day-first-sessions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Soumission du projet WikiPlacesAndroid pour le concours SFR JTD</title>
		<link>http://blog.dahanne.net/2009/04/26/soumission-du-projet-wikiplacesandroid-pour-le-concours-sfr-jtd/</link>
		<comments>http://blog.dahanne.net/2009/04/26/soumission-du-projet-wikiplacesandroid-pour-le-concours-sfr-jtd/#comments</comments>
		<pubDate>Sun, 26 Apr 2009 21:52:59 +0000</pubDate>
		<dc:creator>anthony.dahanne</dc:creator>
				<category><![CDATA[android]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[rails]]></category>

		<guid isPermaLink="false">http://blog.dahanne.net/?p=137</guid>
		<description><![CDATA[<p>Cà y est, aujourd&#8217;hui, comme le veut la tradition des deadlines, tout s&#8217;est mis à planter, à ne plus marcher dans l&#8217;application que j&#8217;ai développé conjointement avec Romain, pour le concours SFR JTD, WikiPlacesAndroid. Faut dire que j&#8217;ai voulu rajouter plein de fonctionnalités (upload d&#8217;images, redimensionnement d&#8217;images sur le téléphone) et là, des catastrophes à [...]]]></description>
			<content:encoded><![CDATA[<p>Cà y est, aujourd&#8217;hui, comme le veut la tradition des deadlines, tout s&#8217;est mis à planter, à ne plus marcher dans l&#8217;application que j&#8217;ai développé conjointement avec Romain, pour le concours <a href="http://www.sfrjtd.fr/content/wikiplacesandroid">SFR JTD, WikiPlacesAndroid</a>.<br />
Faut dire que j&#8217;ai voulu rajouter plein de fonctionnalités (upload d&#8217;images, redimensionnement d&#8217;images sur le téléphone) et là, des catastrophes à répétition : memory leaks sur le téléphone android qui vit très mal le redimensionnement d&#8217;images de 2MegaPixels, l&#8217;appli serveur Rails qui elle vit très mal la lecture des blobs en base de données MySQL, bref, un %*$ de Dimanche, comme on s&#8217;en passerait bien.<br />
Enfin, j&#8217;ai posté l&#8217;application pour le concours, avec du coup moins de fonctionnalités que prévu, en tout cas elle fonctionne et bug (presque) plus.<br />
Vous avez un téléphone Android ? Essayez donc notre application, ci jointe à ce billet !<br />
\!/ le serveur de l&#8217;application correspondant étant offline, vous ne pourrez pas&#8230; faire grand chose avec l&#8217;appli <img src='http://blog.dahanne.net/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />  !<br />
<a href="http://blog.dahanne.net/wp-content/uploads/wikiplacesandroid.apk">Télécharger WikiPlacesAndroid</a> (développée avec le SDK 1.1)</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.dahanne.net/2009/04/26/soumission-du-projet-wikiplacesandroid-pour-le-concours-sfr-jtd/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Jazoon 09 : le programme officiel de la conférence</title>
		<link>http://blog.dahanne.net/2009/04/05/jazoon-09-le-programme-officiel-de-la-conference/</link>
		<comments>http://blog.dahanne.net/2009/04/05/jazoon-09-le-programme-officiel-de-la-conference/#comments</comments>
		<pubDate>Sun, 05 Apr 2009 13:25:28 +0000</pubDate>
		<dc:creator>anthony.dahanne</dc:creator>
				<category><![CDATA[agile]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[conferences]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[jazoon 09]]></category>

		<guid isPermaLink="false">http://blog.dahanne.net/?p=127</guid>
		<description><![CDATA[<p>çà y est, il est en ligne ! Vous pouvez jeter un coup d&#8217;oeil au programme de Jazoon 2009 (qui aura lieu fin Juin) en cliquant sur ce lien : http://jazoon.com/en/conference/schedule.html Je commence à élaborer mon planning pour cette semaine (bien que j&#8217;ai énormément de mal à faire mon choix, beaucoup de sujets sont très [...]]]></description>
			<content:encoded><![CDATA[<p>çà y est, il est en ligne !<br />
Vous pouvez jeter un coup d&#8217;oeil au programme de Jazoon 2009 (qui aura lieu fin Juin) en cliquant sur ce lien :<br />
<a href="http://jazoon.com/en/conference/schedule.html">http://jazoon.com/en/conference/schedule.html</a><br />
Je commence à élaborer mon planning pour cette semaine (bien que j&#8217;ai énormément de mal à faire mon choix, beaucoup de sujets sont très intéressants)</p>
<ul>
<li>Lundi (si j&#8217;y suis):  Glassfish</li>
<li>Mardi : Java EE6, groovy, Spring 3.0, GWT, iphone, maven , mobile java</li>
<li>Mercredi : hudson, securing ajax,jsf 2,mule, android</li>
<li>Jeudi : android, rest, mockito, openjdk</li>
</ul>
<p>çà va être épuisant je sens !<br />
Trop hâte d&#8217;y être !</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.dahanne.net/2009/04/05/jazoon-09-le-programme-officiel-de-la-conference/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Premiere application android déployée sur mon HTC Dream (G1)</title>
		<link>http://blog.dahanne.net/2009/03/22/premiere-application-android-deployee-sur-mon-htc-dream-g1/</link>
		<comments>http://blog.dahanne.net/2009/03/22/premiere-application-android-deployee-sur-mon-htc-dream-g1/#comments</comments>
		<pubDate>Sun, 22 Mar 2009 16:02:04 +0000</pubDate>
		<dc:creator>anthony.dahanne</dc:creator>
				<category><![CDATA[android]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[open source]]></category>

		<guid isPermaLink="false">http://blog.dahanne.net/?p=120</guid>
		<description><![CDATA[<p>Depuis le temps que je l&#8217;attendais ! Sorti le jour de mon anniversaire (12 Mars) chez Orange France, le HTC Dream (ou G1) est motorisé par l&#8217;OS open source Android, démarré par Google il y a presque 3 ans. Et oui, il y a désormais une alternative aux mondes cloisonnés sur portable comme Iphone ou [...]]]></description>
			<content:encoded><![CDATA[<p>Depuis le temps que je l&#8217;attendais !<br />
Sorti le jour de mon anniversaire (12 Mars) chez Orange France, le HTC Dream (ou G1) est motorisé par l&#8217;OS open source Android, démarré par Google il y a presque 3 ans.<br />
Et oui, il y a désormais une alternative aux mondes cloisonnés sur portable comme Iphone ou Windows Mobile, une alternative aussi aux limitations de J2ME : Android est arrivé !</p>
<h3>Ecriture de ma première application Android</h3>
<h4>Ce qu&#8217;il faut sur le poste de développement : </h4>
<p>De retour de vacances, je me dirige sur http://developer.android.com/sdk/1.1_r1/installing.html où je découvre que dans eclipse je peux installer le plugin de développement ADT, qui, une fois connectée au SDK installée sur ma machine (sous windows pour commencer <img src='http://blog.dahanne.net/wp-includes/images/smilies/icon_sad.gif' alt=':-(' class='wp-smiley' />  ) me permet d&#8217;intéragir plus facilement avec ce SDK.<br />
En résumé il vous faut :</p>
<ul>
<li>Eclipse 3.4 avec une JRE 6</li>
<li>Le plugin ADT téléchargé via le &laquo;&nbsp;Software updates&nbsp;&raquo; d&#8217;Eclipse</li>
<li>Le SDK Android</li>
</ul>
<h4>Ecriture du Hello Android : première application Android</h4>
<p>Google fournit un tutorial très bien fait qui permet de se familiariser avec le concept d&#8217;activité et de création de vues via des fichiers XML (çà me rappelle une mission çà &#8230;), à l&#8217;adresse : http://developer.android.com/guide/tutorials/hello-world.html<br />
Oups !  quand on (contrôle) clique sur du code Android (comme Activity.class par exemple), on se rend compte que les source sne sont pas fournies ! Plutôt dur à digérer quand on a l&#8217;habitude d&#8217;avoir les sources des frameworks que l&#8217;on utilise et que l&#8217;on sait qu&#8217;Android est un produit Open Source ! Heureusement, <a href="http://code.google.com/p/android/issues/detail?id=979">le &laquo;&nbsp;bug&nbsp;&raquo; est signalé</a> et en supprimant la librairie Android (android.jar) dans le projet Eclipse et en la ré important en précisant le chemin du code source  (<a href="http://drupalmodules.com/sources.zip ">téléchargeable ici</a>), on a accès au code source du framework !<br />
On lance un &laquo;&nbsp;Run&nbsp;&raquo; et on a le plaisir de voir l&#8217;application se lancer dans l&#8217;émulateur d&#8217;Android !</p>
<h4>Déploiement de l&#8217;application Android sur le HTC Dream</h4>
<p>Il faut tout d&#8217;abord <a href="http://dl.google.com/android/android_usb_windows.zip">télécharger et installer les drivers USB sur votre poste de développement</a>.<br />
Pour installer les pilotes, dézippez les dans le répertoire de votre choix, et connectez en USB votre téléphone (en ayant pris soin au préalable de le mettre en mode Debug USB dans Parametres -> Applications -> Développement); Windows va détecter votre téléphone et vous demandez d&#8217;installer les pilotes.<br />
On y est presque !<br />
Il n&#8217;y a plus qu&#8217;à déployer l&#8217;application, pour cela, retournez dans Eclipse, dans votre &laquo;&nbsp;Run Configuration&#8230;&nbsp;&raquo; qui lance votre application Android dans l&#8217;émulateur, sélectionner dans &laquo;&nbsp;Target&nbsp;&raquo; Selection &laquo;&nbsp;Manual&nbsp;&raquo;, cliquez sur &laquo;&nbsp;Run&nbsp;&raquo; un dialogue apparaît, sélectionnez votre téléphone, et regardez votre application se lancer sur votre téléphone portable toujours connecté en USB bien sûr !<br />
Maintenant, laissez place à votre imagination et codez !</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.dahanne.net/2009/03/22/premiere-application-android-deployee-sur-mon-htc-dream-g1/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic

Served from: blog.dahanne.net @ 2012-02-04 16:38:33 -->
