<?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>SolitaryGeek &#187; James</title>
	<atom:link href="http://solitarygeek.com/author/james/feed" rel="self" type="application/rss+xml" />
	<link>http://solitarygeek.com</link>
	<description>Technical Productivity</description>
	<lastBuildDate>Mon, 28 Jun 2010 03:54:10 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Switched the hosting provider</title>
		<link>http://solitarygeek.com/general/switched-the-hosting-provider</link>
		<comments>http://solitarygeek.com/general/switched-the-hosting-provider#comments</comments>
		<pubDate>Mon, 28 Jun 2010 03:45:15 +0000</pubDate>
		<dc:creator>James</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://solitarygeek.com/?p=532</guid>
		<description><![CDATA[<p>Dear readers,
Thanks for your patience. I&#8217;ve successfully moved my blog from my old hosting provider.</p>
<p>Still something might be broken. I&#8217;m working them out one by one. Thanks for <span style="color:#777"> . . . &#8594; Read More: <a href="http://solitarygeek.com/general/switched-the-hosting-provider">Switched the hosting provider</a></span>]]></description>
			<content:encoded><![CDATA[<p>Dear readers,<br />
Thanks for your patience. I&#8217;ve successfully moved my blog from my old hosting provider.</p>
<p>Still something might be broken. I&#8217;m working them out one by one. Thanks for your support.</p>
]]></content:encoded>
			<wfw:commentRss>http://solitarygeek.com/general/switched-the-hosting-provider/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Changing the hosting provider</title>
		<link>http://solitarygeek.com/uncategorized/hello-world</link>
		<comments>http://solitarygeek.com/uncategorized/hello-world#comments</comments>
		<pubDate>Fri, 25 Jun 2010 01:49:33 +0000</pubDate>
		<dc:creator>James</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://solitarygeek.com/blog/?p=1</guid>
		<description><![CDATA[<p>Dear readers,</p>
<p>Sorry for the down time. I&#8217;m in the process of changing to a different hosting provider. The blog should be up in a couple of days. <span style="color:#777"> . . . &#8594; Read More: <a href="http://solitarygeek.com/uncategorized/hello-world">Changing the hosting provider</a></span>]]></description>
			<content:encoded><![CDATA[<p>Dear readers,</p>
<p>Sorry for the down time. I&#8217;m in the process of changing to a different hosting provider. The blog should be up in a couple of days. <img src='http://solitarygeek.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://solitarygeek.com/uncategorized/hello-world/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Windows 7 RC Expiration</title>
		<link>http://solitarygeek.com/general/windows-7-rc-expiration</link>
		<comments>http://solitarygeek.com/general/windows-7-rc-expiration#comments</comments>
		<pubDate>Wed, 17 Feb 2010 02:01:59 +0000</pubDate>
		<dc:creator>James</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://www.solitarygeek.com/?p=525</guid>
		<description><![CDATA[<p>I received a mail from Microsoft today morning about Windows 7 expiration. Here is the essence of the mail:</p>
<p>It’s time to upgrade from the Windows 7 Release Candidate</p>
<p>While most people who tested Windows 7 have now moved to the final version, some are still running the Release Candidate. If you haven’t moved yet, it’s time to <span style="color:#777"> . . . &#8594; Read More: <a href="http://solitarygeek.com/general/windows-7-rc-expiration">Windows 7 RC Expiration</a></span>]]></description>
			<content:encoded><![CDATA[<p>I received a mail from Microsoft today morning about Windows 7 expiration. Here is the essence of the mail:</p>
<p><em><strong>It’s time to upgrade from the Windows 7 Release Candidate</strong></em></p>
<p><em>While most people who tested Windows 7 have now moved to the final version, some are still running the Release Candidate. If you haven’t moved yet, it’s time to replace the RC.</em></p>
<p><em>Starting on March 1, 2010 your PC will begin shutting down every two hours. Your work will not be saved during the shutdown.</em></p>
<p><em>The Windows 7 RC will fully expire on June 1, 2010. Your PC running the Windows 7 RC will continue shutting down every two hours and your files won’t be saved during shutdown. In addition, your wallpaper will change to a solid black background with a persistent message on your desktop. You’ll also get periodic notifications that Windows isn’t genuine. That means your PC may no longer be able to obtain optional updates or downloads requiring genuine Windows validation.</em></p>
<p><em>To avoid interruption, please reinstall a prior version of Windows or move to Windows 7. In either case, you’ll need to do a custom (clean) install to replace the RC. As with any clean installation, you’ll need to back up your data then reinstall your applications and restore the data. For more details about replacing the RC, see the Knowledge Base article KB 971767. For more information, visit the Window 7 Forum.</em></p>
<p><em>Thanks again for helping us test Windows 7.</em></p>
<p><em>The Windows 7 Team</em></p>
<p>This sounds very unprofessional and disappointing. Why shutdown the operating system every 2 hours? Why change the wall paper to &#8220;a solid black background with a persistent message on your desktop&#8221;?. Why display &#8220;periodic notifications that Windows isn’t genuine&#8221;?. Did we cheat Microsoft by running Windows 7 RC? Why not just expire gracefully with some friendly reminders.</p>
<p>What do you think about this?</p>
<p>You can get more information about Windows 7 RC expiration from <a href="http://support.microsoft.com/kb/971767">Microsoft Knowledge Base</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://solitarygeek.com/general/windows-7-rc-expiration/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>What Java Look and Feel do you use?</title>
		<link>http://solitarygeek.com/java/what-java-look-and-feel-do-you-use</link>
		<comments>http://solitarygeek.com/java/what-java-look-and-feel-do-you-use#comments</comments>
		<pubDate>Mon, 09 Nov 2009 15:10:32 +0000</pubDate>
		<dc:creator>James</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Polls]]></category>
		<category><![CDATA[look and feel]]></category>
		<category><![CDATA[swing]]></category>
		<category><![CDATA[themes]]></category>

		<guid isPermaLink="false">http://www.solitarygeek.com/?p=519</guid>
		<description><![CDATA[<p>Quite some time back, I read an article titled &#8220;20+ Free Look and Feel Libraries For Java Swing&#8220;. I have evaluated most of the libraries mentioned in that article. Personally, I  prefer the System look and feel that is bundled in the JRE. However, I like Substance, PGS and JGoodies as well. Which one do you <span style="color:#777"> . . . &#8594; Read More: <a href="http://solitarygeek.com/java/what-java-look-and-feel-do-you-use">What Java Look and Feel do you use?</a></span>]]></description>
			<content:encoded><![CDATA[<p>Quite some time back, I read an article titled &#8220;<a href="http://javabyexample.wisdomplug.com/web-programming/37-core-java/65-20-free-look-and-feel-libraries-for-java-swings.html">20+ Free Look and Feel Libraries For Java Swing</a>&#8220;. I have evaluated most of the libraries mentioned in that article. Personally, I  prefer the System look and feel that is bundled in the JRE. However, I like Substance, PGS and JGoodies as well. Which one do you use? Curious to know.</p>
Note: There is a poll embedded within this post, please visit the site to participate in this post's poll.
]]></content:encoded>
			<wfw:commentRss>http://solitarygeek.com/java/what-java-look-and-feel-do-you-use/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Developing A Simple Java Application With Spring</title>
		<link>http://solitarygeek.com/java/developing-a-simple-java-application-with-spring</link>
		<comments>http://solitarygeek.com/java/developing-a-simple-java-application-with-spring#comments</comments>
		<pubDate>Tue, 03 Nov 2009 16:12:23 +0000</pubDate>
		<dc:creator>James</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[spring]]></category>

		<guid isPermaLink="false">http://www.solitarygeek.com/java/java-spring/</guid>
		<description><![CDATA[<p>Introduction
Spring is a powerful application framework that can be used across any layer in your application. For example, you can use Spring to manage only your data access layer or you can use Spring to provide remote services for your swing client. In this article, I will explain how to get started with Spring by developing <span style="color:#777"> . . . &#8594; Read More: <a href="http://solitarygeek.com/java/developing-a-simple-java-application-with-spring">Developing A Simple Java Application With Spring</a></span>]]></description>
			<content:encoded><![CDATA[<p><strong>Introduction</strong><br />
Spring is a powerful application framework that can be used across any layer in your application. For example, you can use Spring to manage only your data access layer or you can use Spring to provide remote services for your swing client. In this article, I will explain how to get started with Spring by developing a simple java application.</p>
<p><strong>Requirements</strong><br />
1. Your favorite IDE<br />
2. <a href="http://www.springsource.org/download">Latest Spring framework</a>.</p>
<p>(Note: This article makes use of Spring framework 2.5.6 which is the current production release)</p>
<p><strong>The Application</strong><br />
We are going to develop a simple application that fetches and display the list of registered users. The application consists of just two interfaces, their implementation.</p>
<p><strong>The DAO layer</strong><br />
Let us now develop the DAO layer of the application. This layer consists of just one interface &#8220;UserDao&#8221; and it&#8217;s implementation &#8220;UserDaoImpl&#8221;. The interface consists of just one method named &#8220;getUsers()&#8221;. Let us quickly develop them.</p>
<p>Listing 1. UserDao</p>
<pre class="brush: java;">
package com.springapp.dao;
import java.util.Iterator;

/**
 *
 * @author James
 */
public interface UserDao
{
    Iterator&lt;String&gt; getUsers();
}
</pre>
<p>Listing 2. UserDaoImpl</p>
<pre class="brush: java;">

package com.springapp.dao;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

/**
 *
 * @author James
 */
public class UserDaoImpl implements UserDao
{
    public Iterator&lt;String&gt; getUsers()
    {
        List&lt;String&gt; users = new ArrayList&lt;String&gt;();
        users.add(&quot;Gavin King&quot;);
        users.add(&quot;Geertjan&quot;);
        users.add(&quot;Mike Keith&quot;);
        users.add(&quot;James&quot;);
        return users.iterator();
    }
}
</pre>
<p>Nothing fancy here. The implementation is pretty straight forward, though in a real environment you might fetch those details from the database using ORM frameworks like JPA.</p>
<p><strong>The Service Layer</strong></p>
<p>We will encapsulate the service layer from the dao implementaion by writing code against the interface UserDao. We will follow the same pattern we used in developing the dao layer and write the interface UserService and it&#8217;s implementation UserServiceImpl.</p>
<p>Listing 3. UserService</p>
<pre class="brush: java;">

package com.springapp.service;

import java.util.Iterator;

/**
 *
 * @author James
 */
public interface UserService
{
    Iterator&lt;String&gt; getUsers();
}
</pre>
<p>Listing 4. UserServiceImpl</p>
<pre class="brush: java;">

package com.springapp.service;

import com.springapp.dao.UserDao;
import java.util.Iterator;

/**
 *
 * @author James
 */
public class UserServiceImpl implements UserService
{
    private UserDao userDao;

    public Iterator&lt;String&gt; getUsers()
    {
        return userDao.getUsers();
    }

    public void setUserDao(UserDao userDao)
    {
        this.userDao = userDao;
    }
}
</pre>
<p>Kindly notice that both the service layer classes and dao layer classes are Spring agnostic. That&#8217;s the beauty of Spring. Spring is less invasive. Most of the application code can be developed without knowing anything about Spring.</p>
<p><strong>The Client</strong></p>
<p>Now we need someone to make use of our service layer and we will waste no time in developing the client for our service. We can just write a junit test class to invoke our service but I prefer to write a simple java class to be the client. Though our client will be a simple POJO class, you can easily replace it with a Swing or Web front end. Enough talking, let us dive into action! We will first develop our client as a normal java class without using Spring.</p>
<p><em>Standard Client</em></p>
<p>Listing 5. StandardUserServiceClient</p>
<pre class="brush: java;">

package com.springapp;

import com.springapp.dao.UserDao;
import com.springapp.dao.UserDaoImpl;
import com.springapp.service.UserServiceImpl;
import java.util.Iterator;

/**
 *
 * @author James
 */
public class StandardUserServiceClient
{

    private UserServiceImpl userService;

    public StandardUserServiceClient()
    {
        userService = new UserServiceImpl();
        UserDao userDao = new UserDaoImpl();
        userService.setUserDao(userDao);
    }

    private void fetchUsers()
    {
        Iterator&lt;String&gt; users = userService.getUsers();
        while (users.hasNext())
        {
            System.out.println(users.next());
        }
    }

    public static void main(String[] args)
    {
        StandardUserServiceClient client = new StandardUserServiceClient();
        client.fetchUsers();
    }
}
</pre>
<p>Hmm, there you can see our client code is &#8220;coupled&#8221; tightly with the service and dao implementations. That&#8217;s where Spring comes to our rescue. Spring will dynamically &#8220;inject&#8221; the implemenations so our application will remain &#8220;loosely&#8221; coupled.</p>
<p><em>Spring Client</em></p>
<p>But how will Spring know about our implementations? We need to inform Spring a little about our application and define the &#8220;hotspots&#8221; where it can dynamically &#8220;inject&#8221; the dependencies or implementations. Spring expects these details in a configuration file and let us quickly write that. Create a package called &#8220;resources&#8221; and create a xml file called &#8220;applicationContext.xm&#8221; inside it.</p>
<p>Listing 6. applicationContext.xml</p>
<pre class="brush: xml;">

&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;beans xmlns=&quot;http://www.springframework.org/schema/beans&quot;
 xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
 xsi:schemaLocation=&quot;http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd&quot;&gt;

 &lt;bean id=&quot;userDao&quot; class=&quot;com.springapp.dao.UserDaoImpl&quot;&gt;
 &lt;/bean&gt;

 &lt;bean id=&quot;userService&quot; class=&quot;com.springapp.service.UserServiceImpl&quot;&gt;
     &lt;property name=&quot;userDao&quot; ref=&quot;userDao&quot;/&gt;
 &lt;/bean&gt;
&lt;/beans&gt;
</pre>
<p>In the &#8220;applicationContext.xml&#8221; file we defiend two beans named &#8220;userDao&#8221; and &#8220;userService&#8221;. We also specified their implementations using the &#8220;class&#8221; attribute. Also notice that we are setting the property &#8220;userDao&#8221;  in the &#8220;UserServiceImpl&#8221; class with &#8220;UserDaoImpl&#8221; by referencing it&#8217;s name &#8220;userDao&#8221;. Pretty straighforward!</p>
<p>Now it&#8217;s time to churn out our Spring client.</p>
<p>Listing 7. SpringUserServiceClient</p>
<pre class="brush: java;">

package com.springapp;

import com.springapp.service.UserService;
import java.util.Iterator;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 *
 * @author James
 */
public class SpringUserServiceClient
{
    private UserService userService;

    public SpringUserServiceClient()
    {
        //initialize the spring container
        ApplicationContext context = new ClassPathXmlApplicationContext(&quot;resources/applicationContext.xml&quot;);
        userService = (UserService) context.getBean(&quot;userService&quot;);
    }

    private void fetchUsers()
    {
        Iterator&lt;String&gt; users = userService.getUsers();
        while(users.hasNext())
        {
            System.out.println(users.next());
        }
    }

    public static void main(String[] args)
    {
        SpringUserServiceClient client = new SpringUserServiceClient();
        client.fetchUsers();
    }
}
</pre>
<p>A couple of details about this class:</p>
<ul>
<li>The ApplicationContext interface helps us to plug into the Spring container and lookup the classes we need by using the name we defined in the xml file.</li>
<li>There are many implementataions of ApplicationContext available in Spring. One of the most widely used implementation is &#8220;ClassPathXmlApplicationContext&#8221;. It is used to load Spring configuration files found in classpath.</li>
</ul>
<p>As seen from Listing 7, Spring helps us to program to interfaces and develop loosely coupled applications. As a result, applications become more testable as there are no external dependencies like application server. It is also very easy to switch the implementations effortlessly. For example, in our sample application you can easily write a UserDaoMockImpl and use it in your test cases effortlessly.</p>
<p><strong>Project Structure</strong></p>
<p>Here is the complete application looks like:</p>
<p><strong><img class="alignnone size-full wp-image-515" title="screenshot1" src="http://solitarygeek.com/blog/wp-content/uploads/2009/11/screenshot1.png" alt="screenshot1" width="302" height="310" /><br />
</strong></p>
<div class="zemanta-pixie"><img class="zemanta-pixie-img" src="http://img.zemanta.com/pixy.gif?x-id=d7d85c06-7c20-8a72-ae33-ec6bc5f32317" alt="" /></div>
]]></content:encoded>
			<wfw:commentRss>http://solitarygeek.com/java/developing-a-simple-java-application-with-spring/feed</wfw:commentRss>
		<slash:comments>20</slash:comments>
		</item>
		<item>
		<title>Developing A Simple Pluggable Java Application</title>
		<link>http://solitarygeek.com/java/a-simple-pluggable-java-application</link>
		<comments>http://solitarygeek.com/java/a-simple-pluggable-java-application#comments</comments>
		<pubDate>Sun, 20 Sep 2009 15:23:12 +0000</pubDate>
		<dc:creator>James</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[NetBeans]]></category>
		<category><![CDATA[application]]></category>
		<category><![CDATA[pluggable]]></category>
		<category><![CDATA[plugins]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[tools]]></category>

		<guid isPermaLink="false">http://www.solitarygeek.com/java/a-simple-pluggable-java-application/</guid>
		<description><![CDATA[<p>Most of the applications we use on daily basis are pluggable. Popular applications like Firefox, Eclipse, NetBeans, JEdit, Wordpress, Hudson are all pluggable. In fact, pluggability has played a major part in the success of most of these applications. Why not make the Java applications we develop pluggable as well? Yes, we get pluggability out of <span style="color:#777"> . . . &#8594; Read More: <a href="http://solitarygeek.com/java/a-simple-pluggable-java-application">Developing A Simple Pluggable Java Application</a></span>]]></description>
			<content:encoded><![CDATA[<p>Most of the applications we use on daily basis are pluggable. Popular applications like Firefox, Eclipse, NetBeans, JEdit, Wordpress, Hudson are all pluggable. In fact, pluggability has played a major part in the success of most of these applications. Why not make the Java applications we develop pluggable as well? Yes, we get pluggability out of the box, if our applications are based on a rich client platform like NetBeans or Eclipse. But for some reasons if you decide not to use those platforms, it doesn&#8217;t mean that they should not be pluggable. In this article, we will learn how to write a simple pluggable application that will load it&#8217;s plugins dynamically.</p>
<p><strong>The API<br />
</strong>First, let us define a plugin interface that should be implemented by all the plugins of our application. We are going to keep it very simple. Create a project called &#8220;plugin-api&#8221; in your favorite IDE and create the interface &#8220;ApplicationPlugin&#8221;.</p>
<p><img style="max-width: 800px;" src="http://solitarygeek.com/blog/wp-content/uploads/2009/09/screenshot1-p2.png" alt="" /></p>
<pre class="brush: java;">

package com.pluggableapp.plugins.api;

public interface ApplicationPlugin
{
    String getName();
    void init();
}
</pre>
<p><span id="more-464"></span></p>
<p><strong>The Plugins</strong></p>
<p>Writing the plugins now is very easy. Our plugins need to implement the plugin interface and follow a simple convention to make it easy for our applications to find them later. Create a project called &#8220;plugin-a&#8221; and develop our first plugin.</p>
<pre class="brush: java;">

package com.pluggableapp.plugins;

import com.pluggableapp.plugins.api.ApplicationPlugin;
import java.util.logging.Logger;

public class PluginA implements ApplicationPlugin
{
    private static Logger logger = Logger.getLogger(PluginA.class.getName());

    public String getName()
    {
        return &quot;Plugin A&quot;;
    }

    public void init()
    {
        logger.info(getName() + &quot; initialized!&quot;);
    }
}
</pre>
<p>Now create a directory called &#8220;META-INF/services&#8221; inside the source directory and create a file with the name &#8220;com.pluggableapp.plugins.api.ApplicationPlugin&#8221; (This is the fully qualified name of the plugin interface). The file should contain the name of the actual plugin inside it. In our case, the text is &#8220;com.pluggableapp.plugins.PluginA&#8221;.</p>
<p><img style="max-width: 800px;" src="http://solitarygeek.com/blog/wp-content/uploads/2009/09/screenshot4-p.png" alt="" /></p>
<p>Repeat these steps to create PluginB.</p>
<p><strong>The Application</strong></p>
<p>It&#8217;s time to create the application that will consume the plugins we created. First let us create a class to add the plugin jars to the classpath dynamically.</p>
<pre class="brush: java;">

package com.pluggableapp;

import java.io.File;
import java.io.IOException;
import java.lang.reflect.Method;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.logging.Logger;

public class ClasspathUtils
{

 private static Logger logger = Logger.getLogger(ClasspathUtils.class.getName());
 // Parameters
 private static final Class[] parameters = new Class[]
 {
     URL.class
 };

 /**
 * Adds the jars in the given directory to classpath
 * @param directory
 * @throws IOException
 */
 public static void addDirToClasspath(File directory) throws IOException
 {
     if (directory.exists())
     {
         File[] files = directory.listFiles();
         for (int i = 0; i &lt; files.length; i++)
         {
             File file = files[i];
             addURL(file.toURI().toURL());
         }
     }
     else
     {
         logger.warning(&quot;The directory \&quot;&quot; + directory + &quot;\&quot; does not exist!&quot;);
     }
}

 /**
 * Add URL to CLASSPATH
 * @param u URL
 * @throws IOException IOException
 */
 public static void addURL(URL u) throws IOException
 {
     URLClassLoader sysLoader = (URLClassLoader) ClassLoader.getSystemClassLoader();
     URL urls[] = sysLoader.getURLs();
     for (int i = 0; i &lt; urls.length; i++)
     {
         if (urls[i].toString().equalsIgnoreCase(u.toString()))
         {
             logger.info(&quot;URL &quot; + u + &quot; is already in the CLASSPATH&quot;);
             return;
         }
     }
     Class sysclass = URLClassLoader.class;
     try
     {
         Method method = sysclass.getDeclaredMethod(&quot;addURL&quot;, parameters);
         method.setAccessible(true);
         method.invoke(sysLoader, new Object[]
         {
             u
         });
     } catch (Throwable t)
     {
         t.printStackTrace();
         throw new IOException(&quot;Error, could not add URL to system classloader&quot;);
     }
  }
}
</pre>
<p>Now create an interface called &#8220;PluginService&#8221; to define the methods needed to load and initialize the plugins.</p>
<pre class="brush: java;">

package com.pluggableapp;

import com.pluggableapp.plugins.api.ApplicationPlugin;
import java.util.Iterator;

public interface PluginService
{
    Iterator&lt;ApplicationPlugin&gt; getPlugins();
    void initPlugins();
}
</pre>
<p>As of version 1.6, the Java runtime ships with a class called &#8220;ServiceLoader&#8221; to easily find and load plugins. Let us now write a implementation called &#8220;StandardPluginService&#8221; and make use of the facilities built into the java runtime.</p>
<pre class="brush: java;">

package com.pluggableapp;

import com.pluggableapp.PluginService;
import com.pluggableapp.plugins.api.ApplicationPlugin;
import java.util.Iterator;
import java.util.ServiceLoader;
import java.util.logging.Logger;

public class StandardPluginService implements PluginService
{
    private static StandardPluginService pluginService;
    private ServiceLoader&lt;ApplicationPlugin&gt; serviceLoader;
    private Logger logger = Logger.getLogger(getClass().getName());

    private StandardPluginService()
    {
        //load all the classes in the classpath that have implemented the interface
        serviceLoader = ServiceLoader.load(ApplicationPlugin.class);
    }

    public static StandardPluginService getInstance()
    {
        if(pluginService == null)
        {
            pluginService = new StandardPluginService();
        }
        return pluginService;
    }

    public Iterator&lt;ApplicationPlugin&gt; getPlugins()
    {
        return serviceLoader.iterator();
    }

    public void initPlugins()
    {
        Iterator&lt;ApplicationPlugin&gt; iterator = getPlugins();
        if(!iterator.hasNext())
        {
            logger.info(&quot;No plugins were found!&quot;);
        }
        while(iterator.hasNext())
        {
            ApplicationPlugin plugin = iterator.next();
            logger.info(&quot;Initializing the plugin &quot; + plugin.getName());
            plugin.init();
        }
    }
}
</pre>
<p>Feel free to write your own implementation if needed. For example you can easily write an implementation based on the NetBeans API.</p>
<p>Write a factory class named &#8220;PluginServiceFactory&#8221; to create &#8220;PluginService&#8221; objects.</p>
<pre class="brush: java;">

package com.pluggableapp;

import com.pluggableapp.*;
import com.pluggableapp.StandardPluginService;
import com.pluggableapp.PluginService;
import java.io.File;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;

public class PluginServiceFactory
{
    public static PluginService createPluginService()
    {
        addPluginJarsToClasspath();
        return StandardPluginService.getInstance();
    }

    private static void addPluginJarsToClasspath()
    {
        try
        {
            //add the plugin directory to classpath
            ClasspathUtils.addDirToClasspath(new File(&quot;plugins&quot;));
        } catch (IOException ex)
        {
            Logger.getLogger(PluginServiceFactory.class.getName()).log(
                Level.SEVERE, null, ex);
        }
    }
}
</pre>
<p>That&#8217;s it. All we need to do now is to write a class that will invoke the &#8220;PluginServiceFactory&#8221;.</p>
<pre class="brush: java;">

package com.pluggableapp;

import com.pluggableapp.plugins.api.ApplicationPlugin;
import java.util.Iterator;
import java.util.logging.Logger;

public class Main
{

    private static Logger logger = Logger.getLogger(Main.class.getName());

    /**
    * @param args the command line arguments
    */
    public static void main(String[] args)
    {
        loadPlugins();
    }

    private static void loadPlugins()
    {
        PluginService pluginService = PluginServiceFactory.createPluginService();
        pluginService.initPlugins();
    }
}
</pre>
<p>Before we build and see the application in action, create a directory called &#8220;plugins&#8221; and put all plugin jars there.</p>
<p><img style="max-width: 800px;" src="http://solitarygeek.com/blog/wp-content/uploads/2009/09/screenshot3-p1.png" alt="" /></p>
<p>And this is what you might see when you run our pluggable application.</p>
<p><img style="max-width: 800px;" src="http://solitarygeek.com/blog/wp-content/uploads/2009/09/screenshot2-p1.png" alt="" /></p>
<p>Now feel free to create as many plugins you want to write and just drop them in the &#8220;plugins&#8221; directory and restart the &#8220;pluggable&#8221; application to see your &#8220;home grown&#8221; plugins in action!</p>
<p><strong>Resources</strong></p>
<p><a href="http://java.sun.com/developer/technicalArticles/javase/extensible/index.html">Creating Extensible Applications With the Java Platform</a> &#8211; <em>John O&#8217;Conner</em></p>
<p><a href="http://twit88.com/blog/2007/10/07/develop-a-java-plugin-framework/">Developing a Java Plugin Framework </a></p>
<p><a href="http://java.dzone.com/news/how-create-pluggable-photo-alb">How to Create a Pluggable Photo Album in Java</a> &#8211; <em>Geertjan</em></p>
<div class="zemanta-pixie"><img class="zemanta-pixie-img" src="http://img.zemanta.com/pixy.gif?x-id=d7d85c06-7c20-8a72-ae33-ec6bc5f32317" alt="" /></div>
]]></content:encoded>
			<wfw:commentRss>http://solitarygeek.com/java/a-simple-pluggable-java-application/feed</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>NautilusSVN &#8211; The TortoiseSVN for Linux users</title>
		<link>http://solitarygeek.com/linux/linux-version-control-svn-subversion-nautilus-nautilussvn-ubuntu</link>
		<comments>http://solitarygeek.com/linux/linux-version-control-svn-subversion-nautilus-nautilussvn-ubuntu#comments</comments>
		<pubDate>Sat, 19 Sep 2009 09:46:13 +0000</pubDate>
		<dc:creator>James</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Subversion]]></category>
		<category><![CDATA[Version Control]]></category>
		<category><![CDATA[explorer]]></category>
		<category><![CDATA[filebrowser]]></category>
		<category><![CDATA[filesystem]]></category>
		<category><![CDATA[nautilus]]></category>
		<category><![CDATA[nautilussvn]]></category>
		<category><![CDATA[svn]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://www.solitarygeek.com/linux/linux-version-control-svn-subversion-nautilus-nautilussvn-ubuntu/</guid>
		<description><![CDATA[<p>TortoiseSVN is the dominant Subversion client for Windows. While there so many Subversion clients available, what makes TortoiseSVN special is it&#8217;s smooth integration with the Windows Explorer. As a result, working with your Subversion repository becomes super easy. When I switched completely from Windows to Ubuntu Linux, TortoiseSVN is one of the few applications I missed. <span style="color:#777"> . . . &#8594; Read More: <a href="http://solitarygeek.com/linux/linux-version-control-svn-subversion-nautilus-nautilussvn-ubuntu">NautilusSVN &#8211; The TortoiseSVN for Linux users</a></span>]]></description>
			<content:encoded><![CDATA[<p>TortoiseSVN is the <a href="http://www.solitarygeek.com/version-control/poll-what-is-your-favourite-subversion-client/">dominant Subversion client</a> for Windows. While there so many Subversion clients available, what makes TortoiseSVN special is it&#8217;s smooth integration with the Windows Explorer. As a result, working with your Subversion repository becomes super easy. When I switched completely from Windows to Ubuntu Linux, TortoiseSVN is one of the few applications I missed. Not anymore!</p>
<p><a href="http://code.google.com/p/nautilussvn"><img class="alignnone" title="NautilusSVN" src="http://code.google.com/p/nautilussvn/logo?logo_id=1238136127" alt="" width="48" height="45" /></a></p>
<p>As I <a href="http://www.solitarygeek.com/linux/most-popular-subversion-clients/">mentioned</a> earlier, <a href="http://code.google.com/p/nautilussvn/">NautilusSVN</a> attempts to be the TortoiseSVN for Linux. It looks like NautilusSVN is not yet available in the Ubuntu repositories but fortunately they had a <a href="http://code.google.com/p/nautilussvn/wiki/Installation">&#8220;deb&#8221; package</a> which I downloaded.</p>
<p>Though their documentation specifies that you don&#8217;t need anything extra, I had to install a few packages before proceeding to NautilusSVN. I installed the dependencies using the following command,</p>
<pre lang="bash">sudo apt-get install python-nautilus python-svn python-configobj</pre>
<p>Then I installed the &#8220;deb&#8221; package using the command,</p>
<pre lang="bash">sudo dpkg -i nautilussvn*.deb</pre>
<p>I had to just close and open Nautilus to see NautilusSVN in action.</p>
<p><img style="max-width: 800px;" src="http://solitarygeek.com/blog/wp-content/uploads/2009/09/screenshot1-p1.png" alt="" /></p>
<p>All other SVN tasks can be performed by simply doing a &#8220;right click&#8221; at appropriate places in your working copy.</p>
<p><img style="max-width: 800px;" src="http://solitarygeek.com/blog/wp-content/uploads/2009/09/screenshot2-p.png" alt="" /></p>
<p>NautilusSVN has a commit window quite similar to TortoiseSVN.</p>
<p><img style="max-width: 800px;" src="http://solitarygeek.com/blog/wp-content/uploads/2009/09/screenshot3-p.png" alt="" width="610" height="614" /></p>
<p>NautilusSVN provides decent support to create branch/tag, move, change properties, view revisions etc. But there is no &#8220;Repository Browser&#8221; yet and the &#8220;Revert&#8221; option needs more polish. Also I noticed that as my working copy grew, NautilusSVN seems to slow down Nautilus. This can be a major downside which might prevent the adoption of this otherwise great tool. But NautilusSVN is still in beta and I hope these issues will be resolved shortly.</p>
<div class="zemanta-pixie"><img class="zemanta-pixie-img" src="http://img.zemanta.com/pixy.gif?x-id=64d12121-8a5e-8a61-9398-43e2f6fcd6e0" alt="" /></div>
]]></content:encoded>
			<wfw:commentRss>http://solitarygeek.com/linux/linux-version-control-svn-subversion-nautilus-nautilussvn-ubuntu/feed</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>What UML Tools do you use?</title>
		<link>http://solitarygeek.com/general/what-uml-tools-do-you-use</link>
		<comments>http://solitarygeek.com/general/what-uml-tools-do-you-use#comments</comments>
		<pubDate>Wed, 26 Aug 2009 13:30:58 +0000</pubDate>
		<dc:creator>James</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[NetBeans]]></category>
		<category><![CDATA[Polls]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[opinion]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[technology]]></category>
		<category><![CDATA[uml]]></category>
		<category><![CDATA[uml-tools]]></category>
		<category><![CDATA[umltools]]></category>

		<guid isPermaLink="false">http://www.solitarygeek.com/?p=425</guid>
		<description><![CDATA[<p>Recently I read the article &#8220;Free UML tools&#8221; which explains about the various free UML tools available. That article made me think &#8220;What UML tool do people actually use?&#8221;. Over the years, I have used tools like Microsoft Visio, ArgoUML, NetBeans UML, StarUML and finally settled with JUDE. How about you? What UML tools do you <span style="color:#777"> . . . &#8594; Read More: <a href="http://solitarygeek.com/general/what-uml-tools-do-you-use">What UML Tools do you use?</a></span>]]></description>
			<content:encoded><![CDATA[<p>Recently I read the article &#8220;<a href="http://www.certpal.com/blogs/2009/08/free-uml-tools/">Free UML tools</a>&#8221; which explains about the various free UML tools available. That article made me think &#8220;What UML tool do people actually use?&#8221;. Over the years, I have used tools like Microsoft Visio, <a href="http://argouml.tigris.org/">ArgoUML</a>, <a href="http://www.netbeans.org/features/uml/">NetBeans UML</a>, <a href="http://staruml.sourceforge.net/">StarUML</a> and finally settled with <a href="http://jude.change-vision.com/jude-web/product/community.html">JUDE</a>. How about you? What UML tools do you use? Some of you might use more than one tool (at work, at home etc), so feel free to choose all the options applicable.</p>
Note: There is a poll embedded within this post, please visit the site to participate in this post's poll.
]]></content:encoded>
			<wfw:commentRss>http://solitarygeek.com/general/what-uml-tools-do-you-use/feed</wfw:commentRss>
		<slash:comments>23</slash:comments>
		</item>
		<item>
		<title>Readers choice: Most popular Subversion clients</title>
		<link>http://solitarygeek.com/linux/most-popular-subversion-clients</link>
		<comments>http://solitarygeek.com/linux/most-popular-subversion-clients#comments</comments>
		<pubDate>Tue, 25 Aug 2009 15:54:15 +0000</pubDate>
		<dc:creator>James</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[NetBeans]]></category>
		<category><![CDATA[Subversion]]></category>
		<category><![CDATA[Version Control]]></category>
		<category><![CDATA[opinion]]></category>
		<category><![CDATA[svn]]></category>
		<category><![CDATA[svnclients]]></category>
		<category><![CDATA[technology]]></category>
		<category><![CDATA[tortoisesvn]]></category>

		<guid isPermaLink="false">http://www.solitarygeek.com/linux/subversion-svn-svnclients-tortoisesvn-technology-linux-windows/</guid>
		<description><![CDATA[<p>Subversion is a very popular version control system. As a result, subversion has a wide array of client tools which makes life difficult for us, the users. So we wanted to know what our readers actually use and here is the summary of their opinions.</p>
<p>Not surprisingly, close to 50% of them use the popular TortoiseSVN as <span style="color:#777"> . . . &#8594; Read More: <a href="http://solitarygeek.com/linux/most-popular-subversion-clients">Readers choice: Most popular Subversion clients</a></span>]]></description>
			<content:encoded><![CDATA[<p>Subversion is a very popular version control system. As a result, subversion has a <a href="http://en.wikipedia.org/wiki/Comparison_of_Subversion_clients">wide array of client tools</a> which makes life difficult for us, the users. So we <a href="http://www.solitarygeek.com/version-control/poll-what-is-your-favourite-subversion-client/">wanted to know</a> what our readers actually use and here is the summary of their opinions.</p>
<p><strong>Not surprisingly, close to 50% of them</strong> use the popular <a href="http://tortoisesvn.tigris.org/">TortoiseSVN</a> as their client.</p>
<p><img class="alignnone" src="http://tortoisesvn.tigris.org/tortoisesvn_logo_hor468x64.PNG" alt="" width="468" height="64" /></p>
<p>The only limiting factor of this wildly popular tool is that it is available only for Windows.</p>
<p><strong>Surprisingly, the second most popular choice</strong> for users is their IDE (like Eclipse, NetBeans etc). 30% users are satisfied with the support provided by their IDE. I hope this user base will only increase in future as the IDEs offer more sophisticated support not just for Subversion but also for other popular version control systems.</p>
<p><a href="http://eclipse.org"><img class="alignnone" title="Eclipse" src="http://eclipse.org/eclipse.org-common/themes/Nova/images/eclipse.png" alt="" width="171" height="91" /></a> <a href="http://netbeans.org"><img class="alignnone size-full wp-image-420" title="NetBeans" src="http://solitarygeek.com/blog/wp-content/uploads/2009/08/netbeans6ns0.png" alt="NetBeans" width="134" height="134" /></a></p>
<p>But there are some limiting factor in using the IDE as the Subversion client. The support, in most cases (atleast in NetBeans), is limited to only the projects you are working from the IDE. That&#8217;s where the third popular Subversion client comes into picture.</p>
<p><strong>The third choice</strong> of the users is the <a href="http://subversion.tigris.org/">Subversion command line client</a> which comes bundled with Subversion.</p>
<p><a href="http://subversion.tigris.org"><img class="alignnone" title="Subversion" src="http://subversion.tigris.org/images/subversion_logo_hor-468x64.png" alt="" width="468" height="64" /></a></p>
<p>To be frank, the command line client is what all you need with the only limiting factor being it&#8217;s &#8220;<em>command line</em>&#8221; nature <img src='http://solitarygeek.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  . Whenever the tool you use falls short in certain scenarios, the command line client can be your life saver. 14% of users vow by the Subversion command line client and I believe most of them are Linux users.</p>
<p><strong><a href="http://rapidsvn.tigris.org/">RapidSVN</a> comes at the distant fourth</strong> garnering only 5% of votes.</p>
<p><a href="http://rapidsvn.tigris.org"><img class="alignnone" title="RapidSVN" src="http://rapidsvn.tigris.org/logo.png" alt="" width="156" height="129" /></a></p>
<p><strong>Going by the comments,</strong> <a href="http://www.syntevo.com/smartsvn/">SmartSVN</a> is preferred by a couple of users and so is nautilus scripts, <a href="http://code.google.com/p/nautilussvn/">nautilussvn</a>, <a href="http://www.kernel.org/pub/software/scm/git/docs/git-svn.html">git-svn</a>, <a href="http://kdesvn.alwins-world.de/">kdesvn</a>.</p>
<p>I have used SmartSVN for a while and I would say it&#8217;s almost on par with TortoiseSVN. The biggest advantage of SmartSVN is it&#8217;s cross platform nature while the biggest drawback is that it&#8217;s not opensource. <a href="http://code.google.com/p/nautilussvn/">NautilusSVN</a> has big potential as it attempts to become the TortoiseSVN for linux.</p>
<p><a href="http://code.google.com/p/nautilussvn/"><img class="alignnone" title="NautilusSVN" src="http://code.google.com/p/nautilussvn/logo?logo_id=1238136127" alt="" width="48" height="45" /></a></p>
<p>Thanks for everyone who participated in the poll &#8220;<a href="http://www.solitarygeek.com/version-control/poll-what-is-your-favourite-subversion-client/">What is your favourite Subversion client?</a>&#8221;</p>
<p>If you use any other Subversion client, please let us know.</p>
<p>Read more about Subversion at the dedicated <a href="http://www.solitarygeek.com/category/version-control/subversion/">SolitaryGeek Subversion category</a>.</p>
<div class="zemanta-pixie"><img class="zemanta-pixie-img" src="http://img.zemanta.com/pixy.gif?x-id=26d13b99-e894-817d-8422-0aafea0190c6" alt="" /></div>
]]></content:encoded>
			<wfw:commentRss>http://solitarygeek.com/linux/most-popular-subversion-clients/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Five different uses of Java Applets</title>
		<link>http://solitarygeek.com/java/five-different-uses-of-java-applets</link>
		<comments>http://solitarygeek.com/java/five-different-uses-of-java-applets#comments</comments>
		<pubDate>Sat, 22 Aug 2009 09:54:42 +0000</pubDate>
		<dc:creator>James</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[applets]]></category>
		<category><![CDATA[applications]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[tech]]></category>
		<category><![CDATA[technology]]></category>
		<category><![CDATA[tools]]></category>

		<guid isPermaLink="false">http://www.solitarygeek.com/java/java-technology-tech-computers-software-applications-tools-applets/</guid>
		<description><![CDATA[<p>In a world where everyone is using technologies like Flash, Silverlight etc to present rich content, are Java Applets still used? Are they still relevant? The answer is &#8211; &#8220;Yes&#8221;. Apart from being used primarily for playing online games, Java Applets are still used in many different ways. Here I would like to highlight a few <span style="color:#777"> . . . &#8594; Read More: <a href="http://solitarygeek.com/java/five-different-uses-of-java-applets">Five different uses of Java Applets</a></span>]]></description>
			<content:encoded><![CDATA[<p>In a world where everyone is using technologies like Flash, Silverlight etc to present rich content, are Java Applets still used? Are they still relevant? The answer is &#8211; &#8220;Yes&#8221;. Apart from being used primarily for playing online games, Java Applets are still used in many different ways. Here I would like to highlight a few applications that put Applets to good use.</p>
<p><strong>1. Online Office Suite</strong><br />
<a href="http://thinkfree.com">ThinkFree</a> is a very popular and professional online office suite <a href="http://en.wikipedia.org/wiki/ThinkFree_Office">based on Java Applet and Ajax</a>.</p>
<p><img style="max-width: 800px;" src="http://solitarygeek.com/blog/wp-content/uploads/2009/08/screenshot2-p1.png" alt="" /></p>
<p><strong>2. Virtualization</strong><br />
<a href="http://www-jpc.physics.ox.ac.uk/home_home.html">JPC</a> or <a href="http://www-jpc.physics.ox.ac.uk/home_home.html">Java PC Emulator</a> is a pure java based virtualization software that can be used to boot your virtual computers right inside the browser. Yes they run as &#8220;Java Applets&#8221; inside the browser.</p>
<p><strong>3. Remote Desktop Viewer</strong><br />
Products like <a href="http://www.tightvnc.com/">TightVNC</a> and <a href="http://www.uvnc.com/">UltraVNC</a> provide a java applet based client to view remote desktops.</p>
<p><strong>4. (Web) Operating System<br />
</strong><a href="http://icloud.com">iCloud</a>, is an web operating sytem that makes use of XML and Java Applet Technology (atleast for Firefox).</p>
<p><strong>5. File Upload</strong></p>
<p><a href="http://www.facebook.com">Facebook</a> uses a beautifully designed Java Applet to upload photos to facebook photo albums.<br />
<a href="http://net2ftp.com">net2ftp</a> is a web based ftp client that makes use of tiny Java Applet to &#8220;drag and drop&#8221; files from local computer to the browser and upload them to the remote ftp server.</p>
<p><img style="max-width: 800px;" src="http://solitarygeek.com/blog/wp-content/uploads/2009/08/screenshot1-p.png" alt="" /></p>
<p>If you have come across any website that make use of Java Applets, please share your thoughts in the comments.</p>
]]></content:encoded>
			<wfw:commentRss>http://solitarygeek.com/java/five-different-uses-of-java-applets/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
