<?xml version='1.0' encoding='utf-8'?>
<rss version='2.0' xmlns:content='http://purl.org/rss/1.0/modules/content/' xmlns:dc='http://purl.org/dc/elements/1.1/' xmlns:slash='http://purl.org/rss/1.0/modules/slash/'>
<channel><title>Official Blog of Michael Liao</title><link>http://michael-liao.appspot.com/feed.xml</link><description>Java and Python developer</description><pubDate>Thu, 05 Nov 2009 09:29:17 +0000</pubDate><generator>expressme.org</generator><language>en</language><item><title>Be careful when using Timer</title><link>http://michael-liao.appspot.com/it/47253e2096114567813fde72c1d7c278</link><dc:creator>Michael Liao</dc:creator><pubDate>Thu, 05 Nov 2009 09:29:17 +0000</pubDate><description><![CDATA[<p>Timer is used to schedule tasks that run at a fixed rate in Java. However, the thread of Timer itself may stop unexpected when your TimerTask throws an uncaught exception. See following code:</p>
<pre class="brush:java">
public class TimerTest {

    public static void main(String[] args) {
        Timer timer = new Timer();
        timer.scheduleAtFixedRate(
                new TimerTask() {
                    int n = 0;
                    @Override
                    public void run() {
                        if (n==10)
                            throw new RuntimeException(&quot;task failed.&quot;);
                        System.out.print('.');
                        n++;
                    }
                },
                1000L,
                1000L
        );
    }
}
</pre>
<p>When the TimerTask runs 10 times it throws a RuntimeException, which cause the thread of Timer stopped. You will get the following output:</p>
<pre class="brush:java">
..........Exception in thread &quot;Timer-0&quot; java.lang.RuntimeException: task failed.
	at sync.test.TimerTest$1.run(TimerTest.java:16)
	at java.util.TimerThread.mainLoop(Timer.java:512)
	at java.util.TimerThread.run(Timer.java:462)
</pre>
<p>It is necessary to catch all exceptions in TimerTask. But the best way to schedule tasks is using Executor if you are working with JDK 5 or later. It is fast, with pooled thread, and more simple API to schedule tasks.</p>]]></description></item>
<item><title>JexiEditor: a WYSIWYG Editor</title><link>http://michael-liao.appspot.com/it/c2027e30aa2844fea4e506960ffe7837</link><dc:creator>Michael Liao</dc:creator><pubDate>Fri, 16 Oct 2009 07:49:32 +0000</pubDate><description><![CDATA[<p>JexiEditor is a WYSIWYG (what you see is what you get) editor written by Java. It is a very good example of learning the famous &quot;<a target="_blank" href="http://www.amazon.com/Design-Patterns-Elements-Reusable-Object-Oriented/dp/0201633612">GoF: Design Patterns</a>&quot;.</p>
<p>The source code can be downloaded or checked out from SVN. Please visit the project home page:</p>
<p><a target="_blank" href="http://code.google.com/p/jexieditor/">http://code.google.com/p/jexieditor/</a></p>
<p>The word &quot;Jexi&quot; is a combination of &quot;Java&quot; and &quot;Lexi&quot;. See snapshot:</p>
<p><img alt="" src="http://michael-liao.appspot.com/proxy?url=http://lh6_ggpht_com/_Q_A6LQBcREQ/StgjPunrzvI/AAAAAAAAAy8/m79Rx-TYGSk/snapshot.jpg" /></p>]]></description></item>
<item><title>JOpenID: OpenID 2.0 Client Library for Java</title><link>http://michael-liao.appspot.com/it/f6568e3e47074d3b8922124354391767</link><dc:creator>Michael Liao</dc:creator><pubDate>Fri, 16 Oct 2009 07:36:58 +0000</pubDate><description><![CDATA[<p>JOpenID is a lightweight Java client library of <a target="_blank" href="http://openid.net/">OpenID 2.0</a>.</p>
<p>JOpenID supports sign on by OpenID 2.0 protocol, which enables user to sign on with their OpenID account without registration on your website. The well-known OpenID providers are Google account, Yahoo account, etc.</p>
<p>JOpenID is simple, fast and very small, about <strong>50 KB</strong> including both binary and source code. You can download from:</p>
<p><a target="_blank" href="http://code.google.com/p/jopenid/downloads/list">http://code.google.com/p/jopenid/downloads/list</a></p>
<p>For more information about JOpenID, please visit the project home page:</p>
<p><a target="_blank" href="http://code.google.com/p/jopenid/">http://code.google.com/p/jopenid/</a></p>
<p>JOpenID is now on the list of recommended libraries on <a target="_blank" href="http://openid.net/">OpenID official website</a>:</p>
<p><img alt="" src="http://michael-liao.appspot.com/proxy?url=http://lh5_ggpht_com/_Q_A6LQBcREQ/StVvOOkXYnI/AAAAAAAAAyc/8A2CoHcNlg4/jopenid.png" /></p>]]></description></item>
<item><title>How to use OpenID to sign on with Google account</title><link>http://michael-liao.appspot.com/it/35220c97f4524e38864e062edf55d1a4</link><dc:creator>Michael Liao</dc:creator><pubDate>Wed, 14 Oct 2009 05:40:46 +0000</pubDate><description><![CDATA[<p>Recently Google announced its support for OpenID, called &quot;<a target="_blank" href="http://code.google.com/apis/accounts/docs/OpenID.html">Federated Login</a>&quot;, to let any site enable their users to sign on by their Google accounts, without registrations.</p>
<p>This is really a good news, and for Java developers they can write some code to make the 3rd-part site to connect to Google. There are already lots of libaries that can be used in J2EE. However, after I do some evaluation of these libaries, I do not find a suitable libary. The well-known &quot;<a target="_blank" href="http://code.sxip.com/openid4java/">OpenID4Java</a>&quot;, is too large (46MB!), with dependencies on many other libaries. So I decided to write a small, but very lightweight libary to support OpenID 2.0 spec, called &quot;<a target="_blank" href="http://code.google.com/p/jopenid/">JOpenID</a>&quot;.</p>
<p>It is very small, about 50KB including both source &amp; binary. You can download from:</p>
<p><a target="_blank" href="http://code.google.com/p/jopenid/downloads/list">http://code.google.com/p/jopenid/downloads/list</a>.</p>
<p>It only depends <a target="_blank" href="http://commons.apache.org/logging/">commons-logging</a>!</p>
<p>Sample code is provided:</p>
<p><a target="_blank" href="http://code.google.com/p/jopenid/source/browse/trunk/JOpenId/src/com/javaeedev/openid/Main.java">http://code.google.com/p/jopenid/source/browse/trunk/JOpenId/src/com/javaeedev/openid/Main.java</a></p>
<p>It has been fully tested based on Google accounts. However, I think it also can support Yahoo! OpenID, but with little information provided by Yahoo! I do not test yet.</p>]]></description></item>
<item><title>About Michael Liao</title><link>http://michael-liao.appspot.com/it/4b1b19cb6f8749208a1c12f18243c729</link><dc:creator>Michael Liao</dc:creator><pubDate>Wed, 14 Oct 2009 03:26:32 +0000</pubDate><description><![CDATA[<p>Hi, I'm Michael Liao, a software engineer in China.</p>
<p>I have 5 years experiences in software development, especially Java and Python.</p>]]></description></item>
</channel></rss>