<?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>Duy Do blog</title>
	<atom:link href="http://duydo.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://duydo.com</link>
	<description>technology, software development, review</description>
	<lastBuildDate>Mon, 28 Jan 2013 02:59:09 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>JPA Repository &#8211; makes your data access layer easy</title>
		<link>http://duydo.com/jpa-repository-makes-your-data-access-layer-easy/</link>
		<comments>http://duydo.com/jpa-repository-makes-your-data-access-layer-easy/#comments</comments>
		<pubDate>Mon, 28 Jan 2013 02:59:09 +0000</pubDate>
		<dc:creator>Duy Do</dc:creator>
				<category><![CDATA[Design Patterns]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[hibernate]]></category>
		<category><![CDATA[jpa]]></category>
		<category><![CDATA[opensource]]></category>
		<category><![CDATA[orm]]></category>

		<guid isPermaLink="false">http://duydo.com/?p=361</guid>
		<description><![CDATA[This is a small open source project I&#8217;ve created to implement repository programming model with JPA 2 and Specification pattern, it  provides a simple and easy way to build the data access layer. The source code is hosted at GitHub https://github.com/duydo/jpa-repository,
If you have any suggestion or feedback, don&#8217;t hesitate to drop me a line ...]]></description>
			<content:encoded><![CDATA[<p>This is a small open source project I&#8217;ve created to implement repository programming model with JPA 2 and <a href="http://en.wikipedia.org/wiki/Specification_pattern">Specification</a> pattern, it  provides a simple and easy way to build the data access layer. The source code is hosted at GitHub <a href="https://github.com/duydo/jpa-repository">https://github.com/duydo/jpa-repository</a>,</p>
<p>If you have any suggestion or feedback, don&#8217;t hesitate to drop me a line <img src='http://duydo.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<h1>Build &amp; Install</h1>
<p>It is very easy to build from source code with maven:</p>
<ol>
<li>git clone https://github.com/duydo/jpa-repository.git</li>
<li>cd jpa-repository</li>
<li>mvn install</li>
</ol>
<p>If you use maven with project, just adding dependency to your pom, :</p>
<pre>&lt;dependency&gt;
&lt;groupId&gt;com.duydo&lt;/groupId&gt;
&lt;artifactId&gt;jpa-repository&lt;/artifactId&gt;
&lt;version&gt;0.0.1-SNAPSHOT&lt;/version&gt;
&lt;/dependency&gt;</pre>
<h1>Usage</h1>
<p><strong>Create an example entity User</strong></p>
<pre><code>
    @Entity
    public class User extends EntityObject {
        private String name;
        private Integer age;
        private String email;

        public User() {}
        //getter/setter here

    }
</code></pre>
<p><strong>First, we need to create an instance of <code>Repository</code></strong></p>
<pre><code>
EntityManager em = ...;
Repository repo = new JPARepository(em);

</code></pre>
<p><strong>Basic Query</strong></p>
<pre><code>
//find all users
List users = repo.findAll(User.class)

//find user by id
User user = repo.findById(User.class, 1L);

//create
User user = new User();
repo.save(user);

//update
User user = repo.findById(User.class, 1L);
user.setName("Duy Do");
repo.update(user);

// delete
repo.remove(user);

</code></pre>
<h2><a name="query-with-specification" href="https://github.com/duydo/jpa-repository#query-with-specification"></a>Query with Specification</h2>
<p><strong>Find unique user has email <a href="mailto:abc@example.com">abc@example.com</a></strong></p>
<pre><code>
Specification hasEmail = Specifications.equal("email", "abc@example.com");
User user = repo.findBySpecification(User.class, hasEmail).asSingle();
</code></pre>
<p><strong>Find all users has name &#8220;Duy&#8221;</strong></p>
<pre><code>
Specification hasName = Specifications.equal("name", "Duy");
List users = repo.findBySpecification(User.class, hasName).asList();
</code></pre>
<p><strong>Find all users which name is not &#8220;Duy&#8221;</strong></p>
<pre><code>
Specification notName = Specifications.equal("name", "Duy").not();
List users = repo.findBySpecification(User.class, notName).asList();
</code></pre>
<p><strong>We can combine specifications with AND, OR</strong></p>
<pre><code>
//Find users has name "Duy" and age is "28"
Specification hasName = Specifications.equal("name", "Duy");
Specification hasAge28 = Specifications.equal("age", 28);
List users = repo.findBySpecification(User.class, hasName.and(hasAge28)).asList();
</code></pre>
<h2><a name="sorting" href="https://github.com/duydo/jpa-repository#sorting"></a>Sorting</h2>
<p>Sorting by using method <code>sortXXX()</code> of <code>SepecificationResult</code></p>
<p><strong>Find all users has name &#8220;Duy&#8221; and sort ascending by name</strong></p>
<pre><code>
Specification hasName = Specifications.equal("name", "Duy");
List users = repo.findBySpecification(User.class, hasName).sortAscending("name").asList();
</code></pre>
<h2><a name="paging" href="https://github.com/duydo/jpa-repository#paging"></a>Paging</h2>
<p>Paging by using method <code>skip(int count)</code> and <code>get(int count)</code> of <code>SepecificationResult</code></p>
<p><strong>Find 10 users has name &#8220;Duy&#8221;</strong></p>
<pre><code>
Specification hasName = Specifications.equal("name", "Duy");
List users = repo.findBySpecification(User.class, hasName).get(10).asList();
</code></pre>
<p><strong>Find all users has name &#8220;Duy&#8221; but skip 10 first users</strong></p>
<pre><code>
Specification hasName = Specifications.equal("name", "Duy");
List users = repo.findBySpecification(User.class, hasName).skip(10).asList();
</code></pre>
<p><strong>Find 20 users has name &#8220;Duy&#8221; but skip 10 first users</strong></p>
<pre><code>
Specification hasName = Specifications.equal("name", "Duy");
List users = repo.findBySpecification(User.class, hasName).skip(10).get(20).asList();
</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://duydo.com/jpa-repository-makes-your-data-access-layer-easy/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Install Hadoop with MapReduce 2 (YARN) on Ubuntu</title>
		<link>http://duydo.com/install-hadoop-with-mapreduce-2-yarn-on-ubuntu-2/</link>
		<comments>http://duydo.com/install-hadoop-with-mapreduce-2-yarn-on-ubuntu-2/#comments</comments>
		<pubDate>Sat, 01 Dec 2012 03:21:33 +0000</pubDate>
		<dc:creator>Duy Do</dc:creator>
				<category><![CDATA[Hadoop]]></category>
		<category><![CDATA[cloudera]]></category>
		<category><![CDATA[yarn]]></category>

		<guid isPermaLink="false">http://duydo.com/?p=332</guid>
		<description><![CDATA[A quick note for installing Hadoop with MapReduce 2 (YARN) on Ubuntu 12.04 in pseudo-distributed mode using Cloudera CDH4.
First, ensure JDK 1.6 installed on your system and set environment variable JAVA_HOME point to jdk path and then following these steps:
Install
1. Download and install CDH4 repository
wget http://archive.cloudera.com/cdh4/one-click-install/precise/amd64/cdh4-repository_1.0_all.deb
$ sudo dpkg -i cdh4-repository_1.0_all.deb
2. Add the Cloudera Public GPG ...]]></description>
			<content:encoded><![CDATA[<p>A quick note for installing Hadoop with MapReduce 2 (YARN) on Ubuntu 12.04 in pseudo-distributed mode using Cloudera CDH4.</p>
<p>First, ensure JDK 1.6 installed on your system and set environment variable JAVA_HOME point to jdk path and then following these steps:</p>
<h3>Install</h3>
<p><strong>1. Download and install CDH4 repository</strong></p>
<pre>wget http://archive.cloudera.com/cdh4/one-click-install/precise/amd64/cdh4-repository_1.0_all.deb
$ sudo dpkg -i cdh4-repository_1.0_all.deb</pre>
<p><strong>2. Add the Cloudera Public GPG Key to your repository</strong></p>
<pre>$ curl -s http://archive.cloudera.com/cdh4/ubuntu/precise/amd64/cdh/archive.key | sudo apt-key add</pre>
<p><strong>3. Install Hadoop with Yarn</strong></p>
<pre>$ sudo apt-get update
$ sudo apt-get install hadoop-conf-pseudo</pre>
<h3>Starting and verifying Hadoop is working correctly</h3>
<p>For YARN, a pseudo-distributed Hadoop installation consists of one node running all five Hadoop daemons: namenode, secondarynamenode, resourcemanager, datanode, and nodemanager.<br />
<strong><br />
1. View files on the system</strong></p>
<pre>$ dpkg -L hadoop-conf-pseudo</pre>
<p><strong>2. Start the NameNode</strong><br />
Before starting the NameNode we must format the NameNode</p>
<pre>$ sudo -u hdfs hdfs namenode -format</pre>
<p><strong>Start HDFS</strong></p>
<pre>$ for service in /etc/init.d/hadoop-hdfs-*; do $service start; done</pre>
<p>To verify the services have started, we can check <a href="http://localhost:50070" target="_blank">http://localhost:50070</a></p>
<p><strong>3. Create /tmp directory and set permissions</strong></p>
<pre>$ sudo -u hdfs hadoop fs -mkdir /tmp
$ sudo -u hdfs hadoop fs -chmod -R 1777 /tmp</pre>
<p><strong>4. Create Staging and Log Directories</strong><br />
Create the staging directory and set permissions</p>
<pre>$ sudo -u hdfs hadoop fs -mkdir /tmp/hadoop-yarn/staging
$ sudo -u hdfs hadoop fs -chmod -R 1777 /tmp/hadoop-yarn/staging</pre>
<p>Create the done_intermediate directory under the staging directory and set permissions</p>
<pre>$ sudo -u hdfs hadoop fs -mkdir /tmp/hadoop-yarn/staging/history/done_intermediate
$ sudo -u hdfs hadoop fs -chmod -R 1777 /tmp/hadoop-yarn/staging/history/done_intermediate</pre>
<p>Change ownership on the staging directory and subdirectory</p>
<pre>$ sudo -u hdfs hadoop fs -chown -R mapred:mapred /tmp/hadoop-yarn/staging</pre>
<p>Create the /var/log/hadoop-yarn directory and set ownership</p>
<pre>$ sudo -u hdfs hadoop fs -mkdir /var/log/hadoop-yarn
$ sudo -u hdfs hadoop fs -chown yarn:mapred /var/log/hadoop-yarn</pre>
<p><strong>5. Verify HDFS file structure</strong></p>
<pre>$ sudo -u hdfs hadoop fs -ls -R /</pre>
<p>You should see the following directories</p>
<pre>drwxrwxrwt   - hdfs   supergroup        0 2012-05-31 15:31 /tmp
drwxr-xr-x   - hdfs   supergroup        0 2012-05-31 15:31 /tmp/hadoop-yarn
drwxrwxrwt   - mapred mapred            0 2012-05-31 15:31 /tmp/hadoop-yarn/staging
drwxr-xr-x   - mapred mapred            0 2012-05-31 15:31 /tmp/hadoop-yarn/staging/history
drwxrwxrwt   - mapred mapred            0 2012-05-31 15:31 /tmp/hadoop-yarn/staging/history/done_intermediate
drwxr-xr-x   - hdfs   supergroup        0 2012-05-31 15:31 /var
drwxr-xr-x   - hdfs   supergroup        0 2012-05-31 15:31 /var/log
drwxr-xr-x   - yarn   mapred            0 2012-05-31 15:31 /var/log/hadoop-yarn</pre>
<p><strong>6. Start YARN</strong></p>
<pre>$ sudo service hadoop-yarn-resourcemanager start
$ sudo service hadoop-yarn-nodemanager start
$ sudo service hadoop-mapreduce-historyserver start</pre>
<p><strong>7. Create User Directories</strong><br />
Create a home directory for each MapReduce user. It is best to do this on the NameNode; for example:</p>
<pre>$ sudo -u hdfs hadoop fs -mkdir  /user/
$ sudo -u hdfs hadoop fs -chown  /user/</pre>
<p>where  is the Linux username of each user.</p>
<p>Alternatively, you can log in as each Linux user and create the home directory as follows:</p>
<pre>$ sudo -u hdfs hadoop fs -mkdir /user/$USER
$ sudo -u hdfs hadoop fs -chown $USER /user/$USER</pre>
<h3>Running an example application with YARN</h3>
<p><strong>Create a home directory on HDFS for the user who will be running the job (for example, duydo):</strong></p>
<pre>$ sudo -u hdfs hadoop fs -mkdir /user/duydo
$  sudo -u hdfs hadoop fs -chown duydo /user/duydo</pre>
<p>Do the following steps as the user duydo.<br />
Make a directory in HDFS called input and copy some XML files into it by running the following commands in pseudo-distributed mode:</p>
<pre>$ hadoop fs -mkdir input
$ hadoop fs -put /etc/hadoop/conf/*.xml input
$ hadoop fs -ls input</pre>
<p>Found 3 items:</p>
<pre>-rw-r--r--   1 duydo supergroup       1348 2012-02-13 12:21 input/core-site.xml
-rw-r--r--   1 duydo supergroup       1913 2012-02-13 12:21 input/hdfs-site.xml
-rw-r--r--   1 duydo supergroup       1001 2012-02-13 12:21 input/mapred-site.xml</pre>
<p>Set HADOOP_MAPRED_HOME for user duydo:</p>
<pre>$ export HADOOP_MAPRED_HOME=/usr/lib/hadoop-mapreduce</pre>
<p>Run an example Hadoop job to grep with a regular expression in our input data.</p>
<pre>$ hadoop jar /usr/lib/hadoop-mapreduce/hadoop-mapreduce-examples.jar grep input output23 'dfs[a-z.]+'</pre>
<p>After the job completes, we can find the output in the HDFS directory named output23 because we specified that output directory to Hadoop.</p>
<pre>$ hadoop fs -ls
$ hadoop fs -ls output23</pre>
<p>Found 2 items</p>
<pre>drwxr-xr-x  -  duydo supergroup     0 2009-02-25 10:33   /user/duydo/output23/_SUCCESS
-rw-r--r--  1  duydo supergroup  1068 2009-02-25 10:33   /user/duydo/output23/part-r-00000</pre>
<p>Read the results in the output file.</p>
<pre>$ hadoop fs -cat output23/part-r-00000 | head
1    dfs.safemode.min.datanodes
1    dfs.safemode.extension
1    dfs.replication
1    dfs.permissions.enabled
1    dfs.namenode.name.dir
1    dfs.namenode.checkpoint.dir
1    dfs.datanode.data.dir</pre>
<p>References:<br />
<a href="https://ccp.cloudera.com/display/CDH4DOC/Installing+CDH4+on+a+Single+Linux+Node+in+Pseudo-distributed+Mode">https://ccp.cloudera.com/display/CDH4DOC/Installing+CDH4+on+a+Single+Linux+Node+in+Pseudo-distributed+Mode</a></p>
]]></content:encoded>
			<wfw:commentRss>http://duydo.com/install-hadoop-with-mapreduce-2-yarn-on-ubuntu-2/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Spring 3 + JPA 2.0 + Hibernate 3.5.1-Final + Wicket 1.4.9 + Maven 2</title>
		<link>http://duydo.com/spring-3-hibenate-3-5-wicket-maven/</link>
		<comments>http://duydo.com/spring-3-hibenate-3-5-wicket-maven/#comments</comments>
		<pubDate>Mon, 25 Jan 2010 08:10:06 +0000</pubDate>
		<dc:creator>Duy Do</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[hibernate3]]></category>
		<category><![CDATA[jpa2]]></category>
		<category><![CDATA[maven]]></category>
		<category><![CDATA[spring3]]></category>
		<category><![CDATA[wicket]]></category>

		<guid isPermaLink="false">http://duydo.com/?p=269</guid>
		<description><![CDATA[This is just a quick note for someone want to use Spring 3, Jpa 2, Hibernate 3, Wicket within Maven 2 project.
You can download an example project at here and remember that only Spring version from 3.0.1  supports JPA 2 fully.
I. Add properties and dependencies into your POM.XML file
1. Add properties
&#60;properties&#62;
    ...]]></description>
			<content:encoded><![CDATA[<p>This is just a quick note for someone want to use Spring 3, Jpa 2, Hibernate 3, Wicket within Maven 2 project.</p>
<p>You can download an example project at <a href="http://dl.dropbox.com/u/1598491/wicket-spring-jpa-hibernate.zip">here</a> and remember that only Spring version from 3.0.1  supports JPA 2 fully.</p>
<p><strong>I. Add properties and dependencies into your POM.XML file</strong></p>
<p>1. Add properties</p>
<pre name="code" class="xml">&lt;properties&gt;
       ...
       &lt;wicket.version&gt;1.4.9&lt;/wicket.version&gt;
       &lt;spring.version&gt;3.0.2.RELEASE&lt;/spring.version&gt;
       &lt;hibernate.version&gt;3.5.1-Final&lt;/hibernate.version&gt;
&lt;/properties&gt;
</pre>
<p>2.  Add Wicket dependencies</p>
<pre name="code" class="xml">&lt;!--  WICKET DEPENDENCIES --&gt;
&lt;dependency&gt;
    &lt;groupId&gt;org.apache.wicket&lt;/groupId&gt;
    &lt;artifactId&gt;wicket&lt;/artifactId&gt;
    &lt;version&gt;${wicket.version}&lt;/version&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
   &lt;groupId&gt;org.apache.wicket&lt;/groupId&gt;
   &lt;artifactId&gt;wicket-extensions&lt;/artifactId&gt;
   &lt;version&gt;${wicket.version}&lt;/version&gt;
&lt;/dependency&gt;

&lt;!--  WICKET-SPRING DEPENDENCIES --&gt;
 &lt;dependency&gt;
 &lt;groupId&gt;org.apache.wicket&lt;/groupId&gt;
 &lt;artifactId&gt;wicket-spring&lt;/artifactId&gt;
 &lt;version&gt;${wicket.version}&lt;/version&gt;
 &lt;/dependency&gt;
</pre>
<p>3. Add Spring 3 dependencies<strong><br />
</strong></p>
<pre name="code" class="xml">&lt;!--  SPRING DEPENDENCIES --&gt;
 &lt;dependency&gt;
 &lt;groupId&gt;org.springframework&lt;/groupId&gt;
 &lt;artifactId&gt;spring-core&lt;/artifactId&gt;
 &lt;version&gt;${spring.version}&lt;/version&gt;
 &lt;/dependency&gt;
 &lt;dependency&gt;
 &lt;groupId&gt;org.springframework&lt;/groupId&gt;
 &lt;artifactId&gt;spring-web&lt;/artifactId&gt;
 &lt;version&gt;${spring.version}&lt;/version&gt;
 &lt;/dependency&gt;
 &lt;dependency&gt;
 &lt;groupId&gt;org.springframework&lt;/groupId&gt;
 &lt;artifactId&gt;spring-beans&lt;/artifactId&gt;
 &lt;version&gt;${spring.version}&lt;/version&gt;
 &lt;/dependency&gt;
 &lt;dependency&gt;
 &lt;groupId&gt;org.springframework&lt;/groupId&gt;
 &lt;artifactId&gt;spring-aop&lt;/artifactId&gt;
 &lt;version&gt;${spring.version}&lt;/version&gt;
 &lt;/dependency&gt;
 &lt;dependency&gt;
 &lt;groupId&gt;org.springframework&lt;/groupId&gt;
 &lt;artifactId&gt;spring-context&lt;/artifactId&gt;
 &lt;version&gt;${spring.version}&lt;/version&gt;
 &lt;/dependency&gt;
 &lt;dependency&gt;
 &lt;groupId&gt;org.springframework&lt;/groupId&gt;
 &lt;artifactId&gt;spring-context-support&lt;/artifactId&gt;
 &lt;version&gt;${spring.version}&lt;/version&gt;
 &lt;/dependency&gt;
 &lt;dependency&gt;
 &lt;groupId&gt;org.springframework&lt;/groupId&gt;
 &lt;artifactId&gt;spring-tx&lt;/artifactId&gt;
 &lt;version&gt;${spring.version}&lt;/version&gt;
 &lt;/dependency&gt;
 &lt;dependency&gt;
 &lt;groupId&gt;org.springframework&lt;/groupId&gt;
 &lt;artifactId&gt;spring-jdbc&lt;/artifactId&gt;
 &lt;version&gt;${spring.version}&lt;/version&gt;
 &lt;/dependency&gt;
 &lt;dependency&gt;
 &lt;groupId&gt;org.springframework&lt;/groupId&gt;
 &lt;artifactId&gt;spring-orm&lt;/artifactId&gt;
 &lt;version&gt;${spring.version}&lt;/version&gt;
 &lt;/dependency&gt;
 &lt;dependency&gt;
 &lt;groupId&gt;org.springframework&lt;/groupId&gt;
 &lt;artifactId&gt;spring-test&lt;/artifactId&gt;
 &lt;version&gt;${spring.version}&lt;/version&gt;
 &lt;scope&gt;test&lt;/scope&gt;
 &lt;/dependency&gt;
</pre>
<p>4. Add JPA 2.o /Hibernate 3 dependencies</p>
<pre name="code" class="xml">&lt;!-- HIBERNATE 3.5.1 JPA --&gt;
 &lt;dependency&gt;
 &lt;groupId&gt;org.hibernate.java-persistence&lt;/groupId&gt;
 &lt;artifactId&gt;jpa-api&lt;/artifactId&gt;
 &lt;version&gt;2.0-cr-1&lt;/version&gt;
 &lt;/dependency&gt;
 &lt;dependency&gt;
 &lt;groupId&gt;org.hibernate&lt;/groupId&gt;
 &lt;artifactId&gt;hibernate-entitymanager&lt;/artifactId&gt;
 &lt;version&gt;${hibernate.version}&lt;/version&gt;
 &lt;/dependency&gt;
&lt;!-- C3p0 for Datasource --&gt;
 &lt;dependency&gt;
 &lt;groupId&gt;c3p0&lt;/groupId&gt;
 &lt;artifactId&gt;c3p0&lt;/artifactId&gt;
 &lt;version&gt;0.9.0.4&lt;/version&gt;
 &lt;/dependency&gt;

&lt;!-- H2 DEPENDENCIES for testing --&gt;
 &lt;dependency&gt;
 &lt;groupId&gt;com.h2database&lt;/groupId&gt;
 &lt;artifactId&gt;h2&lt;/artifactId&gt;
 &lt;version&gt;1.2.125&lt;/version&gt;
 &lt;/dependency&gt;
</pre>
<p><strong>II. Create applicationContext.xml for Spring 3</strong><br />
1. Create application.properties for datasource and jpa configuration:</p>
<pre name="code" class="xml"># connection pool config (c3p0 ComboPooledDataSource)
# all time values are in seconds
c3p0.minPoolSize=2
c3p0.maxPoolSize=20
c3p0.maxConnectionAge=21600
c3p0.maxIdleTime=3600
c3p0.idleConnectionTestPeriod=300

# Development config with H2 database
jdbc.driver=org.h2.Driver
jdbc.url=jdbc:h2:~/your_database
jdbc.username=sa
jdbc.password=

jpa.databasePlatform=org.hibernate.dialect.HSQLDialect
jpa.generateDdl=true
jpa.showSql=true
</pre>
<p>2. An example applicatonContext.xml:</p>
<pre name="code" class="xml"> &lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;beans xmlns="http://www.springframework.org/schema/beans"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
 xmlns:tx="http://www.springframework.org/schema/tx" xmlns:p="http://www.springframework.org/schema/p"
 xmlns:aop="http://www.springframework.org/schema/aop"
 xsi:schemaLocation="http://www.springframework.org/schema/beans  http://www.springframework.org/schema/beans/spring-beans-3.0.xsd  http://www.springframework.org/schema/context  http://www.springframework.org/schema/context/spring-context-3.0.xsd  http://www.springframework.org/schema/tx  http://www.springframework.org/schema/tx/spring-tx-3.0.xsd  http://www.springframework.org/schema/aop  http://www.springframework.org/schema/aop/spring-aop-3.0.xsd"&gt;

 &lt;context:annotation-config /&gt;
 &lt;context:component-scan base-package="com.duydo.model" /&gt;
 &lt;tx:annotation-driven transaction-manager="transactionManager" /&gt;

 &lt;context:property-placeholder location="classpath:application.properties"/&gt;

 &lt;bean id="dataSource"&gt;
 &lt;property name="driverClass"&gt;
 &lt;value&gt;${jdbc.driver}&lt;/value&gt;
 &lt;/property&gt;
 &lt;property name="jdbcUrl"&gt;
 &lt;value&gt;${jdbc.url}&lt;/value&gt;
 &lt;/property&gt;
 &lt;property name="user"&gt;
 &lt;value&gt;${jdbc.username}&lt;/value&gt;
 &lt;/property&gt;
 &lt;property name="password"&gt;
 &lt;value&gt;${jdbc.password}&lt;/value&gt;
 &lt;/property&gt;
 &lt;property name="minPoolSize"&gt;
 &lt;value&gt;${c3p0.minPoolSize}&lt;/value&gt;
 &lt;/property&gt;
 &lt;property name="maxPoolSize"&gt;
 &lt;value&gt;${c3p0.maxPoolSize}&lt;/value&gt;
 &lt;/property&gt;
 &lt;property name="checkoutTimeout"&gt;
 &lt;!-- Give up waiting for a connection after this many milliseconds --&gt;
 &lt;value&gt;20000&lt;/value&gt;
 &lt;/property&gt;
 &lt;property name="maxIdleTime"&gt;
 &lt;value&gt;${c3p0.maxIdleTime}&lt;/value&gt;
 &lt;/property&gt;
 &lt;property name="idleConnectionTestPeriod"&gt;
 &lt;value&gt;${c3p0.idleConnectionTestPeriod}&lt;/value&gt;
 &lt;/property&gt;
 &lt;/bean&gt;

 &lt;bean
 class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor" /&gt;

 &lt;bean id="entityManagerFactory"
 class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"&gt;
 &lt;property name="persistenceUnitName" value="wsjhPU" /&gt;
 &lt;property name="dataSource" ref="dataSource" /&gt;
 &lt;property name="jpaVendorAdapter"&gt;
 &lt;bean&gt;
 &lt;property name="databasePlatform" value="${jpa.databasePlatform}" /&gt;
 &lt;property name="showSql" value="${jpa.showSql}" /&gt;
 &lt;property name="generateDdl" value="${jpa.generateDdl}" /&gt;
 &lt;/bean&gt;
 &lt;/property&gt;
 &lt;/bean&gt;
 &lt;bean id="transactionManager"&gt;
 &lt;property name="entityManagerFactory" ref="entityManagerFactory" /&gt;
 &lt;property name="dataSource" ref="dataSource" /&gt;
 &lt;/bean&gt;

 &lt;bean id="wicketApplication" class="com.duydo.WicketApplication"/&gt;

&lt;/beans&gt;
</pre>
<p><strong>III. Modify your PERSISTENCE.XML as following</strong></p>
<pre name="code" class="xml">&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;persistence version="2.0"
 xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"&gt;
 &lt;persistence-unit name="wsjhPU" transaction-type="RESOURCE_LOCAL"&gt;
 &lt;provider&gt;org.hibernate.ejb.HibernatePersistence&lt;/provider&gt;
 &lt;/persistence-unit&gt;
&lt;/persistence&gt;
</pre>
<p><strong>IV. Modify your WEB.XML as following</strong></p>
<pre name="code" class="xml">&lt;?xml version="1.0" encoding="ISO-8859-1"?&gt;
&lt;web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
 version="2.4"&gt;

 &lt;display-name&gt;wicket-spring-jpa-hibernate&lt;/display-name&gt;

 &lt;context-param&gt;
 &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
 &lt;param-value&gt;classpath:applicationContext.xml&lt;/param-value&gt;
 &lt;/context-param&gt;

 &lt;filter&gt;
 &lt;filter-name&gt;open.entitymanager.in.view&lt;/filter-name&gt;
 &lt;filter-class&gt;org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter&lt;/filter-class&gt;
 &lt;/filter&gt;

 &lt;filter&gt;
 &lt;filter-name&gt;wicket.wicket-spring-jpa-hibernate&lt;/filter-name&gt;
 &lt;filter-class&gt;org.apache.wicket.protocol.http.WicketFilter&lt;/filter-class&gt;
 &lt;init-param&gt;
 &lt;param-name&gt;applicationFactoryClassName&lt;/param-name&gt;
 &lt;param-value&gt;org.apache.wicket.spring.SpringWebApplicationFactory&lt;/param-value&gt;
 &lt;/init-param&gt;
 &lt;init-param&gt;
 &lt;param-name&gt;configuration&lt;/param-name&gt;
 &lt;param-value&gt;development&lt;/param-value&gt;
 &lt;/init-param&gt;
 &lt;/filter&gt;

 &lt;filter-mapping&gt;
 &lt;filter-name&gt;open.entitymanager.in.view&lt;/filter-name&gt;
 &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
 &lt;/filter-mapping&gt;

 &lt;filter-mapping&gt;
 &lt;filter-name&gt;wicket.wicket-spring-jpa-hibernate&lt;/filter-name&gt;
 &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
 &lt;/filter-mapping&gt;

 &lt;listener&gt;
 &lt;listener-class&gt;org.springframework.web.context.ContextLoaderListener&lt;/listener-class&gt;
 &lt;/listener&gt;
&lt;/web-app&gt;</pre>
]]></content:encoded>
			<wfw:commentRss>http://duydo.com/spring-3-hibenate-3-5-wicket-maven/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>Effective JPA: Use Enumeration Effectively</title>
		<link>http://duydo.com/effective-jpa-persist-an-enumerationeffectively/</link>
		<comments>http://duydo.com/effective-jpa-persist-an-enumerationeffectively/#comments</comments>
		<pubDate>Sun, 24 Jan 2010 04:51:09 +0000</pubDate>
		<dc:creator>Duy Do</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[effective]]></category>
		<category><![CDATA[enum]]></category>
		<category><![CDATA[enumeration]]></category>
		<category><![CDATA[jpa]]></category>

		<guid isPermaLink="false">http://duydo.com/?p=294</guid>
		<description><![CDATA[How to persist an enumeration effectively? Here is my experience.]]></description>
			<content:encoded><![CDATA[<p>How to persist an enumeration effectively? Here is my experience.</p>
<p>I will use Wordpress for example. We all know that every <strong>post </strong>in wordpress blog system has a <strong>status </strong>with possible values: draft, pending-review, published&#8230;</p>
<p>There are some ways to model the post entity. We can save <strong>status </strong>as an integer value in database: draft -> 0, pending-review -> 1, published -> 2</p>
<p><strong>Version 1</strong></p>
<pre name="code" class="java">
@Entity
public class Post {
	private Integer status;

	public Integer getStatus() {
		return status;
	}

	public void setStatus(Integer status) {
		this.status = status;
	}
}
</pre>
<p>Well that&#8217;s ok. A client can use:</p>
<pre name="code" class="java">
	Post post = ...;
	//Draft post
	post.setStatus(0);
	repository.store(post);
</pre>
<p>But this is not safe, the client can set any integer value for status. For more save, we can define constants for status values like that:</p>
<pre name="code" class="java">
public class PostStatus {
	public static final Integer DRAFT = 0;
	public static final Integer PENDING_REVIEW = 1;
	public static final Integer PUBLISHED = 2;
}
</pre>
<p>The client can use:</p>
<pre name="code" class="java">
	Post post = ...;
	//Draft post
	post.setStatus(PostStatus.DRAFT);
	repository.store(post);
</pre>
<p>But it is still not safe, because the client maybe do not use <strong>PostStatus</strong> class. So for more safe, what we need to do?<br />
Yes, we can force the client use <strong>PostStatus</strong> by declaring <strong>PostStatus</strong> as an Enum and make it dependency in <strong>Post</strong> class:</p>
<p><strong>Version 2</strong></p>
<pre name="code" class="java">
public enum PostStatus {
	DRAFT, PENDING_REVIEW, PUBLISHED;
}
</pre>
<pre name="code" class="java">
@Entity
public class Post {
	@Enumerated
	private PostStatus status;

	public PostStatus getStatus() {
		return status;
	}

	public void setStatus(PostStatus status) {
		this.status = status;
	}
}
</pre>
<p>And now client can use it:</p>
<pre name="code" class="java">
	Post post = ...;
	//Draft post
	post.setStatus(PostStatus.DRAFT);
	repository.store(post);
</pre>
<p>Well, it is better. But wait&#8230;<br />
We know that JPA persists all enum constants in order we declare them in PostStatus with value started from 0. This is limitation, we can not change order of constants, we only can append a new constant. How does we solve this limitation? </p>
<p><strong>Version 3</strong></p>
<p>Enum type in Java 5 is wonderful, we can add constructor and do some business logic in it. Apply it we can re-write PostStatus like this:</p>
<pre name="code" class="java">
public enum PostStatus {
	DRAFT(0),
	PENDING_REVIEW(1),
	PUBLISHED(2);

	private final Integer value;
	private PostStatus(Integer value) {
		this.value = value;
	}
	public Integer getValue() {
		return value;
	}
}
</pre>
<p> And Post class is re-wrote like this:</p>
<pre name="code" class="java">
@Entity
public class Post {
	private Integer status;

	public PostStatus getStatus() {
		//TODO we need a helper to convert status value to PostStatus enum
		return ...;
	}

	public void setStatus(PostStatus status) {
		this.status = status.getValue();
	}
}
</pre>
<p>Great!!!</p>
<p>Now client can use code safety and we can add many constants as we want into PostStatus without worry about order of them.</p>
<p>It reminds me of the sentence the guy talked in Java4Ever trailer: &#8220;Look how beautiful, robust, secure, portable and scalable it is&#8221; <img src='http://duydo.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://duydo.com/effective-jpa-persist-an-enumerationeffectively/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Install Thrift on Ubuntu</title>
		<link>http://duydo.com/install-thrift-on-ubuntu/</link>
		<comments>http://duydo.com/install-thrift-on-ubuntu/#comments</comments>
		<pubDate>Sun, 10 Jan 2010 04:02:44 +0000</pubDate>
		<dc:creator>Duy Do</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[thrift]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://duydo.com/?p=285</guid>
		<description><![CDATA[A quick note for installing Thrift on Ubuntu]]></description>
			<content:encoded><![CDATA[<p>A quick note for installing Thrift on Ubuntu</p>
<p>0. Install basic lib</p>
<pre name="code" class="xml">sudo apt-get install build-essential libboost-dev automake libtool flex bison pkg-config</pre>
<p>1. Get Thrift:</p>
<pre name="code" class="xml">wget http://www.apache.org/dyn/closer.cgi?path=/incubator/thrift/0.2.0-incubating/thrift-0.2.0-incubating.tar.gz</pre>
<p>2. Install Thrift</p>
<pre name="code"  class="xml">tar zxvf thrift-0.2.0-incubating.tar.gz
cd thrift-0.2.0-incubating
./bootstrap.sh
./configure --with-boost=/usr/local
make
sudo make install</pre>
<p>3. Done <img src='http://duydo.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://duydo.com/install-thrift-on-ubuntu/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Re-launch blog with my own theme</title>
		<link>http://duydo.com/re-launch-blog-with-my-own-theme/</link>
		<comments>http://duydo.com/re-launch-blog-with-my-own-theme/#comments</comments>
		<pubDate>Fri, 01 Jan 2010 04:58:56 +0000</pubDate>
		<dc:creator>Duy Do</dc:creator>
				<category><![CDATA[Misc]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[grid]]></category>
		<category><![CDATA[microformat]]></category>

		<guid isPermaLink="false">http://duydo.com/?p=266</guid>
		<description><![CDATA[



Cái blog của mình nó đi vào trạng thái offline  gần cả năm rồi. Cả năm không viết lách cái gì cả, đôi lúc cũng muốn  viết, cùng muốn chia sẻ với mọi người nhưng rồi cái cục lười biếng của  mình nó đã chiến thắng.
Vì nhu cầu muốn được &#8220;tự do ...]]></description>
			<content:encoded><![CDATA[<div>
<div>
<div>
<div>
<p>Cái blog của mình nó đi vào trạng thái offline  gần cả năm rồi. Cả năm không viết lách cái gì cả, đôi lúc cũng muốn  viết, cùng muốn chia sẻ với mọi người nhưng rồi cái cục lười biếng của  mình nó đã chiến thắng.</p>
<p>Vì nhu cầu muốn được &#8220;tự do đục khoét&#8221; cái blog và những thứ khác nên  quyết định chuyển qua dùng domain và host riêng nhưng rồi cũng làm  biếng chỉ mua host &amp; domain để đó cả mấy tháng trời mà không làm gì.  Hôm nay là một ngày đẹp trời quyết định cài đặt lại blog vớí theme mới  sau một thời gian dài làm biếng <img src="../wp-includes/images/smilies/icon_biggrin.gif" alt=":D" /> .</p>
<p>Lịch sử làm cái theme này cũng gắn liền với cái sự làm biếng của  mình. Ban đầu định dành ra khoản 1 tuần để thiết kế cái theme này, nhưng  1 tuần trôi qua rồi tuần thứ 2, 3&#8230; mình vẫn chưa làm xong. Đến tuần  thứ 7 mới thực sự bước vào làm.</p>
<p>Nói vậy chứ không làm biếng lắm, tuần 1 lên kế hoạch tìm kiếm nghiên  cứu làm sao thiết kế cái giao diện nhìn cho nó ngon ngon 1 chút. Ban đầu  định sẽ dùng BluePrint CSS framework và những thứ có sẵn để làm nhưng  sau đó quyết định sẽ thiết kế và viết mọi thứ từ đầu.</p>
<p>Quyết định thế nhưng lúc này trong đầu không có nhiều kiến thức về  xây dựng giao diện người dùng với XHTML/CSS, theo thói quen là nhờ bác  Google hỗ trợ.</p>
<p>Search tới search lui mình cũng lần ra được nhiều tên tuổi nổi tiếng  trong làng design như <a href="http://www.markboultondesign.com/" target="_blank">Mark Boulton</a>, <a href="http://subtraction.com/" target="_blank">Khoi Vinh</a>&#8230; Và cũng  từ đây mình tìm thấy những khái niệm, nguyên lý và kỹ thuật thiết kế  giao diện cho Web như: Eye Tracking, Grid System, Typography&#8230;</p>
<p>Để tìm hiểu những vấn đề này mình đã đọc những bài viết và sách sau:</p>
<ol>
<li><a href="http://www.thegridsystem.org/2009/articles/interview-with-khoi-vinh/" target="_blank">Interview  with Khoi Vinh about Grid System</a></li>
<li><a href="http://www.smashingmagazine.com/2009/08/20/typographic-design-survey-best-practices-from-the-best-blogs/" target="_blank">Typographic  Design Patterns and Best Practice</a></li>
<li>Save the Pixel &#8211; Ben Hunt</li>
<li>Don&#8217;t make me think &#8211; Steven Krug</li>
<li>Design for the Web &#8211; Mark Bouton</li>
<li>More Eric Myer on CSS &#8211; <a target="_blank">Eric A. Meyer</a></li>
<li>Design In Browser &#8211; Andy</li>
<li>&#8230;&#8230;.</li>
</ol>
<p>6 tuần dành để đọc sách và nghiên cứu những vấn đề về web, về UI thấy  cũng rất thú vị. Cảm thấy có  hứng thú mình bắt tay vào thực hành những  thứ vừa tìm hiểu được và kết quả thu được là cái theme này cùng với 1  số thư viện để dùng lại:</p>
<ol>
<li>Mini Grid System library &#8211; grid.css</li>
<li>Typography library &#8211; typography.css</li>
</ol>
<p>Đây là lần đầu tiên mình làm giao diện web ngay từ đầu 1 cách bài  bản, mặc dù theme này chưa hoàn thiện nhưng mình cảm thấy rất tự hào về  nó.</p>
<p>Để đánh dấu sự kiện này mình đã đặt tên theme là <strong>TwoMice</strong> (2 con chuột) cho dễ nhớ vì mình và vợ đều tuổi con chuột :&#8221;&gt;.</p>
<p>Thỉnh thoảng làm biếng cũng có lợi <img src="../wp-includes/images/smilies/icon_wink.gif" alt=";-)" /></p>
</div>
</div>
</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://duydo.com/re-launch-blog-with-my-own-theme/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Google Wave Account</title>
		<link>http://duydo.com/google-wave-account/</link>
		<comments>http://duydo.com/google-wave-account/#comments</comments>
		<pubDate>Mon, 20 Jul 2009 08:35:52 +0000</pubDate>
		<dc:creator>Duy Do</dc:creator>
				<category><![CDATA[Misc]]></category>
		<category><![CDATA[Google Wave]]></category>

		<guid isPermaLink="false">http://doquocduy.wordpress.com/?p=200</guid>
		<description><![CDATA[Có lẽ mình là 1 trong số những developer Việt Nam đầu tiên may mắn có được tài khoản Google Wave. Đang tìm hiểu về Google Wave, có gì hay ho sẽ chia sẻ với anh em :D. Đây là tài khoản Google Wave của mình: duydo@wavesandbox.com, anh em nào hứng thú với Google Wave thì chúng ta cùng tìm hiểu, thảo luận.]]></description>
			<content:encoded><![CDATA[<p>Có lẽ mình là 1 trong số những developer Việt Nam đầu tiên may mắn có được tài khoản Google Wave. Đang tìm hiểu về Google Wave, có gì hay ho sẽ chia sẻ với anh em <img src='http://duydo.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> . Đây là tài khoản Google Wave của mình: duydo@wavesandbox.com, anh em nào hứng thú với Google Wave thì chúng ta cùng tìm hiểu, thảo luận.</p>
<p><span id="more-200"></span></p>
<p>Làm quả screenshot cho vui nhà vui cửa <img src='http://duydo.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /><br />
<a href="http://picasaweb.google.com/lh/photo/-Sg2Km02b7RPrK5nVW4mYA?authkey=Gv1sRgCNDY4aSC4oe3QA&amp;feat=embedwebsite"><img src="http://lh3.ggpht.com/_kUX1O17s63c/SmQriUv1CKI/AAAAAAAAB9w/W487kLzhubY/s400/screenshot_01%202009-07-20%2015.13.jpg" alt="" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://duydo.com/google-wave-account/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Đi Quảng Ngãi &#8211; Sài Gòn bằng xe máy</title>
		<link>http://duydo.com/di-qu%e1%ba%a3ng-ngai-sai-gon-b%e1%ba%b1ng-xe-may/</link>
		<comments>http://duydo.com/di-qu%e1%ba%a3ng-ngai-sai-gon-b%e1%ba%b1ng-xe-may/#comments</comments>
		<pubDate>Thu, 11 Jun 2009 04:51:33 +0000</pubDate>
		<dc:creator>Duy Do</dc:creator>
				<category><![CDATA[Misc]]></category>
		<category><![CDATA[Quãng Ngãi]]></category>
		<category><![CDATA[Sài Gòn]]></category>
		<category><![CDATA[Xe Máy]]></category>

		<guid isPermaLink="false">http://doquocduy.wordpress.com/?p=192</guid>
		<description><![CDATA[Tết rồi mình và bạn gái làm một chuyến từ Quảng Ngãi vào Sài Gòn bằng xe máy. Xuất phát tại Quãng Ngãi lúc 10h sáng, mình đi một mạch đến Nha Trang vào lúc 8h tối. Ơ lại Nha Trang chơi, 10h sáng hôm sau xuất phát đi SG, chạy đến 8h tối thì ...]]></description>
			<content:encoded><![CDATA[<p>Tết rồi mình và bạn gái làm một chuyến từ Quảng Ngãi vào Sài Gòn bằng xe máy. Xuất phát tại Quãng Ngãi lúc 10h sáng, mình đi một mạch đến Nha Trang vào lúc 8h tối. Ơ lại Nha Trang chơi, 10h sáng hôm sau xuất phát đi SG, chạy đến 8h tối thì tới Thủ Đức.</p>
<p><span id="more-192"></span></p>
<p>Trong quá trình đi minh ít khi nào dừng lại nghỉ, chủ yếu đi vệ sinh hoặc khát nước thì dừng lại. Cảm giác đi lên đèo thích lắm <img src='http://duydo.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> . Rất tiếc là lúc đó mình chưa có máy quay phim chứ không giờ có được thước phim &#8221; Hành trình Quảng Ngãi &#8211; Sài Gòn bằng xe máy&#8221; cho ae thưởng ngoạn rồi hehe.</p>
<p>Ban đầu đi ai cũng không cho nhưng mình và bạn gái quyết định đi một chuyến cho biết cảm giác. Thật sự thì đi cũng không nguy hiểm như mọi người thường nghĩ. Kinh nghiệm của mình đi xe máy là phải luôn có kính chiếu hậu để quan sát dòng xe cộ phía sau, luôn cho xe chạy cách xe ô tô hoặc xe máy khác một khoảng cách an toàn, không bám đuôi hoặc cắt ngang đầu xe khác. Và khi đi phải nhìn xa xa để tránh mấy con chó hay chạy băng qua đường. Đang chạy tốc độ cao mà đụng mấy con này là coi như toi mạng. Chuyến đi này mình chỉ tốn 165.000 tiền xăng.</p>
<p>Tết này mình cũng chạy xe máy về Quảng Ngãi, anh em nào muốn thử cảm giác đi xe máy thì mình hẹn ngày lập hội đi cùng <img src='http://duydo.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://duydo.com/di-qu%e1%ba%a3ng-ngai-sai-gon-b%e1%ba%b1ng-xe-may/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Page Speed</title>
		<link>http://duydo.com/page-speed/</link>
		<comments>http://duydo.com/page-speed/#comments</comments>
		<pubDate>Sat, 06 Jun 2009 16:16:52 +0000</pubDate>
		<dc:creator>Duy Do</dc:creator>
				<category><![CDATA[Misc]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[Page Speed]]></category>
		<category><![CDATA[Performance]]></category>

		<guid isPermaLink="false">http://doquocduy.wordpress.com/?p=187</guid>
		<description><![CDATA[Page Speed is a Firefox add-on (integrated with Firebug), which has been using to improve the performance of  web pages at Google. This is very, very useful tool for web developers.
When you run Page Speed, you get immediate suggestions on how you can change your web pages to improve their speed. For example, Page Speed ...]]></description>
			<content:encoded><![CDATA[<p>Page Speed is a Firefox add-on (integrated with Firebug), which has been using to improve the performance of  web pages at Google. This is very, very useful tool for web developers.</p>
<p>When you run Page Speed, you get immediate suggestions on how you can change your web pages to improve their speed. For example, Page Speed automatically optimizes images for you, giving you a compressed image that you can use immediately on your web site. It also identifies issues such as JavaScript and CSS loaded by your page that wasn&#8217;t actually used to display the page, which can help reduce time your users spend waiting for the page to download and display.</p>
<p>You can download and install Page Speed at <a href="http://code.google.com/speed/page-speed">here</a></p>
]]></content:encoded>
			<wfw:commentRss>http://duydo.com/page-speed/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fluent Interface</title>
		<link>http://duydo.com/fluent-interface/</link>
		<comments>http://duydo.com/fluent-interface/#comments</comments>
		<pubDate>Tue, 24 Mar 2009 17:45:18 +0000</pubDate>
		<dc:creator>Duy Do</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[OOP]]></category>

		<guid isPermaLink="false">http://doquocduy.wordpress.com/?p=153</guid>
		<description><![CDATA[Recently, I&#8217;ve played with my own  framework. I found a new term, called &#8220;Fluent Interface&#8220;. There is a great article on bliki of Martin Fowler about this term, you can read it if you have not heard about it yet.
The idea of  &#8220;Fluent Interface&#8221; is instead of returning void in  setter methods of an object, ...]]></description>
			<content:encoded><![CDATA[<p>Recently, I&#8217;ve played with my own  framework. I found a new term, called &#8220;<strong>Fluent Interface</strong>&#8220;. There is <a href="http://martinfowler.com/bliki/FluentInterface.html" target="_blank">a great article</a> on bliki of Martin Fowler about this term, you can read it if you have not heard about it yet.</p>
<p>The idea of  &#8220;Fluent Interface&#8221; is instead of returning <code>void</code> in  setter methods of an object, returning an object to promote object chaining.</p>
<p><span id="more-153"></span></p>
<p><strong>Example:</strong></p>
<pre lang="java">class Query {
    private String props;
    private String table;
    private String condition;

    public Query select(String props) {
        this.props = props;
        return this;
    }

    public Query from(String table) {
        this.table = table;
        return this;
    }

    public Query where(String condition) {
        this.condition = condition;
        return this;
    }

    public String buildQuery() {
        return String.format("SELECT %s FROM %s WHERE %s", props, table, condition);
    }
}</pre>
<p><strong>Instead of:</strong></p>
<pre lang="java">Query q = new Query();
q.select("username");
q.from("user");
q.where("username = 'duydo'");
String sql = q.buildQuery();</pre>
<p><strong>We can write:</strong></p>
<pre lang="java">Query q = new Query();
String sql = q.select(”username”).from(”user”).where(”username = ‘duydo’”).buildQuery();</pre>
<p>This will make code more readable, but be careful when use this technique.</p>
]]></content:encoded>
			<wfw:commentRss>http://duydo.com/fluent-interface/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
