Monday, September 07, 2009

Maven default bindings

Source: http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html#Built-in_Lifecycle_Bindings

Each phase of a build lifecycle in implemented by a set of goals. These goals are part of plugins.

Which goals handle which phases is specified by binding the goals(s) to phases. Following is the list of default such bindings.

Some phases have goals binded to them by default. And for the default lifecycle, these bindings depend on the packaging value. Here are some of the goal-to-build-phase bindings.

Clean Lifecycle Bindings

clean

clean:clean

Default Lifecycle Bindings - Packaging ejb / ejb3 / jar / par / rar / war

process-resources

resources:resources

compile

compiler:compile

process-test-resources

resources:testResources

test-compile

compiler:testCompile

test

surefire:test

package

ejb:ejb or ejb3:ejb3 or jar:jar or par:par or rar:rar or war:war

install

install:install

deploy

deploy:deploy

Default Lifecycle Bindings - Packaging ear

generate-resources

ear:generateApplicationXml

process-resources

resources:resources

package

ear:ear

install

install:install

deploy

deploy:deploy

Default Lifecycle Bindings - Packaging maven-plugin

generate-resources

plugin:descriptor

process-resources

resources:resources

compile

compiler:compile

process-test-resources

resources:testResources

test-compile

compiler:testCompile

test

surefire:test

package

jar:jar and plugin:addPluginArtifactMetadata

install

install:install and plugin:updateRegistry

deploy

deploy:deploy

Default Lifecycle Bindings - Packaging pom

package

site:attach-descriptor

install

install:install

deploy

deploy:deploy

Site Lifecycle Bindings

site

site:site

site-deploy

site:deploy

 

Phases of the maven lifecycles

Source: http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html#Lifecycle_Reference

Clean Lifecycle

pre-clean

executes processes needed prior to the actual project cleaning

clean

remove all files generated by the previous build

post-clean

executes processes needed to finalize the project cleaning

Default Lifecycle

validate

validate the project is correct and all necessary information is available.

initialize

initialize build state, e.g. set properties or create directories.

generate-sources

generate any source code for inclusion in compilation.

process-sources

process the source code, for example to filter any values.

generate-resources

generate resources for inclusion in the package.

process-resources

copy and process the resources into the destination directory, ready for packaging.

compile

compile the source code of the project.

process-classes

post-process the generated files from compilation, for example to do bytecode enhancement on Java classes.

generate-test-sources

generate any test source code for inclusion in compilation.

process-test-sources

process the test source code, for example to filter any values.

generate-test-resources

create resources for testing.

process-test-resources

copy and process the resources into the test destination directory.

test-compile

compile the test source code into the test destination directory

process-test-classes

post-process the generated files from test compilation, for example to do bytecode enhancement on Java classes. For Maven 2.0.5 and above.

test

run tests using a suitable unit testing framework. These tests should not require the code be packaged or deployed.

prepare-package

perform any operations necessary to prepare a package before the actual packaging. This often results in an unpacked, processed version of the package. (Maven 2.1 and above)

package

take the compiled code and package it in its distributable format, such as a JAR.

pre-integration-test

perform actions required before integration tests are executed. This may involve things such as setting up the required environment.

integration-test

process and deploy the package if necessary into an environment where integration tests can be run.

post-integration-test

perform actions required after integration tests have been executed. This may including cleaning up the environment.

verify

run any checks to verify the package is valid and meets quality criteria.

install

install the package into the local repository, for use as a dependency in other projects locally.

deploy

done in an integration or release environment, copies the final package to the remote repository for sharing with other developers and projects.

Site Lifecycle

pre-site

executes processes needed prior to the actual project site generation

site

generates the project's site documentation

post-site

executes processes needed to finalize the site generation, and to prepare for site deployment

site-deploy

deploys the generated site documentation to the specified web server

 

Nice maven article

http://blogs.plexibus.com/2007/12/02/maven-guide-part-one-basics/

Friday, September 04, 2009

Creating a empty maven project structure

