<?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>The Telio Blog &#187; Java</title>
	<atom:link href="http://www.telio.be/blog/category/java/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.telio.be/blog</link>
	<description>&#34;Du choc des idées jaillit la lumière&#34;</description>
	<lastBuildDate>Mon, 15 Mar 2010 16:47:35 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Let&#8217;s put Hibernate to sleep ?</title>
		<link>http://www.telio.be/blog/2008/10/08/lets-put-hibernate-to-sleep/</link>
		<comments>http://www.telio.be/blog/2008/10/08/lets-put-hibernate-to-sleep/#comments</comments>
		<pubDate>Wed, 08 Oct 2008 10:44:45 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[All]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://www.telio.be/blog/2008/10/08/lets-put-hibernate-to-sleep/</guid>
		<description><![CDATA[Don&#8217;t get me wrong, Hibernate is a great tool written by very smart people, but I keep wondering how this technology has become so popular.
Maybe it&#8217;s just me, but for the past 3 years now I have not come across one single developer that grasps half of the concepts needed to understand how Hibernate works. [...]]]></description>
			<content:encoded><![CDATA[<p>Don&#8217;t get me wrong, Hibernate is a great tool written by very smart people, but I keep wondering how this technology has become so popular.</p>
<p>Maybe it&#8217;s just me, but for the past 3 years now I have not come across one single developer that grasps half of the concepts needed to understand how Hibernate works. They use it and don&#8217;t understand it.</p>
<p>This is a trend I have been witnessing more and more. Developers pick a technology because it is the hype of the moment, start to use it, get a hard time to get it to do what they want, <strong>but keep using it</strong> and advocate it. Probably because they don&#8217;t want to admit to the world they don&#8217;t understand it.</p>
<p>This is in my opinion what makes Hibernate (and the like) so popular.</p>
<p>To illustrate my point, we were just contracted by one of our customers to take over the maintenance of a codebase written by another company.</p>
<p>I will make no comment on the code itself, since I tend not to judge code written by others since code is always written in a specific &#8220;context&#8221; and, in my opinion, can not be judged without knowing that context.</p>
<p>The main complaint of the customer was that the application was getting slow. He had to wait from 5 minutes to 15 minutes to get one specific screen to dispay (I am not exagerating).</p>
<p>So we started  a code analysis and had the chance to witness exactly what I was mentioning above. All the code was written exactly as if practice existed in &#8220;theory&#8221;.</p>
<p>The application had a magnificent (ironic) data model with 50 tables (entirely generated by Hibernate). An object graph sometimes 5 or 6 level deep.</p>
<p>While looking at it, I could hear the developer say on day 1 : Wouaw, this is so cool &#8230; I can do getEmployee().getDepartment().getRegion().getXXXX().getYYY().add(new ZZZ()) .. and it all works ..</p>
<p>And then the nightmare begins : lazy loading, hibernate session (open session in view issues), object identity, HQL, slow queries, etc ..</p>
<p>And so the developer (which never abandons) tries to &#8220;understand&#8221; by finding workarounds, tricks, breaks his architecture and does everything that is needed to make this nightmare work.</p>
<p>And so in day 15 (or 200 depending on the company you work for) : the code works (or seems to work) and nobody can touch it anymore because nobody understands it (except of course the main developer).</p>
<p>In our case, in production with real data (1.000.000 records or so &#8211; which is not even that big) the application is &#8220;curiously&#8221; verrrrrry slow ..</p>
<p>Just turning on the &#8220;show sql&#8221; in hibernate generated 3 Mb logs on every click &#8230;</p>
<p>The conclusion here is that, in my opinion, it is not a good idea to try to &#8220;hide&#8221; your database behind a &#8220;magic&#8221; object model. Even if Hibernate does its best to achieve just that, I think the challenge is not worth it .. The database will always pop back on you .. So embrace it ..</p>
<p>So we decided to remove the Hibernate layer and replaced it with IBatis. Hopefully the code was well structured and we were able to replace the Hibernate DAO layer by and equivalent (somewhat adapted) IBatis layer but not touching the above service layers.</p>
<p>When we choose a technology, we usually expect the following :</p>
<ul>
<li>It should pass the 10 minute test</li>
<li>The learning curve should not be too steep</li>
<li>It should serve a specific purpose and serve it well</li>
<li>The technology should be <strong>understandable</strong> by a junior developer after 30 min introduction</li>
</ul>
<p>Pierre</p>
]]></content:encoded>
			<wfw:commentRss>http://www.telio.be/blog/2008/10/08/lets-put-hibernate-to-sleep/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>What is really in the JDK ?</title>
		<link>http://www.telio.be/blog/2007/10/04/what-is-really-in-the-jdk/</link>
		<comments>http://www.telio.be/blog/2007/10/04/what-is-really-in-the-jdk/#comments</comments>
		<pubDate>Thu, 04 Oct 2007 07:23:29 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://www.telio.be/blog/2007/10/04/what-is-really-in-the-jdk/</guid>
		<description><![CDATA[For a while I&#8217;ve started counting the number of external JAR&#8217;s i&#8217;m using in a given project. I usually try to make sure that every one of them is &#8220;needed&#8221;. Now as a rough statistic, the last 3 projects I worked on had

34 Mb dependencies (cocoon project &#8211; lot of XML stuff  
30 Mb [...]]]></description>
			<content:encoded><![CDATA[<p>For a while I&#8217;ve started counting the number of external JAR&#8217;s i&#8217;m using in a given project. I usually try to make sure that every one of them is &#8220;needed&#8221;. Now as a rough statistic, the last 3 projects I worked on had</p>
<ol>
<li>34 Mb dependencies (cocoon project &#8211; lot of XML stuff <img src='http://www.telio.be/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </li>
<li>30 Mb dependencies (using web services .. )</li>
<li>6 Mb (basic web based project)</li>
</ol>
<p>Now,  considering that a JDK weighs 33Mb (rt.jar) my question is : <strong>what is really in the JDK ?</strong><br />
P.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.telio.be/blog/2007/10/04/what-is-really-in-the-jdk/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Getting the file owner in Java using JNI</title>
		<link>http://www.telio.be/blog/2007/06/26/getting-the-file-owner-in-java-using-jni/</link>
		<comments>http://www.telio.be/blog/2007/06/26/getting-the-file-owner-in-java-using-jni/#comments</comments>
		<pubDate>Tue, 26 Jun 2007 08:57:11 +0000</pubDate>
		<dc:creator>plosson</dc:creator>
				<category><![CDATA[All]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://www.telio.be/blog/2007/06/26/getting-the-file-owner-in-java-using-jni/</guid>
		<description><![CDATA[Since i needed this for a project, I thought it was worth a post.
Basically I needed to watch a directory for incoming files and perform a given action based on the owner of the file, in Java.
For the polling part, no problem, but how can I get the owner of a file in Java ? [...]]]></description>
			<content:encoded><![CDATA[<p>Since i needed this for a project, I thought it was worth a post.</p>
<p>Basically I needed to watch a directory for incoming files and perform a given action based on the <strong>owner </strong>of the file, in Java.</p>
<p>For the polling part, no problem, but how can I get the owner of a file in Java ? Well after 1 hour searching the internet and concluding that :</p>
<ul>
<li>It is not possible in pure Java at least up to 1.5</li>
<li>It should be done using native code through JNI</li>
</ul>
<p>I decided to give it a shot since I had another hour in front of me. Here a the steps I followed :</p>
<p>1. Try to find some code that does this in C++ : <a href="http://msdn2.microsoft.com/en-us/library/aa446629.aspx" title="http://msdn2.microsoft.com/en-us/library/aa446629.aspx">http://msdn2.microsoft.com/en-us/library/aa446629.aspx</a></p>
<p>2. Try to compile this code <img src='http://www.telio.be/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  Since I have no Visual Studio or other C++ IDE, let&#8217;s go find one .. :</p>
<p><a href="http://www.bloodshed.net/devcpp.html">http://www.bloodshed.net/devcpp.html</a></p>
<p>3. Install Dev++ and compile the code .. and to my great surprise, it works (I must say I have bad college memories about C++, compilers, make files, compiler directives, etc&#8230;)</p>
<p>4. Now let&#8217;s tackle the JNI part .. since I never used JNI before (but know what it&#8217;s about), I type &#8216;jni tutorial&#8217; in google .. and find :</p>
<p><a href="http://www.codetoad.com/java_simpleJNI.asp">http://www.codetoad.com/java_simpleJNI.asp</a></p>
<p>I chose this page because it seemed to have an example of passing a String parameter and getting back a String result &#8211; which is exactly what I need since I will pass a file path and get back the file owner.</p>
<p>5. Create a java class</p>
<pre lang="java">
import java.io.*;
public class getowner
{
	private static native String getowner(String arg);
        public static void main(String[] args)
	{
	 	System.load("c:/temp/java/getowner.dll");
		File f = new File(args[0]);
		File[] children = f.listFiles();
		for (int i=0; i &lt; children.length;i++)
		{
			if (children[i].isFile())
				System.out.println(getowner(children[i].getPath()));
	 	}
	}
}</pre>
<p>6. Compile the class and generate the header file using javah</p>
<pre lang="bash">javac getowner.java</pre>
<pre lang="bash">javah getowner</pre>
<p>Which generates the following header file :</p>
<pre lang="cpp">
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class getowner */

#ifndef _Included_getowner
#define _Included_getowner
#ifdef __cplusplus
extern "C" {
#endif
/*
 * Class:     getowner
 * Method:    getowner
 * Signature: (Ljava/lang/String;)Ljava/lang/String;
 */
JNIEXPORT jstring JNICALL Java_getowner_getowner
  (JNIEnv *, jclass, jstring);

#ifdef __cplusplus
}
#endif
#endif
</jni.h></pre>
<p>7. Write the implementation by modifying the code used in step 2</p>
<p>(see attachment for the complete source code)</p>
<p>8. Compile the whole thing, don&#8217;t forget in the project settings to add 2 include directories pointing to the JDK <strong>include</strong> and <strong>include/win32</strong> folder</p>
<p>If you&#8217;re lucky you should get a nice <strong>getowner.dll</strong> file</p>
<p>9. You can now run the java program :</p>
<pre lang="bash">java getowner c:windows</pre>
<p>which will output the owner of all the file in you windows directory.</p>
<p>You can download the source code zip <a href="http://www.telio.be/blog/wp-content/uploads/2007/06/getowner.zip" title="getowner.zip">getowner.zip</a> that contains  :</p>
<ul>
<li>the project file</li>
<li>the cpp source file</li>
<li>the generated header file</li>
<li>the java class</li>
</ul>
<p>Have fun !</p>
<p>P.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.telio.be/blog/2007/06/26/getting-the-file-owner-in-java-using-jni/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>AJAX Upload progress monitor for Commons-FileUpload Example</title>
		<link>http://www.telio.be/blog/2006/01/06/ajax-upload-progress-monitor-for-commons-fileupload-example/</link>
		<comments>http://www.telio.be/blog/2006/01/06/ajax-upload-progress-monitor-for-commons-fileupload-example/#comments</comments>
		<pubDate>Fri, 06 Jan 2006 15:40:33 +0000</pubDate>
		<dc:creator>plosson</dc:creator>
				<category><![CDATA[All]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://www.telio.be/blog/2006/01/06/ajax-upload-progress-monitor-for-commons-fileupload-example/</guid>
		<description><![CDATA[Don&#8217;t laugh .. I did not get any comments from my previous post (normal, nobody reads this blog except me  ), so I decided to take the time to put together a little sample of a Java AJAX file upload progress bar example.
For people who never used DWR, it can also serve as a [...]]]></description>
			<content:encoded><![CDATA[<p>Don&#8217;t laugh .. I did not get any comments from my previous post (normal, nobody reads this blog except me <img src='http://www.telio.be/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> ), so I decided to <em>take </em>the time to put together a little sample of a Java AJAX file upload progress bar example.</p>
<p>For people who never used DWR, it can also serve as a nice example of how simple it is to use.</p>
<p>The example has been kept to the strict minimum to be self explanatory and it not supposed to be used as is .. (java code is a JSP aarrrggg &#8230;).</p>
<p>I also added a delay during the upload so that you get a chance to actually see the progress bar move when the server and the client are on the same machine.</p>
<p>[code lang="java"]UploadListener listener = new UploadListener(request, 30);[/code]<br />
To run the example, just place the war file in your favorite servlet engine&#8217;s deployment dir.</p>
<p>Here is a screenshot of the example in action :</p>
<p><img src="http://www.telio.be/blog/wp-content/uploads/2006/01/ajax_upload1.jpg" /></p>
<p>Here is the war file : <a href="http://www.telio.be/blog/wp-content/uploads/2006/01/ajax-upload-1.0.war">ajax-upload-1.0.war</a> (the war includes all sources and a build file)<br />
And remember, this is an example to <em><strong>demonstrate</strong></em> and <em><strong>understand</strong></em> how all this works and is not supposed to be used as is.</p>
<p>P.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.telio.be/blog/2006/01/06/ajax-upload-progress-monitor-for-commons-fileupload-example/feed/</wfw:commentRss>
		<slash:comments>63</slash:comments>
		</item>
		<item>
		<title>AJAX Upload progress monitor for Commons-FileUpload</title>
		<link>http://www.telio.be/blog/2006/01/05/ajax-upload-progress-monitor-for-commons-fileupload/</link>
		<comments>http://www.telio.be/blog/2006/01/05/ajax-upload-progress-monitor-for-commons-fileupload/#comments</comments>
		<pubDate>Thu, 05 Jan 2006 15:48:13 +0000</pubDate>
		<dc:creator>plosson</dc:creator>
				<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://www.telio.be/blog/2006/01/05/ajax-upload-progress-monitor-for-commons-fileupload/</guid>
		<description><![CDATA[Here is a little addition to the Jakarta File Upload library to allow to monitor the progress of the file upload.
An OutputStreamListener can be used with a MonitoredDiskFileItemFactory. It will be informed of the progress of the HTTP file upload.
To implement a nice AJAX upload progress bar, here is how I did it :

Use DWR [...]]]></description>
			<content:encoded><![CDATA[<p>Here is a little addition to the Jakarta File Upload library to allow to monitor the progress of the file upload.</p>
<p>An <em>OutputStreamListener </em>can be used with a <em>MonitoredDiskFileItemFactory. </em>It will be informed of the progress of the HTTP file upload.</p>
<p>To implement a nice AJAX upload progress bar, here is how I did it :</p>
<ol>
<li>Use <a title="DWR" href="http://www.getahead.ltd.uk/dwr/" target="_blank">DWR</a> (IMO the simplest and easiest java AJAX library out there)</li>
<li>Implement an OutputStreamListener to store the progress information somewhere (in the session, in a file, in a static var, you name it)</li>
<li>Implement an AJAX service to read this information so you can use it in your upload page</li>
<li>Implement some basic javascript to trigger the AJAX calls every <span style="font-style: italic">n</span> milliseconds</li>
</ol>
<p>I&#8217;ll post a full example in a future post if I have time (which I probably won&#8217;t, but if I am overwhelmed with comments I&#8217;ll try to take the time <img src='http://www.telio.be/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> )</p>
<p>You can download the code <a href="http://www.telio.be/blog/wp-content/uploads/2006/01/commons-fu-progress-1.0.zip">here</a></p>
<p>P.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.telio.be/blog/2006/01/05/ajax-upload-progress-monitor-for-commons-fileupload/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
