Monday, December 28, 2009

Finish each day and be done with it.

“Finish each day and be done with it. You have done what you could; some blunders and absurdities have crept in; forget them as soon as you can. Tomorrow is a new day; you shall begin it serenely and with too high a spirit to be encumbered with your old nonsense.”

- Ralph Waldo Emerson through Julie911

When we are ... just not brave enough ...

"There are times when it is hard to believe in the future, when we are temporarily just not brave enough. When this happens, concentrate on the present. Cultivate le petit bonheur (the little happiness) until courage returns. Look forward to the beauty of the next moment, the next hour, the promise of a good meal, sleep, a book, a movie, the likelihood that tonight the stars will shine and tomorrow the sun will shine. Sink roots into the present until the strength grows to think about tomorrow."
— Ardis Whitman through Julie911

I see who I wanna be in my daughter’s eyes

“In my daughter’s eyes I am a hero. I am strong and wise and I know no fear, but the truth is plain to see: she was sent to rescue me. I see who I wanna be in my daughter’s eyes.”

- Martina McBride through Julie911

Wednesday, December 23, 2009

Basic Hibernate APIs

      // configure will look for mapping & settings in an application     

      // resource file named hibernate.cfg.xml

      SessionFactory sessionFactory =

            new Configuration().configure().buildSessionFactory();

      Session session = sessionFactory.getCurrentSession();

      try

      {

            session.beginTransaction();

           

            Event testEvent = new Event();

            testEvent.setTitle("testTitle");

           

            session.save(testEvent);

            // Commit if all goes well

            session.getTransaction().commit();

      }

      catch (Exception e )

      {

            // rollback if something fails

            session.getTransaction().rollback();

      }

 

Advantages of group insurance provided by employer in U.S

  1. The employer’s contribution. You don’t have to contribute to your entire medical insurance premium.
  2. No pre-existing conditions. If one approaches the insurance company directly, any pre-existing conditions are not covered. But this does not apply for group medical insurance provided by employer.

- As I understand from a friend of mine.

Tuesday, December 22, 2009

Seriousness ...can't be over done

I consider seriousness to be a admirable change of character, but it can't be over done.
A christmas carol

Monday, December 21, 2009

Basic Hibernate Command line application

Here is a basic hibernate command line application that is based on the getting started chapter of Hibernate Reference Documentation. It works with PostgreSQL and can be used to play around with small code changes and seeing the impact on the database. To point to another database, change hibernate.cfg.xml.


To build the application, run

mvn clean install

To execute, run

mvn exec:java -Dexec.mainClass=tutorial.EventManager -Dexec.args="store"

Wednesday, December 16, 2009

Whether your kid is a concert pianist or a math genius, it just doesn't matter, because at the end of the day all that matters is...

“Some day you’re gonna have a baby and you’re gonna feel overwhelmed by this little life that you’re responsible for and you’re gonna think and worry that everything you do is wrong, and that’s normal. You’re gonna obsess about what to feed it, and where to send it to school, and whether it should take violin or piano. But, I’m gonna let you in on a little old secret, it doesn’t matter. Whether your kid is a concert pianist or a math genius, it just doesn’t matter, because at the end of the day all that matters is if your kid is happy.”

- 
Grey’s Anatomy through Julie911

Believe that there's light at the end of the tunnel. Believe that you might be that light for someone else.

“Believe that there’s light at the end of the tunnel. Believe that you might be that light for someone else.”

- 
Kobi Yamada through Julie911

Tuesday, December 15, 2009

Merging specific changes from trunk to branch

To merge a set of specific revisions from the trunk to branch [this is usually required when a code change on trunk after a release needs to be back ported on to the release (each release having its tag)].

 

# cd abc/tags/1_7_3 # go to the branch

# svn merge svn://xyz/abc/trunk@8108 svn://xyz/abc/trunk@8109 . # merge into current working copy (branch)

Monday, December 14, 2009

Free Mind - mind mapping tool looks good

A couple of my colleagues discussed this:

 

http://freemind.sourceforge.net

Friday, December 11, 2009

Pursuit of greatness

Pursue something from nothing,

Pursue something good from something,

Pursue greatness from something good.

anybody driving slower than you is an idiot, and anyone going faster than you is a maniac

“Have you ever noticed that anybody driving slower than you is an idiot, and anyone going faster than you is a maniac?”

