Archive

Author Archive

Commons email

November 3rd, 2009 CertPal No comments

There are many apache commons projects out there that save your time either directly or indirectly. Some of the well known commons projects are

  • Commons beanutils – Services wrapped around java beans.
  • Commons digester – XML to java mappings
  • Commons lang – Helper utilities for the java.lang API
  • Commons logging – A generic logging implementation

There are other commons implementations that can save your time, but you are probably not using them. One of them is commons email. Commons email provides a facade to the underlying java mail services that come from mail.jar. Sending an email using mail.jar is not that difficult, but when you use commons email it is downright simple

Check out a sample program that sends a simple email

1
2
3
4
5
6
7
SimpleEmail email = new SimpleEmail();
email.setHostName("mail.myserver.com");
email.addTo("jdoe@somewhere.org", "John Doe");
email.setFrom("me@apache.org", "Me");
email.setSubject("Test message");
email.setMsg("This is a simple test of commons-email");
email.send();

Thats it. Use the HTMLEmail class to send HTML based emails. You can read more about the commons email API from their user guide. The project is active and should simplify the parts of your application that send email.

Categories: java Tags: , ,

More on google wave

October 30th, 2009 CertPal No comments

Things got even better today when we got our second google wave account for the same user. mmm wavelogowait… a second google wave account ? Yep. Google wave is split into googlewave.com accounts for normal end users and the wavesandbox.com accounts for developers and geeks. It is interesting to note the differences.

Googlewave:

  • Is a little less buggier. It has more features like read only waves that the sandbox is missing.
  • Linked to your existing gmail and docs. All your existing contacts can be… contacted.
  • Has this cool green box that opens up for active wave conversations.
  • No debugging or anything technically related.
  • Number of invites allowed are varied. If you requested for the account yourself, you get anywhere from 8 – 22 invites (from what I have heard so far).

Wave sandbox

  • Pretty buggy and is a developer’s paradise.
Categories: Web Tags: ,

Wireframe tools

October 27th, 2009 CertPal 2 comments

There are times when you need to display wireframes of your application for internal discussions / presentations etc. Some online applications allow you to draw a wireframe in no time. Here are a few of them

Balsamiq mockups:

balasmiq_mock

Creately:

creately_mock

Fore UI:

foreui_mock

Hot gloo:

hotgloo

iplotz:

iplotz_mock

Pencil: Mozilla firefox plugin based

pencil_mock

Axure:

azure_mock

Each application has its own style of doing the mockup. Some use an informal approach. Other advanced ones let you click and see the results then and there. There are other tools out there that also run on desktops and IDEs like eclipse, Netbeans etc if you are looking for an offline solution.

Categories: Web Tags: , ,

Google wave java robot overview

October 22nd, 2009 CertPal 3 comments

appspotAs most of you are aware by now, developers can write java robots that can aid a conversation that happens in google wave. A conversation is a wavelet and each reply in this wavelet is called a blip. There are some ‘getting started’ tutorials available out there that are of great help. These links should help you

Official google wave guide
Google wave getting started – Sort of an abridged version of the official guide written by Vogella.

Grasping the overall picture of a java robot is a little difficult. This is because there are no flow or architecture diagrams (at least none that I know of) that show you the sequence of events. Given below is a diagram that does that. Assume that you wrote a java robot that is meant to edit blips in a wavelet. The robot should provide a profanity filter service which will delete objectionable words from the wave. This is how the series of events happen.

Categories: java Tags: , , ,

Java thread tutorial

October 18th, 2009 CertPal 1 comment

j_thread_locksIf you are a newbie to working with java threads, this post will help you. Certifications like the SCJP require you to understand java threads to a fair degree. Threads behavior can be difficult to understand even for experienced programmers, so I will try to present some examples which will help candidates identify how threads wait / lock and synchronize.

Lets cut the chit chat and jump into a problem. A program increments a counter in a for loop as shown below.

Synchronizing:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
public class StaticSync
{
    public static final Object s_lock = new Object();
    public static int s_counter=0;
    public static void main(String... args)
    {
        new StaticSync().go();
    }
 
    public void go()
    {
        for(int iCounter=0; iCounter<50; iCounter++)
        {
            Thread thread = new Thread(new Incrementer(new StaticSync()));
            thread.start();
        }
    }
}
 
class Incrementer implements Runnable
{
    StaticSync m_staticSync=null;
    public Incrementer(StaticSync staticSync_INP)
    {
        m_staticSync = staticSync_INP;
    }
 
    public void run()
    {
        synchronized (m_staticSync.s_lock)
        {
            m_staticSync.s_counter++;
            System.out.println(m_staticSync.s_counter);
        }
    }
}

This program is pretty simple. This is the sort of code that you can expect on the SCJP exam. Advanced versions of the code above can also appear by adding notify() wait() sleep() etc into the picture. Let us concentrate on the program for now. What can be guaranteed about the output of this program ?

Categories: Java certifications Tags: , ,