Maven can itself create empty project structures when you want to start a new code base. To create an empty project structure, maven needs to be told the kind of project (simple servlet web application or JSF web application with Spring and hibernate or Web application with spring, hibernate and spring MVC etc…). Maven knows the details of the directory structure for each project type through an archetype. So a simple servlet web application will have its own archetype that details how the directory structure of a simple servlet web application looks like.

 

So to start with execute

 

mvn archetype:generate

 

Then Maven will ask you the kind of project you want to create by listing the archetype that it knows about and asking you to select the archetype. Then it wail ask other details about your project (group id, artifact id etc… ) and after all project details are provided, will create the empty project structure for you.

 

Source

Hibernate Getting Started

Source: Hibernate Reference documentation

Hibernate Getting Started


Hibernate Mapping File - Specifies how instances of persistent classes are to be persisted and loaded. This specification is laid out by detailing the properties that are mapped to columns, classes that are mapped to tables and the relationship between classes mapped in DB semantics like foreign keys (and join tables?).

Basic Hibernate Mapping File (there are multiple listings of the same file. Each listing builds upon the previous listing):

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
  "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
  "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
  <!-- This file will first be looked up in classpath, then on the web. -->
<hibernate-mapping package="org.hibernate.tutorial.domain">
[...]
</hibernate-mapping>


<hibernate-mapping package="org.hibernate.tutorial.domain">
  <class name="Event" table="EVENTS">
    <!-- All classes that represent persistent entities, must be mapped to a table -->
    <!-- This tells hibernate to persist and load instances of Event class to the EVENTS table. Each instance of Event is a row in EVENTS table -->
  </class>
</hibernate-mapping>

<hibernate-mapping package="org.hibernate.tutorial.domain">
  <class name="Event" table="EVENTS">
    <id name="id" column="EVENT_ID">
 
    <!--
The class Event bean has a property (or getter and setter) by name "id" that serves as a key or id of Event class. The id has to be stored to the column EVENT_ID. -->
      <generator class="native"/>
        <!-- Use hibernate's key generation strategy (How are identifier values generated?) to generate the Keys for Events. Other strategies include Data base generated keys, Globally unique keys, application generated keys -->
    </id>
  </class>
</hibernate-mapping>

<hibernate-mapping package="org.hibernate.tutorial.domain">
  <class name="Event" table="EVENTS">
    <id name="id" column="EVENT_ID">
      <generator class="native"/>
    </id>
    <!-- Other properties of Event class. If a property is not mapped, it is not considered persistent. -->
    <property name="date" type="timestamp" column="EVENT_DATE"/>
      <!-- Event has a getDate() and setDate() and the value is to be stored in the column named EVENT_DATE. Type is hibernate mapping type. There are converters that convert between Java to SQL data types and visa-versa. If type not specified, hibernate will try to determine the mapping type and conversion type. This automatically (detected through reflection - can impact start up performance) type may not be what you want. For example java.util.Date can map to "date" (only date e.g. July 4th, 2009), "timestamp" (both date and time e.g. July 4th, 2009 10:00:00 HRS) or "time" (only time e.g. 10:00:00 HRS). Then you explictly specify the type -->
    <property name="title"/>
      <!-- Event has a getTitle() and setTitle(). Column name is not specified, so use the property name as the column name. -->
  </class>
</hibernate-mapping>


"Hibernate mapping file" specified how to load and store objects of the persistent class

 

Attitude, to me is more important than facts, education, money, circumstances, failures, successes and what others think and say

“The longer I live, the more I realize the impact of attitude on life. Attitude, to me is more important than facts. It is more important than the past, than education, than money, than circumstances, than failures, than successes, than what other people think or say or do. It is more important than appearance, giftedness or skill. It will make or break a company …a church …a home. The remarkable thing is we have a choice everyday regarding the attitude we will embrace for that day. We cannot change our past …we cannot change the fact that people will act in a certain way. We cannot change the inevitable. The only thing we can do is play on the one string we have, and that is our attitude. I am convinced that life is 10% what happens to me and 90% how I react to it. And so it is with you. We are in charge of our attitudes.”

- Charles Swindoll through Julie911

Thursday, September 03, 2009

Logic that needs to be executed only in the JSF Render Response Phase

