Archive for March, 2010

Accessing private members outside a Java class…

March 18, 2010 Comments off

In a discussion with my colleague, who was bored of writing getter and setter methods for member variables in a Java class, was wondering if there is way to access a private variable or a method of a class outside its scope in a different class. In C++ world, this is quite very much possible using friend classes or probably accessing the address of the object to the class…

In the Java world as well, this is a long existing feature since the introduction of the reflection APIs. A sample code below illustrates how it can be done simply:

A TestObject that has a private member without any public getter and setter methods.

package one;

public class TestObject {
    private String testStr = "Hello World!";

An AccessTest class that reads the value of testStr private member using an object of TestObject class.

package two;

import java.lang.reflect.Field;

import one.TestObject;

public class AccessTest {

    public static void main(String[] args) {
        try {
            Class tObjClass = Class.forName("one.TestObject");
            Field tField = tObjClass.getDeclaredField("testStr");
            System.out.println("TestStr Value: "+tField.get(new TestObject()));
        } catch (Exception e) {

Using the java.lang.reflect APIs any private member or method of a class can be accessed from anywhere. One way to prevent this access is to run the program using a security manager as below:

java – AccessTest

would give the below exception:

access denied (java.lang.reflect.ReflectPermission suppressAccessChecks)

This feature is quite useful in unit testing when there is a need to test the private methods using a test suite.

Categories: tech Tags: , ,

Weekend @ Houston

March 16, 2010 Comments off

Almost for 6 months, all my weekends have been just movies and shopping. Putting together a quick plan to get away from Dallas and spend a weekend sounds better and easier than coding Java. With most of the folks here new to Dallas, everyone were anxious to go on a trip. So Parthi and family, Mugunth, Kishore, Senthil readily accepted the invitation to join the trip. Most of them being first timers to long trips, made the group more bubbling with excitement. Mugunth and myself made the initial arrangements, renting a car, booking the tickets to the attractions at Houston (nothing but just NASA), and most important of all buying the snacks from the Indian store. Even though we planned to leave Dallas by 4AM on Saturday, as usual we started late by more than an hour. With some devotional songs filling the air, Mugunth finally drove us out of Dallas.  03132010032

As the CDs kept changing, “hasile fisile en raasamani” continued by interesting-totally-waste-of-time discussions on movies, heroes and all the comedies. Almost an hour passed by, it was about sunrise after 6AM, and our veteran was in full form with his goggles on… Soon, Senthil, the youngest of all (Kutti – we call him), raised his interest to drive on the highway for the first time. We agreed to let him drive if he would stop his dry poor jokes. After coffee @ Starbucks, continued by breakfast @ BK, Kishore and then Parthi drove, and by the time we reached Houston it was half past 11AM, but Kutti never drove, as he never stopped his PJs in the entire trip.


Meenakshi Amman Temple, one of the biggest temples in US, I would say, is one of the most peaceful too. After praying to Goddess Meenakshi, Lord Sundareswara and Lord Vishnu for “World Peace” and our own prosperity, we went around the temple more than once to find if any “unda katti” is being served. With a camera in everyone’s hand, there was no one to pose for pictures, :)  finally a casual shot from Ramya…who was very happy clicking the Sony cam in whichever angle she could, after I abandoned it since my E72. I did not even care if she was taking a photo, being busy with my phone processing all the photos I took proudly with…Kutti was as usual in his own feelings, no one knows what it is…Parthi and wife were the only ones who seemed to be giving a pose…and no comments on what Mugunth and Kishore were trying to do :)   As the noon sun was bright up on the sky, we started moving towards Pongal and Puliyodharai. With a nominal priced canteen at the temple, we ordered each and everything on the menu and decided to share. Eventually we went for second serving on most of the items. DSC05030

Our next destination was the Space Center, NASA. It was 10 miles away from the temple, and we reached there in about 15 minutes. As soon as we entered the space center, cameras started taking shots of anything and everything that met the eyes. After watching a short movie followed by a run through the exhibits of a space station, highly impressed, Ramya and I decided to buy a plane for ourselves instead of our favorite yellow Corvette… ;)

More than the short movie, the space center had quite a number of exhibits and simulation games, which was worth learning and watching. I was expecting a EPCOT kind of space simulation ride, but that is way too much of an expectation for the ten bucks ticket cost. Only after the trip, talking to my uncle I came to know that NASA has exhibited the famous quotes of  “ஔவையார்”  (Auvaiyar)

“கற்றது கை மண் அளவு, கல்லாதது உலகளவு”

“What you have learnt is a mere handful, What you haven’t is like the world in its size”

which I never came across in this space center.

Next was the tram tour to the “Rocket Park” and “Mission Control Center”. The Mission Control Center, the way it looks, is more like my old Unix lab at college, ignoring what is being done at both places…then the Rocket park, reminded me of my visit to RCI, Hyderabad…watching a real Saturn V, was worth missing two return trams to the space center. It was time to try out the panorama mode on my phone camera, and I guess its not too bad for a mobile cam.


So that was all at Space Center, it was almost sunset, and Galveston Beach was 45 minutes away from NASA. Though it would be dark when we reach there, we still drove all the way. With nothing to see at the beach, we returned immediately. With several options for dinner…seeing Olive Garden crowded to the streets, we finally ended up grabbing several of those “5$ foot longs” from Subway, and headed our way back to Dallas.

Shutter Island

March 10, 2010 Comments off

Martin Scorsese’s main stream film starring Leonardo DiCaprio for the fourth consecutive time, Shutter Island, is based on the novel by Dennis Lehane. The story line is quite usual repeated in many movies of a psycho, killer, dual personality, etc. etc. But the movie is still a classic, portrays the experience of Martin Scorsese as a director. Leonardo has once again given a dramatic performance as in Blood Diamond and The Departed.


The movie is set in 1954, in an island hospital treating insane criminals. The story starts with  Edward (TEDDY) Daniels (Leonardo DiCaprio) from US Marshalls along with Chuck Aule (Mark Ruffalo), deputed for an investigation of a missing person in the hospital. With lot of resistance from the hospital chief Dr.Cawley (Ben Kingsley) to cooperate, Teddy takes the help of Chuck to explore the island and sets out in finding the truth.  In his attempt to reach the lighthouse, meets Rachel Solando the missing person, which unfolds the entire mystery about the island and Teddy decides to get away from the island.  When his accomplice Chuck goes missing, Teddy goes to lighthouse in search of Chuck. He does find Dr.Cawley and Chuck in the lighthouse.  What happens after that is the movie all about…

The movie ends with a question to the audience…

“Do you think it would be worse to live as a monster or die as a good man?”

Yet another classic from Martin Scorsese, depicting the concepts of guilt and redemption. Must watch! Definitely a nominee for Academy Awards!!!

Categories: random

Oracle TimesTen

March 4, 2010 Comments off

Database operations have always been expensive for any high volume application. There have been several techniques to cache data either during application deployment or application activation. Several cache loading mechanisms offer efficient algorithms for replacement policies as well.

The problem I would like to discuss here is a little different. An existing application probably with no thoughts of scalability has been designed and implemented without any caching mechanism. As a stable application, it works for low volume of data, but fails when the data volume exponentially increases. There is a need to plug-in a caching implementation somewhere to handle the suddenly increasing load. The complication comes when the caching mechanism has to connect to a database and sync up data very frequently and the application is deployed across multiple servers distributed. This requirement probably needs a design / code change in most of the situations. Most of the caching software that I came across so far does need a application design change at some point. Some of them do not support ANSI SQL or the Oracle standard.

On the other hand, application development and testing environments can afford mostly up to one or two database instances for several developers working simultaneously. It is not very uncommon that applications store all the configuration data in database tables and the configuration does differ for each environment. One thought would be to have a switch, to change between configurations in a db for functional testing and in a xml file for local / unit testing. But there definitely is a more effective solution to this.

TimesTen is a lightweight in-memory database and also provides caching with Oracle Database (only Oracle). TimesTen is simple to configure as a separate footprint. Does not involve the complexity of creating database, table space, etc. It could be easily connected to any Oracle database remote or local, with some few steps configurations. Not only that, from an application perspective, just a change in the data source configurations were required to enable caching.

In Windows, it took me exactly 10 minutes to configure TimesTen for my Weblogic Application server (more application servers are supported). Initial configuration needs a “System DSN” to be created from the Control Panel. The first time connect to the DSN using “ttisql” command line interface, a database gets created automatically. All the usual SQL commands can be then used to create users, tables, etc.

To connect with an Oracle DB and enable caching, just create a table space and a user in the Oracle DB for TimesTen to store its cache grids. And then its all configuration on the TimesTen database to create dynamic cache loading and performance tuning. I am not getting into any details, better to refer the extensive timesten docs.

Of course this solution for caching is very much limited to Oracle DB but is an ideal solution when an application code change is not viable. For the latter problem, this is one of the fitting solution, where each developer can have a separate instance of TimesTen and sync up with the remote oracle db whenever needed.

Categories: tech

Nokia E72

Nokia E72 – its been a week I bought it.

I have read several reviews of this phone, and most people have been comparing this with iPhone. Apples and Oranges are not same. Clearly this is a phone for business segment, and it does its job really well. Having said that, I must explain why.

A quick glance at its specifications would say most of what it can do. With a 16 million color display and 2.4 inch screen, a good enough resolution to watch a video on YouTube. Symbian S60 3rd Edition running on an ARMS 600Mhz with 128MB RAM and 4GB microSD extension, fast enough to run email, chat and other software. 5MP camera with a powerful flash, can take clear pictures even in low light. The keypad does invite one to type more, adding to it the optical navi key is certainly a smooth way to scroll through the items. The battery is a strong 1500mAh Li-ion and holds for a solid 2 days being connected to mobile internet or Wi-Fi as well as GPS when driving. With such a high end spec better than a Blackberry Bold and its thinner than iPhone, a price tag reading 300 USD is worth the buy.


The basic email and chat applications support Mail for Exchange, Lotus Notes, Google and Yahoo. The phone comes with Office 2007 editor from Quick Office package. It also has a VPN client, printer setup and multi-scanner (card reader software). If you need even more, Nokia Ovi does not let you down with a huge collection of apps to download. The Ovi maps are definitely a plus, with maps downloadable for most of the countries free. Fring and Nimbuzz are supported very well.

More than all this, the phone has a much better camera (5MP) unusual in a business phone, all the music software (MP3, FM, Recorder) and a good number of games.

A get-used-to factor which I count as negative in a way is the applications are installed all over the place. It really is difficult to remember and access them quickly whenever I need them. There definitely is a way to re-group the applications to where I need those, yet to figure out.

To conclude, this phone has certainly re-defined how a business phone should be. Definitely a competitor for all the RIM’s out there.

Categories: reviews