Bean Shell Compiler

Bean Shell makes your Java programs scriptable. Recently I started working on it. BeanShell provides its own JavaScript-like syntax to access your Java Objects. You can even change the syntax to anything you like using JavaCC. I started playing with it. BeanShell uses a Parser and Abstract Syntax Tree (AST) to tokenize the code. Here’s a small class for compiling the BSH script, before sending it to the interpreter.

JMX HelloWorld


JMX or Java Management eXtensions gives you the ability to manage programs remotely. I’ve been working on JMX in one of the SOA application. I would like to share how my first program in JMX has been written and deployed onto JBoss. The MBeans are also know as Platform MBeans (MBeans – Management Beans). You can use JMX to remotely invoke the function on an object. In layman terms, JMX MBeans can be used as "Remote Control" for the "Object that implements the MBean". Using the MBean the object’s operations can be invoked remotely. The JBoss application server has been constructed over a microkernel that uses JMX specification. Every service JBoss provides is an MBean or collection of MBeans. Different kinds of MBeans and notifications are not covered in this article. This article just explains two examples: The plain MBean (HelloWorld), and creating and deploying MBean in the JBoss as an SAR (Service Archive).

The HelloWorld MBean

As already told, MBeans are a way to control the Object remotely. A JMX Agent will expose the MBeans to the platform. Here are the setps to create the first Manageable Object using MBeans.
Step 1: Create the HelloWorldMbean class with sayHello method (Note: MBean interface to be named as ***Mbean):

Step 2: Create the Implementation for the MBean:

Step 3: Create an Agent that exposes the MBean to the platform, so that we can manage it remotely:

Once the three classes are created, compile all of them, and then run the Agent class using the command java com.vijaykiran.jmx.HelloWorldAgent If you are using Eclipse then, you need to set the VM arguements in the "Run…" dialog. If you want you can download the Zip file Eclipse Project at the end of the article. Now your Agent is running and exposed to the platform. If you want to invoke the function, goto command line and use the jconsole command to strart the JMX console. The command is in your Javabin directory.

Click on Connect, then goto MBeans Tab. You’ll find com.vijaykiran.jmx package on the left, and expand it to get the HelloWorld Mbean. And then select it and on the right pane, click on the Operations tab. You’ll find the sayHelloButton(). Click on it, and your method is ivoked via the exposed MBean.

XUL tutorial

Mozilla platform provides framework and components to develop crossplatform rich client applications. Mozilla platform contains various technologiy implementations like AJAx, CSS, HTML, DOM,JavaScript, XML, RDF, RSS, XUL, XSLT and XML.

Mozilla provides XPFE (Cross Platfrom Front End) Framework to build the rich cross platform applications. The XPFE contains three basic parts: XUL, JavaScript and CSS. XUL defines the interface, JavaScript is used to attach the behaviour and logic to the interface. CSS does similar part as with HTML, it provides styles and varaiations of the interfaces.

XUL is the XML User interface Language, which lets the developer build rich cross platform applications, that can be run online or offline. Since the behaviour, interface and locale&skin are completely disconnected, they can be very easily customized and localized. XUL is based on XML, so its very easy to learn and get started. In these series of articles I’ll try to explain how I’m developing a small application using Mozilla platform.


Mozilla Developer Wiki
XUL Planet


After reading the Bruce Eckel’s blog after a long time, I found an interesting and entertaining link to a book on ruby: Why’s (poignant) guide to Ruby . Being an extremely influence by Bruce, I got some conviction that there are only four REAL computer languages in the world other than Perl: C++, Java and Python. But this book seems to be re-orienting my views. I am going to download Ruby and let me check how far I can understand the real philosophy of the language.

Talking about learning a language, I feel that one should understand what the language is good for? Learning a new computer language gives me a new perspective to look at the problems. Besides learning the syntax, which is also essential part of the learning, one should understand the philosophy behind it. The way the language provides the abstraction of the solution space so that problems in the real world can be solved. The essential feature of any programmer is to map and abstract the problem space to the solution space. The problem space is the subset of the real world. It mightbe a domain (vertical) or any particular set of problems in one field. The solution space in the programmer’s perspective is composed of computers (Workstations, Servers, Network, and Memory). The basic purpose of the computer language is to provide tools for abstracting the solution space so that the real world or the entities of the problem space can be represented. And that’s why we have the Object Oriented programming.

Consider a problem space of manufacturing company’s one particular department: Accounts. In the problem space (Accounts department) we might have the following entities: Account, Accountant, Accounts Manager etc. But the solution space (software for accounts department) we are developing for the Accounts department will contain the computers/networks and memory. So the language we are going to use should be able to give us the facility to create the entities of account, accountant and manager. And it should take care of the essential conversion of the accountant (properties and behavior) into the computer’s memory. This is what essentially all the OO programming languages do.

I am going to start learn Ruby, will post more code here.

Coming to work place: I am working on design of three new prototypes to test feasibility. One of which is the protocol switching. I am currently writing some proof of concept coding.

More soon…..

Web Application Development using Perl

Perl is one of my favorite languages, especially because of its versatility. Perl is everywhere: CGI, GUI, Application Development, XML Processing, Database Accesss and of course System administration tasks.

The main challenge in developing a web-application is proper design. The decoupling of the static content from the dynamic content inside the individual pages is the trickiest part. I’ve used HTML::Template and Templete Toolkit modules for providing the templates. And the templates are filled in with real data using a Perl script. The HTML::Template module provides good flexibility of separating the dynamic parts of the page from the static content. But as far as the application is small, and there’s a harmony between the application-developer and the UI-designer of the web-app, everything seems to be perfect. But as far as the UI designer is concerned he/she must know how exactly the dynamic parts are being replaced by the application logic. Otherwise, it’s going to be a big mess.Particularly for large web-applications this doesn’t work. I guess same is the case with other template mechanisms. Unless the webpage designer knows how the templates and Perl work, it’s really hard to produce good web-application.

Perl is supported by major web-servers: Apache, IIS etc. Apache has also mod_perl (kind of embedded Perl interpreter) which provides fast, in fact very fast execution of Perl Script. The main idea of using mod_perl is to get access to the Apache API itself, and extend the web-server to provide our we-app functionality, that means: essentially turning your web-servers into web-app-server. The mod_perl can do wonders for large web-sites or web-applications. With all the power of Perl and the super stable Apache, completely reliable applications can be built.