if (FacesContext.getCurrentInstance().getRenderResponse()) {
    // Logic that needs to be executed only in the JSF Render Response Phase
}
 
Source - balusc

 

Have you found joy in your life? 'Has your life brought joy to others?

“You know, the ancient Egyptians had a beautiful belief about death. When their souls got to the entrance to heaven, the guards asked two questions. Their answers determined whether they were able to enter or not. ‘Have you found joy in your life?’ ‘Has your life brought joy to others?’”

- The Bucket List through Julie911

Wednesday, September 02, 2009

Look around you - played in Lost

Oh, look around you
Look down the bar from you
The lonely faces that you see
Are you sure that this is where you want to be
These are your friends
But are they real friends
Do they love you the same as me
Are you sure that this is where you want to be
You seem in such a hurry to live this kind of life
You've caused so many pain and misery
Look around you, take a good look
And tell me what you see
Are you sure that this is where you want to be
Don't let my tears persuade you, I had hoped I wouldn't cry
But lately, teardrops seem a part of me
Oh, look around you, take a good look
At all the local used-to-be's
Are you sure that this is where you want to be

Willie Nelson

Tree conflicts

Friday, August 28, 2009

Medicare

Medicare is health insurance for people age 65. Should have legally entered and lived in u.s. for 5 years. There are 2 parts to it,

Part A - in patient services. This is free as it is paid for through medicare taxes when one worked.

Part B - out patient and other medical expenses - need to pay a premium ($96.40 in 2008)

media multitasking v. task multitasking

http://www.npr.org/templates/story/story.php?storyId=112334449&ft=1&f=5

Our abilities, frailties and virtues

“Ninety percent of the world’s woe comes from people not knowing themselves, their abilities, their frailties, and even their real virtues. Most of us go almost all the way through life as complete strangers to ourselves.“
— Sydney J. Harris through julie911

Thursday, August 27, 2009

Nice trick with xargs

ls | xargs  -t -I{} echo {} {}.new

 

-t echo the command that is going to get executed before executing

-I{} Insert a new line where{} appears

 

e.g.

 

$ ls

first.txt  second.txt

 

$ ls | xargs  -t -I{} echo {} {}.new

echo first.txt first.txt.new

first.txt first.txt.new

echo second.txt second.txt.new

second.txt second.txt.new

Building a massive system is like building a simple API - Eric

In response to Steve indicating that Eric is pretty good at building big systems from the scratch

Good schooling info

One more school to the list - Chinmaya Vidyalaya

Top grade schools in chennai

From here : http://www.indusladies.com/forums/schools/4665-age-criteria-admission-lkg-chennai.html

 

PSBB, DAV, chettinad vidhyasharm, State Bank of India Officers Association (SBOA) school, Vidya mandir, PS senior

Schooling for kids in Chennai

Nice thoughts from http://goodschoolsofchennai.blogspot.com/

 

1. Identifying the right skill and potential in the kid 

2. Identify what interests the child. 
3. Get your aspirations in line with what the Kids interest is.
4. Understand what needs to be provided to the kid to thrive on his interest.
5. Providing the right environment at home, school and the places that we visit regularly to inspire them to pursue their interest.
6. Providing the tools for them to nurture their talent. 
7. Giving the quality time and feedback for them to improve. 
8. Providing the freedom for them to express their point of views.

Wednesday, August 26, 2009

God is behind me - My father

When we came across a pretty helpful Delta airways staff while checking in the baggage at Salt lake city Airport on their (my parents) way to India.

Monday, August 24, 2009

Breathe

If you feel stressed out and overwhelmed, breathe. It will calm you and release the tensions.

If you are worried about something coming up, or caught up in something that already happened, breathe. It will bring you back to the present.

If you are discouraged and have forgotten your purpose in life, breathe. It will remind you about how precious life is, and that each breath in this life is a gift you need to appreciate. Make the most of this gift.

If you have too many tasks to do, or are scattered during your workday, breathe. It will help bring you into focus, to concentrate on the most important task you need to be focusing on right now.

If you are spending time with someone you love, breathe. It will allow you to be present with that person, rather than thinking about work or other things you need to do.