- 
George Carlin through Julie911

Thursday, December 10, 2009

To be present in the appreciation of life's abundance

Gratitude: To be present in the appreciation of life’s abundance and to share that light with others.

by Donna Downey through Julie911

Wednesday, December 09, 2009

Debugging exceptions with no known cause

There are times when you call a third party method in your code which throws an exception. Your line that invokes the third party code is not seen in the exception stack trace. In these cases, it is useful to wrap the call to the third party code in try catch block, catch Exception and log the resulting exception. The stack trace from the exception you log will have your code that is making the third party call, calls made by the third party code and likely a more detailed message of what went wrong.

 

e.g.:

 

class MyClass

{

    public void myMethod()

    {

        try

        {

            new ThirdPartyClass().thirdPartyMethod();

        }

        catch (Exception e)

        {

            e.printStackTrace();

        }

    }

}

Usually an application will create a single Configuration, build a single instance of SessionFactory and then instantiate Sessions in threads servicing client requests.

 

Monday, December 07, 2009

Thursday, December 03, 2009

Wednesday, December 02, 2009

Portlet Modes

The mode indicates the function that the portlet is currently performing. A portlet’s current mode is passed to it by the portlet container. Based on the mode, the portlet can choose to generate different contents. In processAction() method, the portlet can change the mode programmatically.

 

Portlets can be in 3 modes:

  1. View (represented by PortletMode.VIEW) – usually portlets represent their current state
  2. Edit (PortletMode.EDIT) – Options to edit data are presented here
  3. Help (PortletMode.HELP) – Generic or context sensitive information about the portlet provided here.

 

The portlet modes that a user has access to can be restricted by his authentication credentials (e.g. guest can only read and access help).

 

Custom portlet modes are also supported. These custom modes can be portal managed (portal will manage custom modes for the portlet) or portlet managed (portlet manages its mode in its own code. Portal not aware of portlet’s modes).

 

In portlet.xml, the modes that the portlet supports are indicated as follows:

 

<portlet>

  …

  <supports>

    <mime-type>text/html</mime-type>

    <portlet-mode>view</portlet-mode>

    <portlet-mode>edit</portlet-mode>

    <portler-mode>help</portlet-mode>

  </supports>

</portlet>

 

Initialization parameters to a portlet can be specified as follows in portlet.xml:

 

<portlet>

  <init-param>

    <name>view-action</name>

    <value>test</value>

  </init-param>

  <init-param>

    <name>edit-action</name>

    <value>test2</value>

  </init-param>

  …

</portlet>

 

These initialization parameters can be accessed in the portlet using the PortletConfig.

      

Portlet lifecycle

The portal, during the course of managing a portlet, passes the portlet through the following stages

  1. Init
  2. Process Action
  3. Render
  4. Destroy

There is one method in the Portlet interface for these stages. Right before a stage change occurs (e.g. when the portal is about to destroy a portlet), the portal notifies the portlet by invoking the appropriate method (the destroy() method for e.g.) on the Portlet Interface.

 

These are the possible state transitions

Init -> Process Action <-> Render -> Destroy

 

  1. Init – Porlet is loaded and instantiated either on portlet container start or upon receipt of request for the portlet. Following this, the init() method on the portlet will be invoked. Portlets usually initialize expensive resources (connections for e.g.) at this time
  2. Process Action & Render - Requests raised by portlets can from
    1. Action URL: request fires processAction() method on portlet on which the URL resides and render() method on all the portlets. The portlet, in its processAction() method, updates its model. The render() method generates a view that indicates the current state of the model.
    2. Render URL: request only fires render() method on all the portlets.
  3. Destroy – Portal’s notice that the portlet is to be removed. Typically, a portlet will release all resources and persist any yet-to-be-persisted state/model.

 

Tuesday, December 01, 2009

When ... you could not hold on a minute longer, never give up then, for that is just the place and time that the tide will turn.

“When you get into a tight place and everything goes against you, till it seems as though you could not hold on a minute longer, never give up then, for that is just the place and time that the tide will turn.”

- 
Harriet Beecher Stowe through Julie911

Looking at java stack traces

While looking at stack traces,

  1. Read from the bottom of the trace
  2. Read the Message of the last stack trace (usually there are many with “caused by”)
  3. Look for a line in the stack trace that indicate a call to your package in the stack trace. This way, you will know how your code is getting called and what your code is doing.