Saturday, June 27, 2009

Terracotta like implementation :: code

So this is what we thought:

The user object we remove all the field variable initializations and replace them with our custom code. So, the user says

this.list = new ArrayList(),

and during the byte code construction we will mke this equivalent to

this.list= new MyList().

Now the successive updates now happen over MYList which records the deltas.

So, say our object is UserAttributes::

public class UserAttributes implements Interceptable {

private ArrayList alias;

public List getAlias() {
return alias;

public void setAlias(ArrayList alias) {
this.alias = alias;

public static void main(String[] argv) {
UserAttributes u = new UserAttributes();
u.alias = new ArrayList();
System.out.println("alias::" + u.alias + " class:" + u.alias.getClass());

Now to replace the newArrayList() where ever possible we write a point cut as follows in InAspect.aj file

public aspect INAspect {

pointcut listCut(List value, LIST in) : set(@LIST * * ) && args(value) && @annotation(in);

void around(List value, LIST in) :listCut(value,in) {
System.out.println("**annotation " + thisJoinPoint + " ann:"
+ in.value());
value = new MyList(in.value());
value.add("val 1");
proceed(value, in);

Now the sop of the UserAttributes gives the out put as MyList class with one entry in it. Let me put few words abt the listCut.

  1. set(@LIST * * )&& @annotation(in) => cut all the modifying fields of the fields annotated with LIST annotation. Pickeup the annotation into in variable
  2. pointcut listCut(List value...args(value)=> picks up the modifying data as value variable. If u modify the value then it makes modification in the userAttributes class and thats what happens in the advice: around...
  3. proceed continues with the remaining point cuts (if any)

Terracotta like implementation

Terracotta, in one line, is the fast transport layer btw multiple JVMs. How is hte speed achieved? Simple he transfers the delta that happened in an object i.e.. if the object has changed one field variable then he transfers only that variable reather the entire object.

So we had an idea:
We need to transmit data from our Java servers to the Client where the end user plays his game and we thought why not take this terracotta apprach?

Aspect J:
here comes the here (as of now, to the knowledge we have till now). Now we want to manipulate the byte code that is generated by javac so that the new byte code now has new code which is intelligent enough to pickup the deltas between two consecuting updates of the object.

Aspect J

This is open source project and as any other open source it suffers in low documentation, So i thought i will put my work here so that it may help out somebody there trying to figure out the solutions.

Starting point:
  1. Aspect J site; get the eclipse plugin installed (2.0) Actually the plugin keeps u started off blackboxing the intricacies of compiling etc.
  2. Get the basic understanding of the technology jargon is here:
  3. in this link search for pointcut/ joinpoint/ advice and u are at their definitions
  4. Open eclipse and start experimenting.


I worked using open source projects like:: Apache softwares, Java and proprietary software like Oracle etc; one ironical difference i see if you get issues: Oracle forums (leaving the pure db alone otherwise... say Oracle AQ/ Streams/ collab suite) especially are stale. A lot of times i had asked and nobody replies, the forum seems like making us a fools. Or at most one guy comes out asking us for the db details which version. I dont understand how these guys can be so irresponsible? We pay to them and they are so mean. Meta link is another such a place. I actually heard that they ask u too many un necessary qns and eat away weeks of time.

Sun Java forums are the best of all the things i had ever seen. Put a qn and within 1 hr u get the soln, unless its some R&D type of a qn. Apache forums u get within 1 day. So nice... we take their work for free still they server us good.

Tuesday, June 23, 2009

Keeping Hope

Bajaj NANO

Bajaj ' s new Cheapest Bike for Rs.10000 (like nano)..... !!!!!!!

It has been a major hit in the market and is largely responsible for changing the 'Two wheeler maket'

It wil be introduced in Indian market in
1 st june 2009 ...

I hope everyone wil come to office by bike in few days...

Facilities are..

Available in following option

a) Kick Start
b) Electric Start

1. 250 CC Speed + we can increase speed by pedaling

2. 24 hr Free Air Conditoner System

3. Leg break System as like Disc break in Pulsar
(Ultimate one)
4. Without doubt it's going to win "Best Bike Of the Year 200
9 "

Engine Specification

Air Cooled

Front Brakes
No Need
Rear Brakes
130mm Drum
Front Tyre
2.75 X 18
Rear Tyre
100/90 X 18
Ground Clearance
Dry Weight
50 Kg
Tank Capacity
No Need

few more...

1. January to December
Sunday to Saturday
Am to Pm
My feelings for u have never changed..... ..
a HEADACHE to me !!!!

2. When u feel lonely and alone & cannot see any one around you, the
World seems to be fading away, come along with me I'll take u an eye
specialist !!

3. If marriages are made in heaven , then what are made in Hell?
Ans : the days after marriage

4. During Marriage ceremony why is the bridegroom is made to sit on the
horse ? He is given his last chance to run away.

5. Just close ur eyes and think of yourself for 10 seconds..... .
Open ur eyes ! Now you will realize that u have wasted 10 sec in thinking of a fool........ ....

7. I wrote ur name on the sands....... ......
it got washed away,
I wrote ur name in air......... ......... ........
it got blown away,
So i wrote ur name in my heart....... ......

8. LOVE is like a CIGAR
It starts with a fire..... continues with smoke.....and ends in
ashes... But dont worry - we are chain smokers

9. ur smile can be compared to a flower
ur voice can be compared to a cuckoo
ur inocence to a child
but in stupidity
u have no comparison
u r the best

10. True love is like a pillow
u can hug when u r in trouble
u can cry on when u r in pain & u can embrace when u r happy so when
u need true love spend Rs.50/-Buy a pillow

11. Dear Friend,
when i ask u flower,
u give me bouquet
when i ask u a stone
u give me a statue
when i ask u a feather
u give me peacock

12. I had VODKA with WATER
I felt DRUNK
I felt DRU! NK
I had RUM with WATER
I felt DRUNK

13. when i call u;
1 ring means i'm thinking of u;
2 ring means i like u;
3 means i miss u;
4 means .........pick d phone idiot

14. Teacher : four beautiful ladies r walking on the road. change it to
exclamatory sentence ...
Student : WOW !

15. The human brain is most outstanding thing.......
it functions 24hrs 365 days.....
it functions right from the time u r Born....until you fall in love

16. SMILE - is a language of love
SMILE - is a source to win hearts...
SMILE - creates greatness in ur personality SO....
Brush ur Teeth FROM today onwards

17. A cigarette shortens your life by 2 min..
A beer shortens your life by 4 min..
A working day shortens your life by 8 hours!!!!..

18. History Teacher : F! rom where to where did the mughals rule ?
Student : sir, i am not sure but think from page 15 to 26 sir....

19. Teacher : U failure ! @ ur age Bill gates stood first in the class
Student : Mind u, Sir, but @ ur age hitler commited suicide

Sardar again...

Visit Us @ www.MumbaiHangOut.OrgVisit Us @ www.MumbaiHangOut.Organd Visit Us @ www.MumbaiHangOut.Org
2 sardaron ko 2 bomb mile,
1st Sardar: chal police ko de ke aate hain.
2 sardar: agar koi bomb raaste me phat gaya to?
1st sardar: jhoot bol denge ki 1 hi mila tha

Sardar and Home
Man: Sardar jee aap ko garmi lagti hai to kya karte ho?
Sardar: AC k paas ja k baith jata hun
Man: Agar phir bhi garmi lage to?
Sardar: To A/C on kar leta hun

Sardar Visit Us @ www.MumbaiHangOut.Organd Hitler
Hitler says,
"There is no word like IMPOSSIBLE in my dictionary"
Sardar says: Ab bolne se kya faayda? "Jub kharidi thi tab hi check karna tha na"

Sardar and Practical
In bio practical:
Examiner: Tell me the name of this bird by seeing its legs only?
Sardar: I don't know.
Examiner: You r failed, what's your name?
Sardar: See my legs & tell my name

Friday, June 19, 2009

Date to String & viceversa

Yet another simple utility:: date to string and string to date conversion.

Date to String:
            SimpleDateFormat format = new SimpleDateFormat("MM/dd/yyyy-HH:mm:ss");
            format.setLenient(false); //if the string is not inthe expected format:: throws Exception.
            Date date = (Date)o;
            return format.format(date);

String to Date
            if(str ==null )
                return null;
            SimpleDateFormat format = new SimpleDateFormat("MM/dd/yyyy-HH:mm:ss");
            Date d = format.parse(str);
            return d;

Thursday, June 18, 2009

James Bond 000 :)

Once Jamesbond went to a forest for hunting and on his way he sees a Dog.
James Bond: I am bond, James Bond
Then the dog responded: I am dog, Mad Dog... bit him and left.

Monday, June 15, 2009

No Wrap

This is another simple, yet eats off time and forces us to use TDs to allign text + few elements in a td in one horizontal line. The fix is :

<td style="white-space: nowrap;" >  and <s:textfield theme="simple"
                    maxlength="4" size="4" name="playerAccAgeValue2" /></td>

This one worked for me. Another proposed soln:

<asp:Button ID="Button1" runat="server" Text="Add" />
<asp:Button ID="Button2" runat="server" Text="Delete" />
This stops the text from being wrapped around the textbox. Hope it helps.

Friday, June 12, 2009

Bond... James Bond + Telugu guy :D

On a flight James bond was sitting next to a Telugu guy.

Telugu Guy: "Hello, May I know your name please?"

James Bond: "My name is Bond" Continuing in his inimitable style,

"Bond .. James Bond"

Then Bond asks: "And you?"

Telugu Guy: " My name is Rao...

Siva Rao...

Samba Siva Rao...

Venkata Samba Siva Rao...

Yarlagadda Venkata Samba Siva Rao.....

Rajasekhara Yarlagadda Venkata Samba Siva Rao...

Sitaramanjaneyula Rajasekhara Yarlagadda Venkata Samba Siva Rao...

Vijayawada Sitaramanjaneyula Rajasekhara Yarlagadda Venkata Samba Siva

Rao... .."

Since then when anyone asks Bond his name he simply says

"James Bond"

Tuesday, June 2, 2009

running a Main file located in a jar

This is the frequent problem that i am getting so i thought i will put it here so that it can help somone looking for it.

1. I have a jar file in which i have a class file holding public static void main
2. The execution should also pickup a properties file.

java -cp jar_having_main_class.jar;;       com.comp.root.TheMainClass

Every time i get this problem i am re-googling forit. so thought i will post it here.

Monday, June 1, 2009


Seen the below on a forum:

Don't argue with idiots. They bring you down to their level, and then beat you with experience