If you are exercising, breathe. It will help you enjoy the exercise, and therefore stick with it for longer.

If you are moving too fast, breathe. It will remind you to slow down, and enjoy life more.

So breathe. And enjoy each moment of this life. They’re too fleeting and few to waste.

By Leo Babauta through Julie911

Wednesday, August 19, 2009

Hope, Confidence and Optimism - Julie911

Hope: A feeling of expectation and desire for a certain thing to happen.

Confidence: A feeling of self-assurance arising from one’s appreciation of one’s own abilities or qualities.

Optimism: Hopefulness and confidence about the future or the successful outcome of something.

 

Tuesday, August 18, 2009

a alternative loop-up table

In the above case, we had a special column for Key. Instead we could also have a code for the course like this:

 

Student Table

 

 

Id

Name

Course

1

Abc

Comp

2

Xyz

Art

 

Course table

 

Id

Name

Comp

Computers

Art

Arts

 

This way the code is more readable. The downside is its pretty difficult to change the i.d. If in the future its required to change the id of “computers” course from “comp” to “it”, then that is not a easy deal.

Lookup tables

Student Table

 

 

Id

Name

Course

1

Abc

100

2

Xyz

101

 

Course table

 

Id

Name

100

Computers

101

Arts

 

In the above case the Course table is a lookup table. You look up with the course id and get the course name

Friday, August 14, 2009

Unit tests are faster

Write unit tests and your functionality gets done faster and most reliable.

Thursday, August 13, 2009

Clear history of firefox before seeing changes made to css files

Firefox caches css files. So if you change a css file, it may still be using the old css file and your changes will not be seen. So clear the cache to see the changes take effect.

Wednesday, August 12, 2009

Oracle putting its acquired companies to work

