Performance Analysis of J2EE Applications Using AOP Techniques

Performance Analysis of J2EE Applications Using AOP Technique by Ramchandar Krishamurthy

It’s tricky to profile a J2EE application to find performance bottlenecks; it’s even trickier to do this with a production system, without introducing instability or new slowdowns. Aspect-Oriented Programming (AOP) offers a means of injecting new code, such as performance metrics, into existing code, without re-compiling. Ramchandar Krishnamurthy shows how this can be done.

http://www.onjava.com/pub/a/onjava/2004/05/12/aop.html

XML-RPC, ATOM and Blogger backup utility

Just read an awesome blog entry by Anand Sharma about his attempts to understand XML-RPC, blogging API’s and Erik’s Linkblog. Anand does a great job in walking through his discovery of XML-RPC and ends up writing a standalone client and a XML-RPC server in the process. Its fun to learn new stuff, especially when it alls ends up working in the end.

I was really excited to read this blog entry as I am writing a little Java client to download and backup my Blogger posts. Between my 3 blogs, I have over 300 blog entries and I wanted to write something to periodically download all my posts and save them locally. I’m finished writing a command line version of the tool and am now hoping to add a Swing GUI to make it a little more user-friendly before I release it here. I’ve been looking for an excuse to learn more about IDEA 4.0’s GUI designer. :)

Bill Gates, Blogs and RSS

My brother just sent me a link to a Reuter’s article entitled Microsoft’s Gates Touts Blogging as Business Tool. The article quotes Bill Gates where he talks about blogs, how they are distributed and how they can be used as business communication tools. He goes on talking about RSS and how it’s getting away from the drawbacks of e-mail and the drawbacks of a Web site.

Now that Blogs and RSS are on Gates’s radar, we should see some serious movement from Microsoft in blogspace. Microsoft was late to the Internet revolution, dismissing it initially before adopting it and employing the standard ’embrace, extend and annihilate’ strategy. Now that they are focusing on blogs, I wonder what will come next. With Microsoft throwing their support behind RSS and Google backing ATOM, I think we may end up with a standards war.

I’ve also been following the W3C offer to the Atom community to pursue its standardization effort work in the W3C vs. the IETF. I don’t understand the subtlety of W3C vs. IETF and what that means to ATOM in the end, but it does make sense that W3C shepherd ATOM as they have HTML, XHTML, XML and other relevant technologies in their purview.

Update: Just saw another article on the same topic on the Guardian Unlimited. Very interesting read.

J2EE Startup/Shutdown classes

Debu Panda had an interesting blog entry about something that’s always bugged me. Most J2EE applications require you to invoke some functionality at the server startup or application deployment time. For example, you may want to preload some data cache or invoke some business logic or invoke some logic at server shutdown to gracefully disconnect from some service you’re connected to or release some resource. As Debu points out in his blog entry, each container vendor offers a proprietary way to do this. I think this is a huge deficiency in the J2EE specification and I hope it is something that’s addressed in the next iteration of the specification.

I’ve come up with a solution that I have used over the years that is container independent for applications deployed in WebLogic, JBoss and Tomcat. It’s not really rocket science, but I use a Servlet as my startup and shutdown class by taking advantage of the servlet lifecycle and the init() and destroy() methods.

Most web containers will create an instance of the servlet by calling the no-args constructor. Once the instance is created, the container will then call the Servlet’s init() method. The init() method is guaranteed to be called only once during the Servlet’s lifecycle which makes it use as a startup class work perfectly. The same goes for the destroy() method, which is also guaranteed to be called only once and that makes it an ideal candidate as a shutdown class.

To load the servlet on deployment or server start-up, just enable the load-on-startup attribute of the servlet. Here’s what the web.xml looks like for the startup servlet:







    
        startupServlet
        com.j2eegeek.servlet.util.StartupServlet
        9
    

    
        startupServlet
        /startupServlet
    



Here’s the fully commented servlet (HTML | Java) that does the acts as my startup class. Comments on other ideas are always welcome.

Wisconsin Java User Group meeting

The next meeting of the Wisconsin Java User Group just snuck up on me. The next meeting is on Wednesday, May 19th and it will feature John Carnell. The topic of the meeting is Jython in Action and John will demonstrate how to leverage the Java-based Python interpreter Jython to build and extend your own Java applications.

John is a friend I want to be there to heckle him. Richard got me hooked on Groovy and I’ve spent quite a lot of time with Groovy recently and it would be nice to compare and contrast Jython vs. Groovy. But I’m hooked on Groovy and not sure if I’ve got the time and energy to play with something new.

Hope to make it there!