a peek into my MIND

November 30, 2009

Let’s be brothers again

Filed under: screams — Bharat Kondeti @ 2:44 am

Once I had an argument with one of my Pakistani friend about Kashmir. He was arguing that free Kashmir will resolve all the issues between India and Pakistan. It was just a healthy discussion and he did not mean it, but it made me think and following is its result..

They were like brothers, like a family.
Together they shared their joy,
And together they shared their sorrow.
They ate food grown from the same land,
They drank water from the same river,
And its the same air that flowed through their bodies.

Yet a time came when they became bitter enemies.
They became thirsty for each others blood,
They became hungry for each others flesh,
And the air was filled with stench of death.
(Together) They found a reason to kill each other,
When they could have found a reason to live together.

Is it the greed, or hunger for power,
That turns human into a beast.
They blindly (believed in) followed the power craving leaders,
They beheaded the men who were like brothers,
Molested the women who were like sisters,
And killed the children who doesn't know their religion. (which religion they are.)

I wonder which religion permits to kill others,
yet they killed in the name of religion and for the sake of heavens.
They turned their lands into living hell,
And funneled their hatred to next generations.
They only told the things that have been done to them,
But they never told the things that they have done.

I wish they could have thought by themselves,
And listened to their hearts, rather than to their leaders,
That killing is never a solution for anything.
We would have been living like brothers and as a family,
And our land would have been a heaven.
yet, its never too late ,by forgetting to our past and listening to our heart.


November 25, 2009

Law of Demeter

Filed under: General — Bharat Kondeti @ 4:54 pm

Also know as ‘Principle of least knowledge’.

“It means a object should only know about objects that it can directly act upon”. Following this principle will result in a modular code that is easily testable.

A really nice analogy for this principle is from The Clean Code Talks – Don’t Look For Things! by Misko Hevery.

You are in a store and the item you are purchasing costs 10 dollars.

Will you give the clerk 10 dollars ? or Will you give the clerk your wallet and let him retrieve the 10 dollars?

Of-course a sane person will give the clerk 10 dollars. Same principle applies when creating the objects. You should only pass into the object that is relevant and that it can directly act upon.

November 18, 2009

Connecting to multiple datasources in grails application

Filed under: Groovy & Grails — Bharat Kondeti @ 7:44 pm

Grails inherently doesn’t support multiple data sources. We cannot specify for example like domain objects D1 and D2 should talk to DataSource1 and rest should talk to Datasource2.

To have this kind of flexibility one has to install Datasources Plug-in into the application.

Once installed create a Datasources.groovy file under configuration directory of the application. This groovy file will be a companion file for DataSource.groovy file.

Now we can add as many data-sources as we want in the new Darasource.groovy file as follows.

datasources = {
  datasource(name: 'aaaaDev') {
    hibernate {
      cache {
  datasource(name: 'aaaaTest') {
    hibernate {
      cache {

Couple of interesting tags are domainClasses and environments.

domainClasses take in a list of domain classes.
environments take in a list of environments this data source will be applicable for.

The domain classes that are not listed in this file will use the default data-source defined in DataSource.groovy.

Once this information is defined in the new Datasources.groovy everything will work magically.

November 16, 2009

Spring injecting prototype bean into a singleton bean

Filed under: Java — Bharat Kondeti @ 10:50 pm

I came across a scenario when in I had to inject a prototype bean into a singleton bean, in essence I needed a new instance of the bean every time a method is called on the singleton bean.

This can be achieved with something called “method injection”, which is a feature in Spring.

More information can be found in the spring documentation.

Blog at WordPress.com.