It uses JD Edward’s EnterpriseOne as a single point of management for its applications, BEA system’s web logic (integrated with Oracle’s home grown variant) as OFM (Oracle Fusion Middleware) along with its all famous DBMS to offer a full stack of software (added with OFA [Oracle Fusion Application] which are pre-packed applications that leverage on OFM and the DBMS.

Tuesday, August 11, 2009

Sleep well. A full night of sleep will help put you in a better mood. It will also give you energy to enjoy your activities.
Take a day off. If you have something planned for tomorrow that you are not looking forward to, try to cancel or postpone it. When avoiding your regular is impossible, plan ahead for a weekend or a day off by making your “tomorrow” a few days later than the next day.
Do something that you love. Spend some time with a favored activity, even if it is something that you have not done for a while.
Invite a friend or loved one to visit you. Have lunch with them, or watch a movie you both enjoy. Having a friend or loved one around can lift your spirits and make you feel good.
Eat healthy foods. Eating right will make your body feel better. That’s not to say that you can’t have your favourite foods, but make sure to incorporate fruits and veggies into your diet.
Think positively. Wake up and realize what an awesome day it is and how awesome you are!
Listen to a fast upbeat song, such as Jump or Tarzan Boy. It will put you in a good mood.
Seize the moment. Time is fleeting and there is nothing worse than a missed opportunity. Go for it!
Do something everyday that scares you! It helps you grow as a person, and makes you feel great afterwards! But don’t do something dangerous.

Saturday, August 08, 2009

Nice lines by ryan adams

These very moments as they pass
It’s like you’re just dreaming of busting someone else
Hands they hold a candle to the pages
These days they go so fast
These days are ours

Follow the lights that line the streets
connecting telephones
Follow the lights from house to house
And they will lead you home
They will lead you home
Cause there was never anywhere to go
There was never anywhere to go
But home

If every second year is true
Our love is strong enough to guide the way we walk through
Hands inside of hands
Hearts inside of hearts
Like eyes closed
Side by side and through

Follow the lights that line the streets
connecting telephones
Follow the lights from house to house
And they will lead you home
They will lead you home
Cause there was never anywhere to go
There was never anywhere to go
But home

If everything we are is true
Our memories are attics in those houses on the hill
Our love is there above us holding everything so still
And we are always here
Yes we are always here

So follow the lights that line the streets
connecting telephones
Follow the lights from house to house
And they will lead you home
They will lead you home
Cause there was never anywhere to go
There was never anywhere to go
There was never anywhere to go
But home, home

I just know I don't want to be mad anymore. I am just tired of being mad. - October road

Smart, funny and beautiful inside and out - October road

Friday, August 07, 2009

Listen to the sound of your breath, then relax it

  1. Listen to your life with your eyes closed
  2. Listen to your words before you speak them
  3. Listen to what you want - more of - in life
  4. Listen to the sound of your breath, then relax it
  5. Listen to your intuition. It’s always trying to grab your attention
  6. Listen to what your body needs, right now. Put your thumbs in your ears, cover your eyes with your fingers and then listen
  7. Listen thankfully to the sounds of nature
  8. Listen for the wisdom in your problems
  9. Listen more, talk less
  10. Listen to your thoughts in slow motion. Are they bringing you closer to your dreams or taking you further away?
  11. Listen to your life without the sound of technology and machines (no phone, TV, ipod etc)
  12. Listen to silence
  13. Listen to your favourite music
  14. Listen, really listen to your children, family and friends
  15. Listen to how many sounds are actually happening around you right now
  16. Listen to the calming sounds of the ocean by cupping your hands over your ears and turning your awareness inwards
  17. Listen to the sound of your favourite food cooking
  18. Listen to your heart - What is it saying?
  19. Listen to the sound of your feet when walking
  20. Listen to the appreciation of your body after eating something healthy

- thehealthylivinglounge.com

Wednesday, August 05, 2009

Conciousness during the persuit of a big goal

Aiming high is good. Big goals are good. But when it comes to pursuit, small goals (that match your skill and challenge) must occupy your consciousness. Small goals have smaller sacrifices (like spending your time studying instead of watch your favorite TV show). Smaller sacrifices are within one’s skill/ability. Successful small sacrifices, gives one the confidence that the goal is achievable.

It is within one’s ability to be mindful of one’s smaller goal and be focused on putting effort towards the goal by seeing small efforts giving small results. These small results put together will one day look like the big goal that one set out to achieve.

Heaven and hell here in earth

Heaven and hell is not something that one experiences after death. It is something that is undergone or experienced here in earth. God doesn’t sit in heaven and decide if you are going to heaven or hell after you die. He sites in your conscience and delivers heaven or hell based on virtues and non-virtues that occupy your consciousness.

 

Virtues like honesty, love, forgiveness allow you to experience heaven manifesting as peace in each moment on earth. Non-virtues like cheating, egotism, anger take you into hell experienced as a heavy feeling or guilt.

 

-me

oodles - lots of

Oodles of joy – lots of joy

ISO Sensitivity in digital cameras

ISO Sensitivity controls the amount of light that gets captured for photos taken. This is the same as the exposure rate in analog/film based cameras. In analog cameras the amount of light captured in the film is controlled by the duration of time the shutter is open for one click (exposure rate). In digital cameras, this is controlled by setting the ISO Sensitivity level of the cells that capture the incoming light upon click.

During bright light conditions, a lower ISO sensitivity is preferred and a higher sensitivity in dark conditions.

Tuesday, August 04, 2009

Finding the version of current svn working directory

Svnversion .

One brut way to find the cause of a regression change

Lets say we have N number of committed changes. A new defect surfaces. One brut way to find the cause of the defect is to revert the code to the point where the most dubious code change and see if the defect still arises. If it does, the most dubious code change or one of its successive commits are the culprits. If not, the most dubious code change is not the culprit.

Friday, July 31, 2009

It is the fool who fails to return to the place of his last happiness

"It is the fool who fails to return to the place of his last happiness." - Don't know the author

Wednesday, July 22, 2009

Multilayer validation strategy

The validation logic of an application can be spread across the application. Some logic against the UI, some against Business layer, some against service layer and some against DAO layer.

Sunday, July 19, 2009

One difference between chapter 7 vs. 11 bankruptsy

Chapter 7 - Going into liquidation
Chapter 11 - Trying to re-habilitate

Wednesday, July 15, 2009

Simple APIs responsibilities on arguments

public Student createStudent(Student student, Couse course)

 

Lets say the responsibility of this API is to save the student and return the saved version back (the saved version will have the key).

 

Some implications of this API is that

  1. If there is a failure, student and course objects should be left un-touched. If there were changes made before the createStudent() failed, all those changes should not be visible to the client of this API. This can be done by taking a copy of the student and course and letting createStudent() operate on that copy. That way if there is a failure, then the original student and course object remain intact.
  2. If the operation succeeds, the client of this APIs would usually require that all changes made by createStudent() be reflected in student and course. To achieve this, after all createStudent operations complete successfully, overwrite the copy that was made at that start of the call back into student and course.

Saturday, July 04, 2009

Do what you can do

Forget about your lists and do what you can because that’s all you can do. Phone up the people you miss and tell them you love them. Hug those close to you as hard as you can. Because you are always only a drunk driver’s stupidity, a nervous shopkeeper’s mistake, a doctor’s best attempts and an old age away from forever. - Julie

My hapiness and self worth

Don`t rely on someone else for your happiness and self worth. Only you can be responsible for that. If you can`t love and respect yourself - no one else will be able to make that happen. Accept who you are - completely; the good and the bad - and make changes as YOU see fit - not because you think someone else wants you to be different.

- Stacey Charter

Time it takes to get something done

Don’t let the fear of the time it will take to accomplish something stand in the way of your doing it. The time will pass anyway; we might just as well put that passing time to the best possible use
- Earl Nightingale

HQL notes

Case IN-sensitive

except names of classes and their properties
- Doubt: "This manual uses lowercase HQL keywords. Some users find queries with uppercase keywords more readable, but this convention is unsuitable for queries embedded in Java code." - why is this so? 

the from clause

minimum query is from Student - selects all instances of Student class. By default auto-import is true. So class names do not have to be qualified with the package name. If auto-import is turned off (false) then this query must be written as from com.xyz.Student 

To refer to Student in other parts of the query, an alias must be assigned to Student. from Student as student assigns student as an alias for Student. The "as" is optional. So the previous alias association can be written as from Student student. Its a good practice to start alias names in lower case as this is in-line with java coding standards for naming variable names.
- from Student as student, Department as department gives a cartesian product of all students and all departments. 

Joins
SQL Joins
Source. Joins used to fetch rows from 2 or more tables based on the relationship between columns in both the tables. Primary key is a column (or a group of columns - composite key) with unique values that identify each row. 

  1. inner join - returns a row when there is a match in both the tables
  2. left outer join - returns all rows from the left table even if there are no matches on the right table
  3. right outer join - returns all rows from the right table even if there are no matches on the left table
  4. full join - returns rows when there is a match in one of the tables

examples:

Employee table:
emp_noemp_namedept_no
1xyz1
2abc2
3ghi4

Department table:
dept_nodept_name
1IT
2Sales
3Accounts

inner join:
select emp.emp_no, emp.emp_name, dept.dept_name from employee as emp inner join department as dept on emp.dept_no = dept.dept_no;
emp_noemp_namedept_name
1xyzIT
2abcSales

left outer join
select emp.emp_no, emp.emp_name, dept.dept_name from employee as emp left join department as dept on emp.dept_no = dept.dept_no;

emp_noemp_namedept_name
1xyzIT
2abcSales
3ghi

right outer join
select emp.emp_no, emp.emp_name, dept.dept_name from employee as emp right join department as dept on emp.dept_no = dept.dept_no;

emp_noemp_namedept_name
1xyzIT
2abcSales


Accounts

full join
select emp.emp_no, emp.emp_name, dept.dept_name from employee as emp full join department as dept on emp.dept_no = dept.dept_no;

emp_noemp_namedept_name
1xyzIT
2abcSales
3ghi


Accounts

HQL Joins

Same types of joins as SQL
1. inner join e.g. from Employee as emp inner join | join emp.department as dept
2. left outer join e.g. from Employee as emp left outer join | left join emp.department as dept
3. right outer join e.g. from Employee as emp right outer join | right join emp.department as dept
4. full join