Saturday, March 31, 2007

Using Quartz Scheduler in a Java EE Web Application

At times, you may have wanted to perform some action periodically in your web application. Quartz is an enterprise grade scheduler which can be used for such a task. Read here for the complete list of features of Quartz. For using the Quartz scheduler library in a Java EE web application, following needs to be done:
  • Include the quartz jars (quartz-all.jar and others in the lib path). In my case, some of the commons-xxx.jar files were already included in the project due to the dependency of another library (displaytag) on those jar files. So in my quartz setup i had to disinclude them. In the lib/build path, i only included, jta.jar and also everything which was not already there in the project from lib/optional path too (they are not many anyway).
  • We then had to create the tables required by quartz for storing job details and triggers across restart of application. This is an optional feature but an important one (which made us decide to use quartz in the first place over the JDK Timer). We used the docs/dbTables/tables_mysql.sql script to create the tables.
  • Then we copied (example_quartz.properties), modified and saved the quartz.properties file in the project and changed the packaging settings to include the properties file in the WEB-INF/classes path in the IDE. In the properties file, we changed the configuration to have quartz point to the data store we created in step 2.
# Configuring Main Scheduler Properties
org.quartz.scheduler.instanceName = MyScheduler
org.quartz.scheduler.instanceId = 1
org.quartz.scheduler.rmi.export = false
org.quartz.scheduler.rmi.proxy = false

# Configuring ThreadPool
org.quartz.threadPool.class = org.quartz.simpl.SimpleThreadPool
org.quartz.threadPool.threadCount = 30
org.quartz.threadPool.threadPriority = 5

# Configuring JobStore
org.quartz.jobStore.class = org.quartz.impl.jdbcjobstore.JobStoreTX
org.quartz.jobStore.driverDelegateClass = org.quartz.impl.jdbcjobstore.StdJDBCDelegate
org.quartz.jobStore.useProperties = false
org.quartz.jobStore.dataSource = quartzDS
org.quartz.jobStore.tablePrefix = QRTZ_
org.quartz.jobStore.isClustered = false

# Configuring datasource
org.quartz.dataSource.quartzDS.driver = com.mysql.jdbc.Driver
org.quartz.dataSource.quartzDS.URL = jdbc:mysql://localhost:3306/mydb
org.quartz.dataSource.quartzDS.user = me
org.quartz.dataSource.quartzDS.password = secret
org.quartz.dataSource.quartzDS.maxConnections = 31

# Rest of config was retained from example_quartz.properties.
  • We added following lines to our web.xml:
<servlet>
<description>Quartz Initializer Servlet</description>
<servlet-name>QuartzInitializer</servlet-name>
<servlet-class>org.quartz.ee.servlet.QuartzInitializerServlet</servlet-class>
<init-param>
<param-name>shutdown-on-unload</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>start-scheduler-on-load</param-name>
<param-value>true</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>


This sets up the initializer servlet which can initialize the default scheduler and start the scheduler at application bootstrap time.
  • Now in our webservice/jsp/servlet of our web application we do the following:
try {
// A. Get the default scheduler.
Scheduler sched = StdSchedulerFactory.getDefaultScheduler();

// B.Generate a unique name identifier for jobs and
// triggers of your application as required.
// One way is to use hashCode() if its a string param.
String dataToPass = "someParamToPassToJob";
int id = dataToPass.hashCode();

// C. Create/Replace a poll job and add it to the scheduler.
JobDetail job =
new JobDetail("job_"+id, "SomeJobGroup", com.mycompany.MyJob.class);
job.setRequestsRecovery(true);
// Pass data to the poll job.
job.getJobDataMap().put("param", dataToPass);
sched.addJob(job, true);

// D. Create a Trigger with unique name
SimpleTrigger trigger = new SimpleTrigger("trig_"+id, "SomeTriggerGroup");


// E. Check if a trigger is already associated with this job
// This step is optional and depends on your application's requirement.

Trigger[] jobTriggers;
jobTriggers = sched.getTriggersOfJob("job_"+id, "SomeJobGroup");

boolean isTriggerAlreadyAssociated = false;
for (Trigger trig : jobTriggers) {
if (trig.getName().equals("trig_"+id) &&
trig.getGroup().equals("SomeTriggerGroup")) {
// the job already has this trigger associated with it
isTriggerAlreadyAssociated = true;
}
}

// F. Associate this trigger with the job
trigger.setJobName(job.getName());
trigger.setJobGroup(job.getGroup());

// G. Initialize the trigger with duration and resolution to fire
trigger.setStartTime(startTime.getTime());
trigger.setEndTime(endTime.getTime());
trigger.setRepeatCount(SimpleTrigger.REPEAT_INDEFINITELY);
trigger.setRepeatInterval(repeatInterval); //in milliseconds

if (isTriggerAlreadyAssociated) {
// Reschedule the job with the existing trigger.
sched.rescheduleJob("trig_"+id, "SomeTriggerGroup", trigger);
} else {
// Schedule the job with the new trigger.
sched.scheduleJob(trigger);
}
} catch (SchedulerException se) {

}
  • Of course, the last thing is to write the Job class which does the actual work. The following is code from examples of Quartz.
public class PrintPropsJob implements Job {

public PrintPropsJob() {
}

public void execute(JobExecutionContext context)
throws JobExecutionException {

JobDataMap data = context.getJobDetail().getJobDataMap();
System.out.println("someProp = " + data.getString("someProp"));
System.out.println("someObjectProp = " + data.getObject("someObjectProp"));
}
}
  • Some important points to note about jobs and triggers:
  1. Jobs have a name and group associated with them, which should uniquely identify them within a single Scheduler.
  2. A Job can be associated with multiple triggers.
  3. Triggers are the 'mechanism' by which Jobs are scheduled.
  4. Many Triggers can point to the same Job, but a single Trigger can only point to one Job.
  5. JobDataMap holds state information for Job instances. JobDataMap instances are stored once when the Job is added to a scheduler. They are also re-persisted after every execution of StatefulJob instances.
  6. JobDataMap instances can also be stored with a Trigger. This can be useful in the case where you have a Job that is stored in the scheduler for regular/repeated use by multiple Triggers, yet with each independent triggering, you want to supply the Job with different data inputs.
  7. The JobExecutionContext passed to a Job at execution time also contains a convenience JobDataMap that is the result of merging the contents of the trigger's JobDataMap (if any) over the Job's JobDataMap (if any).
  8. We can have different job types:
  • Stateful Jobs - where state passed to job (in JobDataMap) is remembered (like static values) across executions of the job. Also, stateful jobs are not allowed to execute concurrently, which means new triggers that occur before the completion of the execute(xx) method will be delayed.
  • Interruptable job - provide a mechanism for having the Job execution interrupted by implementing a callback method interrupt(), which will be called when scheduler's interrupt method is invoked on the Job.
That's all, in short, about how to integrate Quartz scheduler library in a web application.

Saturday, March 24, 2007

Is it okay to put business logic in stored procedure?

In my experience, i have come across maintaining some software where the business logic was written in stored procedures (or functions/triggers). Recently i collected some points on why this is not such a good idea. The main reason for the use of stored procedures in one product was to have multiple client types to be able to invoke the same business logic. But then we can achieve the same effect applying MVC (model view controller) pattern and keeping the model/business logic in the application code rather than stored procedure. Here are some other reasons why its not a good idea to write BL in stored procedures:

NOTE: Most of the ideas presented below are excerpted from this article.

1. If there are more than one interfaces and the BL is part in stored procedure and part in presentation tier then it becomes a maintenance headache to keep the different presentation tiers in synch.

2. Stored procedures form an API by themselves. Adding new functionality or new procedures is the "best" way to extend an existing API.This means that when a table changes, or behaviour of a stored procedure changes and it requires a new parameter, a new stored procedure has to be added. When stored proc is changed, the DAL/BL code needs to change too to call the changed/new stored proc whereas, if the SQL is generated on the fly from the DAL/BL code and there is no stored proc then only DAL code will change.
Microsoft also believes stored procedures are over: it's next generation business framework MBF is based on Objectspaces, which generates SQL on the fly.
In Java world, ORM (Object to Relational Mapping) frameworks like Hibernate and TopLink (and now Java Persistence Architecture, JPA) are meant to generate SQL on the fly too.

3.Business logic in stored procedures is more work to test than the corresponding logic in the application. Referential integrity will often force you to setup a lot of other data just to be able to insert the data you need for a test.Stored procedures are inherently procedural in nature, and hence harder to create isolated tests and prone to code duplication. Another consideration, and this matters a great deal in a sizable application, is that any automated test that hits the database is slower than a test that runs inside of the application. Slow tests lead to longer feedback cycles.

4. While stored procedures may run faster, they take longer to build, test, debug and maintain, therefore this extra speed comes at a price.

5. BL in stored procs does not scale - If you have a system with 100's of distributed databases it is far more difficult to keep all those stored procedures and triggers synchronized than it is to keep the application code synchronized.

6. Locked in to the DB for which stored procs are written.

7. Porting the data will be one exercise, but porting the stored procedures and triggers will be something else entirely. Now, if all that logic were held inside the application, how much simpler would it be?

All changes made to the database can be logged without using a single database trigger. How? By adding extra code into the DAO to write all relevant details out to the AUDIT database. This functionality is totally transparent to all the objects in the Business Layer, and they do not need any extra code to make it work.

Friday, March 23, 2007

An Events Browser - Using Displaytag and DWR



Problem:

To view application-specific events in the web browser.

Requirements:
The implementation should satisfy the following requirements:
  1. support viewing all the logged events (in a DB) with provision for specifying the number of rows per page to show in a data grid of event records.
  2. support pagination.
  3. support sorting on columns like event time, id, type etc.
  4. support exporting events data to CSV, excel etc formats.
  5. change row color to highlight rows based on severity of events.
  6. enable viewing live events instantaneously as they occur.

Solution:
The first 5 requirements are easily met by Displaytag, an excellent JSP tag library for displaying data grids. We can also enable AJAX support for displaytag data grid pagination and sorting using ajaxtags library.

We did not like the live grid type views (which may be better suited to the search examples) for our requirement as we believe the pagination with Ajax support is more appealing and common experience for users.

The last requirement is met by DWR 2.0 (which as of this writing is still being developed and the current release is 2.0 RC2). DWR 2.0 has a new feature called Reverse AJAX, which enables pushing the data from server to browser client, asynchronously.

So, we have two data grids in our UI;
  1. First data grid, displays the existing event records from the DB.
  2. Second data grid, displays the live events using DWR's Reverse Ajax feature. One can use the recently added proxy for scriptaculous Javascript effects library, to highlight the new rows as they get added to the live events data grid. Adding new rows to the HTML table is facilitated by org.directwebremoting.proxy.dwr.Util class' addRows(String elementId, String[][] data) method. The implementation can choose to route the events to all browsers or selected browser sessions only - an event routing behavior. An example on reverse ajax feature is found here (see stock ticker).
The user can navigate the existing data, paginate, sort, export and at the same time can continue to view the live events being added to the second data grid.


I did further work on improving the way the events displayed in the live events section above. The live events section which uses reverse ajax to asynchronously display events occurring in near real-time, is best kept separated from the archived events browser above. So the live events page can be made to show only the specified size of latest events in a queue fashion (where new incoming events replace some of the existing events (on an oldest removed first basis) when the defined window limit is reached). So if window limit is say 20 events, and we have the latest 19 events displayed so if there are 2 new events to show, we remove the last 1 event from the existing 19 and show the 20 events with the latest 2 being shown at top of the table. The window limit is a client side parameter and can be (re)set by the user. The events will need to be cached locally on the clients to be able to display the lastest on top (as addRows() API of DWR will only append to the table tbody). Also, by caching the events locally, we can easily control the window size. The idea to have a limit to the number of live events is required as we cannot just keep the events table growing forever as the user may just want to see the latest 20 or 50 or 100 or 1000 (some limited set of real time events only as he also has the archived events table to study a past event for analysis). The purpose of the live events table is to alert the operator at the time the event occurs so that he/she can do further analysis by studying the archived events or doing some data collection on the supposedly affected elements.

Saturday, March 10, 2007

Started learning Kenpo Karate

I have started attending Kenpo Karate (one of the forms of Karate martial arts) classes today at a local training institute. Today i attended the first class and learned about some basic stances and some ways to block an attack. The best part is the initial warm up exercise that we get to do in a group. It was very tiring for the first day and we did it for 30mins. There will 3 classes per week and 1.5hr per class.

It was in 1993 that i attended Taekwon-do martial art classes for 3 months but had to leave it because of the study pressure. I joined a gym when i got into engineering college in 1994 and for the first year i could go to the gym regularly but slowly with mounting study pressure i became irregular with gym too and though i continued on an irregular basis till i got my first job in 1999, i could not keep up with gyming once i was in Banglore in the winter of 2000. We had a gym in my Bangalore apartment too but i never could kindle the fire to exercise there. But it has been my desire always to keep fit (as also noticed in this blog's name: FitProgrammer@Work) and when it was time to come to the USA i decided i will get trained in Boxing in USA. But my wife was not very happy with that idea :) considering the first impression one has of Boxing is that its associated with gore. I could not find a local boxing institute in the Maynard region (the nearest was 15mi from my residence) but i could find one martial arts training center very close to my workplace (0.2mi from both my residence and workplace - literally on the way between my residence and work place). Martial arts is not going to be as dull as going to a gym where you train yourself alone and so you require to be very self motivated to persist in the regimen. My experience has been that i tend to loose the fizz with time when i went to gym. I persisted better with martial arts. Probably the idea of exercising in a group environment appeals more to my psyche.

So lets see how it goes... i will keep posting on my learnings in Kenpo(aka Kempo) Karate.

Updates:
6 May, 2007: I have learnt all that is required of a non-ranked student of Griffin Kenpo which includes,
  1. Basic stances and Half-mooning
  2. Kicks - Iron broom, dropping knees, sliding knees, front, back, side, hook, crescent, reverse crescent and their combinations.
  3. Punches and 8 Blocks
  4. Rolling and Falling
  5. 3 techniques to free my hand when caught
Though i should have completed this learning much earlier but for some or the other reason i was not regular in my classes but the good thing is that i am continuing to learn Karate and i am enjoying it a lot.

Thursday, March 08, 2007

Integrating Java and PHP: the Web Services way

Recently on a project, we were faced with the question:
  1. do we put the business logic in the web tier (which was written in PHP 4.7.3) or
  2. do we write the business logic in Java (better tools for development, reliable libraries for some of the tasks we wanted to perform as a part of our business logic, better OO language features than PHP, easy to debug in an IDE, code hidden in class files).
The first option was what we usually call the model 1 architecture, where business logic is written in the same script which serves the presentation code.

In the second approach, we were getting to the point of introducing the MVC pattern to our PHP based web tier by introducing a Java layer to play the model and let PHP scripts be controller and view. This had the added advantage that we could leverage the model written as Java web services in other clients (and we did have other clients than web interface too for our product which provided an alternate interface for user/program to interact with our product and hence we required that the business logic we write for our web interface could be leveraged in other client types too, written in other languages, possibly, which in our case was C/C++). Hence, we opted for the 2nd choice.

We had two options for integrating Java and PHP:
  1. Do it using PHP/Java bridge
  2. Expose the business logic written in Java as web services.
The bridge option is not well supported as of this writing in the PHP world. The Java extension for PHP language is labeled as experimental. So we decided to go with the other option.

Our business logic did not necessitate the use of EJBs (did not require container managed transactions or persistence) for the present, so going the Java path to write our business logic, we wanted to use Tomcat as web container (which could easily be integrated with the Apache web server, running the existing PHP code, using mod_jk(2)).

We developed our web services in Java using the latest JAX-WS 2.1 RI library, primarily because JAX-WS spec makes writing web services in Java pretty easy as compared to the predecessor JAX-RPC 1.1 release (aided by annotations, no more of XML hell). We also made a design choice to use the document/literal style of messaging for maximum flexibility. Here's how a typical JAX-WS code looks:

MyWebServiceImpl.java:

@WebMethod
public MyClassA myWebMethod(
@WebParam(name = "aParam") int aParam) throws MyAppExceptionA, MyAppExceptionB { //.. implementation code }


We chose to use the nusoap 0.7.2 as the PHP web service stack and here's how a typical WS client was written in PHP using nusoap:
client.php:

<?php
require_once('../lib/nusoap.php');

// create a soapclient from wsdl url
$wsdl = 'http://192.168.1.101:8080/MyWebservices/MyWebServiceImpl?wsdl';
$client = new soapclient($wsdl, true);
$err = $client->getError();
if ($err) {
// Display error
}

// specify the soap body content for doc/literal request
$msg = "<web:mywebmethod xmlns:web="\"http://webservice.mycompany.com/\"">
<aparam>3334</aparam>
</web:mywebmethod>";

$namespace = 'http://webservice.mycompany.com/';
$method = 'myWebMethod'; // web method to invoke

$result = $client->call($method, $msg, $namespace, '', false, null, 'document', 'literal');

// Check for a fault
if ($client->fault) {
// Here is how we can do exception handling.
$myAppExceptionA = $result['detail']['MyAppExceptionA'];
if ($myAppExceptionA) {
print "Exception: ". $myAppExceptionA['message'];
}

$myAppExceptionB = $result['detail']['MyAppExceptionB'];
if ($myAppExceptionB) {
print "Exception: ". $myAppExceptionB['message'];
}
} else {
// Check for errors
$err = $client->getError();
if ($err) {
// Display the error - You will not come here in working condition :)
} else {
// Display the result
print_r($result);
// Grab the values in the $result array
}
}
?>

Nusoap stack on PHP end will convert the result in an associative array (as shown in the case of fault handling in the code above). To know the structure of response message to get more clarity on how to extract the data out of result, you can add the following 3 magic debug statements towards the end of the above PHP client code:

echo "<h2>Request</h2><pre>" . htmlspecialchars($client->request, ENT_QUOTES) . "</pre>";
echo "<h2>Response</h2><pre>" . htmlspecialchars($client->response, ENT_QUOTES) . "</pre>";
echo "<h2>Debug</h2><pre>" . htmlspecialchars($client->debug_str, ENT_QUOTES) . "</pre>";

I also used the SoapUI tool (version 1.6) for unit testing my web services and found it to be very useful, especially when we needed to know the exact soap request body content which we needed to embed on the PHP side while invoking the web method. You can do several things with this tools, like generate request templates which you can fill with values to test individual web methods, save such requests and do regression testing later, save the requests to do load testing, view test reports etc.


That's in short about how we can get PHP web tier to invoke methods on a Java web service based business logic tier. I had initially had some trouble in figuring out the way to pass the right arguments to the soapclient() method of nusoap library and after some web searching we could identify how to get it working.

As an aside, this was my first experience of working with PHP language and in my self learning mode i used WAMP distribution (version WAMP5_1.6.5 which includes PHP 5.1.6, Apache 2.0.59, MySQL 5.0.24a and phpmyadmin 2.8.2.4) to quickly setup an environment on my Windows workstation for experiments. I also found the EasyEclipse for PHP (version 1.2.1.1), a very useful IDE for PHP development. And a book i use as reference (only when i need to know how a certain programming thing is done in PHP) is Programming PHP by Kevin Tatroe, Rasmus Lerdorf, and Peter MacIntyre. Its excellent book and has stood by me till date.

The opinion i have formed about PHP till now is that its ideal for a model 1 architecture web application. Its better in such cases than say Servlets/JSP duo because of its simplicity in terms of programming constructs. It simply does not have those advanced features of JSP tag libraries. So for developers who are not fussy about mixing their HTML code with some PHP scripts and have a previous background in Perl or some other such dynamic languages, will be more at ease with PHP than say Java development. Java is object oriented language (a hybrid one though like C++) but PHP is object based (ie PHP has construct for defining classes as Perl but it does not support inheritance, polymorphism etc). So most of the PHP code is more or less procedural, at least thats what is more commonly done (like you are programming in C and creating libraries of functions). Also PHP eases the learning curve as its a dynamic language and does not have standard data types other than arrays (indexed and associative) and scalars. Of course you can define your ADTs but most of the time you will be good working with arrays alone. The arrays in PHP are like a mix of Java's ArrayList and HashMap ie you can use an array as an indexed or associative one. So, in general, i feel if there is a simple web application where all that has to be done is create a catalog out of a database and then allow CRUD using web forms then PHP (and hence model 1 architecture) is suitable, since it gets the work done quicker and resulting code is maintainable. But if you want to support multiple client types (hence model 1 architecture is not what you want) and probably need some advanced middleware services (like persistence, security, transactions) then you are better off with Java EE and other such frameworks.

Share your thoughts by leaving your comments.

Friday, January 26, 2007

My new abode

I am moving to a beautiful city called Maynard. Its been a while that i could post to my blog as i had been busy in setting myself up in the new place. I moved to the US on 17th January to work at a startup in the cable (HFC) broadband access technology domain. The clock tower seen prominent in the picture above, is my new place of work (and surprisingly its also called the Clock tower place) :).

Sunday, December 31, 2006

Year 2007: My Self-Study Goals

In the past year of 2006, i took 4 Sun certifications (that includes Java SE 5.0 programmer, J2EE 1.4 Webservices developer, J2EE 1.4 Web component developer and J2EE 1.3 Business component developer) and 2 trainings ( Oracle workforce development program's Introduction to Oracle 9i SQL and Program with Oracle 9i PL/SQL). In short, i invested a lot of effort and time in learning of Java EE based enterprise application development, which became the major focus for me last year. I wanted to cover every aspect of web application development in my learning, right from CSS, JavaScript, Ajax, XHTML on client tier to Servlets/JSP/Struts 1.2 on Web tier to EJB 2.x for Business tier and lastly, relational database SQL and PL/SQL on EIS tier. I also covered Webservices (in great details) which has become a very important tool for A2A (ie EAI) and B2B integrations. Learning of Webservices and my score of 88% in SCDJWS 1.4 exam really makes me feel good as i have felt that Webservices will be a good substitute for SNMP in the network management domain (the domain in which i continue to specialize).

This year (2007) i intend to continue with learning of EJB 3.0 and JSF 1.2 to begin with. I have also started a project BaseApp (a kick-starter application for development using Java EE 5.0). I also have intentions to learn a bit about JBoss Seam framework (since its on standards track and is a framework built around EJB 3 and JSF). I also think that EJB 3 and JSF 1.2 together with up coming Web beans (or current JBoss seam) will be a strong (and standard) contender to Spring framework. So i will be focusing a lot on Java EE this year too.

Also the goal will be complete BaseApp. For now, baseapp happens to be open ended enterprise but we will soon be defining the requirements for the first release formally.

A few things i missed to complete last year are the reading of,
  1. H F Design patterns
  2. JUnit in Action
  3. J2EE Design and Development
  4. H F HTML with CSS & XHTML
  5. Get SCEA certification
  6. BPEL and WSDM/WS-Man
  7. Ruby/Perl
I think with work and the above tasks identified, i will have enough on my plate for this year.

Friday, December 29, 2006

EJB3 development using JBoss 4.0.5.GA

I encountered an issue today while redeploying EJB 3 jar for hot deployment to JBoss 4.0.5.GA which i installed using the JEMS installer 1.2.0 CR1. The issue and the resolution is mentioned here. You will need to install the JBoss EJB 3 RC 9 Patch 1 to fix it. For EJB3 development with JBoss 4.0.5.GA, you must use the JEMS installer only and not the archive releases.

I continue to see the issue of Wrong target message being thrown and the workaround for now is to restart the JBossAS which fixes the issue. EJB 3 RC 9 patch 1 does not do anything to solve this issue (and i found that one of the issues marked as dependent to this issue has been reopened recently). So expect a fix only by early Jan 07. For now reboot is the best bet.

Also i found that you need to have JSE 5.0 only to run your application. Even though the docs say that JDK 1.5+ is supported but you get a strange issue of "Could not dereference object" on deployment of Stateful session beans (see this). So i had to change back from JSE 6.0 to 5.0 in Eclipse.

At one point i really was planning to switch from JBoss to Glassfish :). But for now it seems i am back on track with some workarounds to continue my learning of EJB 3 using JBoss AS.

BTW, Mikalai Zaikin's notes on SCBCD 5.0 exam has a very nice appendix/tutorial (replete with screen caps) for how to develop using JBoss 4.0.5.GA + Eclipse 3.2.1 + WTP 1.5 + JBoss IDE 2.0.0.Beta 2. What's missing is how to use hibernate entity manager JPA implementation for RESOURCE_LOCAL transactions in a JSE standalone application. You will find this documentation useful for this.

If you are planning on using JBoss AS for a green field (from scratch) EJB 3.0 project and Eclipse is your IDE of choice, then you can find the instructions at following URL useful:
Eclipse + JBoss AS + EJB 3.0 setup instructions by Eric Garrido
Starter Skeleton Eclipse Project on JBoss Wiki site

Wednesday, December 27, 2006

Web Beans: JBoss Seam being standardized for Java EE 6 release

Web Beans JSR 299 proposal by JBoss (RedHat Middleware LLC) has been approved unanimously by the JCP executive committee even though IBM and BEA Systems have expressed their concerns regarding it being (too?) ambitious. Following is what they had to say:

------------------------------------------------------------------------------
On 2006-06-05 BEA Systems voted Yes with the following comment:
This appears to be a sufficient challenge to achieve, but, in light of the overwhelming support at this stage of the process, we are prepared to see it go ahead.
------------------------------------------------------------------------------
On 2006-06-05 IBM voted Yes with the following comment:
Delivering on the deep level of integration that is proposed appears to be an ambitious task.

In short, the goal of this initiative is: to enable EJB 3.0 components to be used as JSF managed beans, unifying the two component models and enabling a considerable simplification to the programming model for web-based applications in Java.

The benefit will be: this work will provide a programming model suitable for rapid development of simple data-driven applications without sacrificing the full power of the Java EE 5 platform. This is a domain where Java EE has been perceived as overly complex.

Gavin King (Hibernate founder) is the spec lead for this effort which is targeted for release of a RI with Java EE 6 (fall 2007). This is also the first time that JBoss is leading a standard spec.

Some links to learn more about what Web Beans will offer are:
Gavin's interview by InfoQ on JBoss Seam
Proposed spec description for JSR 299
What Matt Raible (author of Spring Live and AppFuse founder) said about Seam
The JBoss Seam Demo
The JBoss Seam Documentation
JBoss Seam FAQ

What excites me?
Seam is an ambitious full stack framework (unifying and integrating technologies such as Asynchronous JavaScript and XML (AJAX), Java Server Faces (JSF), Enterprise Java Beans (EJB3), Java Portlets and Business Process Management (BPM)) which enables EJB 3.0 components to be JSF managed beans. So your EJB 3.0 beans could become your Action classes and the glue code which was required earlier for enabling Actions to invoke methods on beans in the business tier will go away thus simplifying the development effort required.
Some specifics from the proposal as quoted by Floyd Marinescu at InfoQ are:

  • Changes to EJB 3 that will be needed for EJB's to act as JSF managed beans.
  • Annotations for manipulating contextual variables in a stateful, contextual, component-based architecture.
  • An enhanced context model including conversational and business process contexts.
  • Extension points to allow the integration of business process management engines.
  • Integration of Java Persistence API extended persistence contexts. (The other type of persistence context is transaction-scoped persistence context.)
Now thats what makes Web Beans a full stack framework! :) Here's one Seam Book by JBoss insiders.

Some notable aspects of Seam:
  1. State management: Most other web frameworks store all application state in the HTTP session, which is inflexible, difficult to manage and a major source of memory leak. Seam can manage business and persistence components in several stateful scopes: components that only need to live across several pages are placed in the conversation scope; components that need to live with the current user session are placed in the session scope; components that require interactions from multiple users and last extended period of time (i.e., survive server reboots) are placed in the business process scope. The advanced state management facilities allow us to develop web application features that are previously not possible, or very difficult, to implement.
  2. Multiple browser windows/tabs: Seam supports fine-grained user state management beyond the simple HTTP session. It isolates and manages user state associated with individual browser window or tab (in contrast, HTTP session is shared across all windows of the same browser). So, in a Seam application, each browser window / tab can become a separate workspace that has independent history and context. Multiple user "conversations" can be supported for the same browser. This behavior is similar to that in rich client applications.
  3. Handling back-button navigation: Seam's nested conversation model makes it really easy to build complex, stateful applications that tolerate use of the back button.
  4. Support for REST style bookmarkable URL: it is very easy to expose REST style bookmarkable URLs in a Seam application. In addition, the Seam application can initialize all the necessary backend business logic and persistence components when the user loads that URL. This way, the RESTful URL is not only an information endpoint but also an application interaction start point.
  5. Support for JSR 168 portlets.
  6. Support for internationalization.
  7. JBoss Eclipse IDE provides a sophisticated, template-driven database reverse engineering tool which can generate an entire Seam application in minutes and a graphical jPDL editor for editing Seam pageflows and workflow definitions.

Friday, December 22, 2006

Sunday, December 10, 2006

Using Subversion for your open source project



Subversion has been an open source contribution by CollabNet folks which improves over CVS. The Subversion project started in earnest in February 2000, when CollabNet offered Karl Fogel a full time job developing a replacement for CVS. Karl Fogel and Jim Blandy had previously founded Cyclic Software which provides commercial support for CVS. Subversion was designed from the ground up as a modern, high-performance version control system. In contrast to CVS, which had grown organically from shell scripts and RCS, Subversion carries no historical baggage. Subversion takes advantage of a proper database backend (Berkley DB), unlike CVS which is file based. The Subversion team have tried to make the new system similar in feel to CVS, so users are immediately at home with using it. Most of the features of CVS including tagging, branching and merging, are implemented in Subversion, along with host of new features:

  • versioning support for directories, files and meta-data
  • history tracking across moves, copies and renames
  • truly atomic commits
  • cheap branching and merging operations
  • efficient network usage
  • offline diff and revert
  • efficient handling of binary files

Salient points about Subversion:
  • Subversion is a centralized client-server version control like CVS, VSS or Perforce.
  • Advanced network layer: the Subversion network server is Apache, and client and server speak WebDAV(2) to each other. This gives Subversion an advantage over CVS in interoperability, and provides various key features for free: authentication, wire compression, and basic repository browsing.
  • It's free: Subversion is released under an Apache/BSD-style, open-source license.
  • Like CVS, Subversion has a concept of a single, central repository (often residing on a dedicated server) that stores all data about the projects you are working on. This data is called a repository. You never work in the repository directly, though. Instead, you pull subsets of it into working copies that typically reside on other systems such as your desktop computer. In these working copies, you make your changes, and when you are pleased with them, you commit those changes into the central repository where they become once and forever part of history.
  • Each commit (also called a check-in) to the repository is called a revision, and, in Subversion, revisions are numbered. A commit can be a change to one file or a dozen, to directories, or to metadata.
  • We speak of HEAD when we mean the latest version of the repository; so, when you check in revision 17, then HEAD is revision 17.
  • Atomic Commits: In Subversion, a commit is an atomic operation, meaning it either succeeds entirely or fails entirely; unlike CVS, you can't end up with half of your files saved to the repository but the other half unchanged.
  • Not only does Subversion offer version control of files and directories, it also offers version control of metadata. In the world of Subversion, such metadata is called a property, and every file and directory can have as many properties as you wish. You can invent and store any arbitrary key/value pairs you wish: owner, perms, icons, app-owner, MIME type, personal notes, etc. This is a general-purpose feature for users. Properties are versioned, just like file contents. And some properties are auto-detected, like the MIME type of a file (no more remembering to use the -kb switch).
To read about a quick intro to the setup of a local subversion repository (ie svnadmin create) and how to use the basic svn client commands (checkout, status, commit, update, log, diff, mv, rm, merge, stat, up etc) read this article by Chip Turner. The complete manual for different subversion releases are available too.

If you already have worked with CVS, and you have the option to choose a SCM tool for your project then its better to start with Subversion as it improves upon CVS in several ways. Also the client commands are similar to CVS thus enabling easier migration. Several tools/scripts/IDE plugins/GUI Clients for subversion are now available and mentioned here. Google Code free project hosting and collaborative development site, uses subversion as its version control server.

I have been introduced to subversion in one of my project works in the year 2004 at Hewlett Packard. HP used CollabNet for most of its projects for collaborative development across HP sites and we used to use the Subversion client Tortoise SVN which integrates with Windows explorer. Back then the tortoise svn was still not stable enough and made the particular working directory (copy of the repo) in windows explorer very slow to navigate. So we mostly used the command line client then. For BaseApp, i chose google code project hosting service as it seems to be the most intuitive and easier to get started with than sourceforge.net. Google code project hosting service provides a issue tracking service and a SCM service. Google also provides free discussion forums for your projects from its Google groups. So, with BaseApp, i am back to using Subversion (and this time around i hope the GUI clients will be helpful and not make me go back to command line tools).

Friday, December 08, 2006

Starting BaseApp

I have decided to start an open source project - BaseApp. The project is hosted on Google Code site. A new project blog is started where project activity will be logged.

Objective is to come up with a foundation application which can be leveraged to build web applications quickly in J2EE 1.4 (in the likeness of AppFuse). Most of the commonly used feature will be made available (like form based authentication support, netbeans project enabled, custom ant build file created etc). A sample application source will be provided which will use the following frameworks/toolkits as reference implementation:
  • Oracle 10g XE (the database i will use for testing)
  • JBoss 4.0.4GA (the Application server)
  • Struts 1.2.9 (the web tier framework)
  • Hibernate 2.x (the presentation tier framework)
  • XDoclet 1.2.3 (the attribute oriented programming support library)
  • EJB 2.1
    • Stateless Session Beans (J2EE 1.4) (synchronous request/response)
    • Message Driven Beans (J2EE 1.4) (asynchronous)
  • JAX-RPC 1.1 (webservice support)

Wednesday, December 06, 2006

Choosing your Linux distro

You can find a good comparison between any two Linux distros at http://polishlinux.org/choose/comparison/. For eg, this url compares the Ubuntu with Fedora core.

EasyUbuntu is an easy to use (duh!) script that gives the Ubuntu user the most commonly requested apps, codecs, and tweaks that are not found in the base distribution - all with a few clicks of your mouse.

Sunday, December 03, 2006

Java vs .NET

I recently attended a presentation talk by a .NET developer in my team at workplace where he talked about the reasons why he thought M$ .NET is better than Java EE. Following were the points raised by him together with my views on them:
  • Java is slow in performance (both on server-side and rich client) as compared to .NET.
I found this blog post which presents some stats which clearly show that Java (JRE 1.4.2) was more performant than CLR (.NET 1.1). But C# IL when compiled to native code using Ngen.exe did significantly improve performace. Here's another interesting article i could find which compares the Java 5.0 with .NET 2.0 (the two latest releases of the competing platforms as of this writing). The summary from the article is as follows:
    1. Selection Sort algorithm implementation : .NET performs faster by 2:1 as compared to Java.
    2. Memory comparison: .NET is using more than twice the amount of memory Java uses to store the same amount of data – 19.9 MB versus a whopping 47.8. Since .NET treats native types – such as double – as objects, that this incurs additional overhead of some form. Java, on the other hand, does not treat native types as objects and therefore can save on this overhead. However, when it comes to real-world object allocation, it appears that .NET is more efficient.
    3. Conclusion: Thus, as we have seen, .NET 2.0 won 2 out of the 3 major tests – clearly besting Java 1.5 in both execution speed and real-world memory efficiency. Java did, however, manage to hold its own in the native types memory comparison by a pretty wide margin. This indicates that on the whole .NET is a more efficient platform, with perhaps at least one area for improvement – native type memory efficiency.
  • The Java Swing UI looks and feels ugly.
Good examples of better looking Swing UIs do exist like Netbeans IDE and that of SWT like Eclipse. Still Java does lack on the UI front hands down to MS .NET Winforms as the later looks, feels and responds better and is easier to program. The only reason why you may at all want to use Swing/SWT is portability across platforms.
  • There are too many options in Java to choose from (like Swing/SWT for UI development, Struts/Tapestry/Velocity etc for Web framework, Spring/EJB/xWorks for business tier, IDEA/Netbeans/Eclipse for IDE) and this requires developers to learn more than one way of doing the same thing.
This is debatable topic as having options to choose from is exactly what standards are meant for. So if you have a J2EE application which complies with the standards then you can easily port the application across multiple J2EE application servers, hence removing the risk of vendor lock-ins. Also, it fosters innovations at multiple quarters and there is no one organization dictating the terms in the best of its own interests.

The reason there are many more Java frameworks out there is simply because Java has been around longer, enough to have several good frameworks mature and spread. Many of those are being ported to .NET and others will rise up.
  • You can only program in Java whereas .NET supports multiple languages to run on its CLR.
Multiple languages can be compiled to produce byte code that runs on JVM. See this list.

In short, .NET has managed to surpass Java VM in performance and the cost involved in procuring the tools for development in .NET is not a factor against MS .NET (as investing in the tools for development is only 20% of the total cost of development). But ...
  1. Java is portable and you can run it on Unix servers (Unix remains the server of choice for production deployments in most cases).
  2. Java EE has matured over time and has more developer mind-share (about 4 million Java developers as in 2004).
  3. There is alot of investment in Java today and many big companies like Sun, IBM, BEA, Oracle has vested interest (tools, AS, support & services) in not letting the technology go to dust.
  4. Sun's open sourcing Java SE (under GPLv2) will enable JDK to be bundled with major Linux distros which in the past have not been able to do so due to licensing issues.
  5. There are more than 200 models of mobile phones which run Java and several wireless providers across the world provide Java content to such Java enabled phones. On the contrary there are only 10 or so Windows mobile phones today (this i read from some site i cannot find out now).
Quoting from a blog post:
.NET had many missing parts that the Java world has filled in its years of existence, but these are being filled and completed even as we speak. Moreover, these are usually fixed in ways compatible with the original Java implementations - moving from JUnit to NUnit or from Spring to Spring.NET (or the other way around) is probably easier than from totally disparate implementations.

In some areas, .NET is still lagging behind. COM+ is the only application server I know of that can run .NET components, and it's often overkill. A more flexible solution for that in the .NET world would be great. The .NET solution biosphere is still not as mature as Java, but what it does, it does very well - often better than the original Java product.

How does Sun make money off of Java?
  1. J2ME royalty earned (by Sun) per Java mobile phone sold (less than $1) remains a cash cow for Sun to date.
  2. Also Sun sells certifications to Java EE application server vendors for their compliance to the Java EE Specs.
  3. Sun also makes money by selling books, certifications and trainings for Java technology.
  4. Sun provides consulting services for Java enterprise application development.
  5. Sun also sells its hardware (server boxes) together with Solaris OS for deployment of Java enterprise applications in production.
By giving its JDK implementation and developer tools for free, Sun wants to increase the mind share for Java platform (and now more so as it has .NET to compete against) among the developer community. Sun gives developers Reference implementations for free to try out the technology and when the developers have got a production ready application then they (or their organization) would want to deploy the application on a supported server host which cuts down on the organizations TCO in the long run. Thats the model in which open source or free software businesses survive in today's software industry.

An interesting article with more statistics concludes that Java is loosing ground to LAMP and .NET for web application development. More and more corporations have adopted .NET since its easier and faster to program in than Java. .NET is gaining on developer mind share too.

I don't know how credible are the stats presented in the articles (i have found on the web and linked to above) or whether someone is funding a malicious propaganda against Java as i donot see how anything can beat free (free IDE, even AS, and you pay for a short-term support and you go live with Java). Of course, PHP has gained ground for building small websites and applications but when the applications are big then Java holds good steed. In my opinion, Java and .NET are both competent platforms for developing enterprise applications and both have their own pros and cons to be considered when a decision is being made on which platform to develop on. BTW, here are a few comments which i liked (by one Mr. Abdul Habra) refuting the claims made in the business week article:
I do not know where to start, look at these statements:

1. LAMP is used more than Java: a more accurate comparison is to compare LAMP against LAMJ or P against J. Java is used widely with LAM components.
2. PHP is used more than Java: Well, HTML is used more than both. Counting all the sites that use Java or PHP is meaningless. It is given that there are more basic, simple, or home pages than there are professional complex site. Simple sites are more likely to be written in PHP. This is similar to saying there is more printed material in the USA Today than for Shakespeare, hence USA Today must be better.
3. Sales Of AJAX books grew more than Java: The term AJAX did not exist two years ago, so selling 10 books compared with 0 books two years ago means that AJAX sales have grown infinitely. The other flaw in this argument is that many of the AJAX frameworks are Java based. This is like saying the sale of JDBC, JMX, … grew more than Java. Look at http://adaptivepath.com/publications/essays/archives/000385.php for the first public article of AJAX, it is dated Feb 18 2005.
4. Google and Yahoo do not use Java: Both are C++ shops. Their usage of AJAX is with C++/Java at the backend. Remember, Google hired Josh Bloch not for his PHP skills.
5. Merrill Lynch & Co ... using just Linux and the Apache server: So what language do they use? The author does not say. Clearly you cannot write programs with Linux and Apache, you need a programming language. This is a meaningless statement.
6. Jupiter Research report showed that 62% of ... .NET, vs. 36% for IBM's WebSphere: This only shows that .Net is used more than WS. It does not count WL, Tomcat, JBoss, ...

In conclusion, this is not new. I have been seeing this since Java became popular. Most of these claims are made by ignorant people or people with hidden agendas.

Thursday, November 16, 2006

Convergence of WS-Management and WSDM

JSR-262 which addresses support for Webservices Connector for the JMX Agents, is targeted for Java SE 7 (2008 spring). There are currently two competing webservices-based management standards: WS-Management and WSDM. There is currently an effort in progress to reconcile the two standards into one. But this reconciliation effort is going to take sometime to complete (and the guesstimate is it can be ready by 2008). The bottom layers of the convergence proposal are the existing standards WS-Transfer, WS-Enumeration, and WS-Eventing. JSR-262 chose to implement the Webservice connector using the existing WS-Management standard primarily because it seems to be the most backwards compatible approach possible. For reasons, read here. The idea behind this JSR-262 effort of providing a Webservice connector to the JMX agents is to enable management in hetrogeneous environments where the management host does not support JMX technology (say a management client written in C#). So once your JSR-77 MBeans are exposed via a JSR-262 Webservices connector, you could write a perl or ruby or C# client to talk to the MBean.

Recently after having passed the Sun certified developer for Java Webservices exam (CX-310-220) i wanted to use my learning of webservices building blocks to learn further on how webservices could be used for network management. I have learnt about such a possibility when i was working with HP when they decided to embed the webservice called IXA (XDM Access interface) [XDM means XML data model] in the firmware of the network module for printers. This approach had a strong group of supporters within HP. Till the time i was working with HP, they had already implemented the read-only interface to part of the management objects. And i found that even though it was easier to understand the benefits of this approach to managing the printers (over the traditional SNMP way), implementation was challenging stuff primarily because of less education among the firmware developers for technologies like XML namespaces, schema, etc. But the message was clear to me that sooner than later, webservices will surely be the way to manage the network elements and services. I will blog separately on the advantages of Webservices over traditional approaches like SNMP. For the moment, i just needed to highlight the fact that the webservice-based management specs are still far from final and by the year 2008 we should see some devices and servers implementing support for the webservices way of management. Atleast for Java App Servers, it is clear that JSR-262 will evolve then to support the then latest spec of converged WS-Man and WSDM standards. So for folks (like me) who want to specialize in systems management domain, will certainly want to track the progress of this convergence. IBM maintains the convergence progress drafts at its site.

Wednesday, November 15, 2006

Sun Announces SCBCD 5.0 Beta

Sun has announced SCBCD 5.0 Beta exam on October 19th it seems. It does not require one to purchase a voucher to take a beta exam. Registration starts on 24th Nov, 2006. You can take this exam from 8th Dec, 2006 to 2nd Jan, 2007. The exam objectives are here. The only pre-requisite is you need to be an SCJP (any edition).

The recommended books/tutorials to cover the objectives for this exam are:
1. Mastering EJB 3.0 by Rima Patel Sriganesh, Gerald Brose, Micah Silverman.
2. Java EE 5.0 tutorial
And of course the specs .. the list of them is mentioned here.

Register early as there is a limit to the number of people who can take the free beta exam.

Monday, October 30, 2006

Easy Eclipse Distro

For all you eclipse fans, there is a good distro for eclipse available (called Easy Eclipse) aimed at making the installation easier for eclipse. It has a pre-zipped bundle of plugins and all version dependencies are taken care of plus there are separate versions depending on what you need eclipse for (making Swing/SWT apps, server-side programming, mobile application development, etc). In my own experience, knowing what plugins to install to say start/stop tomcat or weblogic server or to support javascript or xslt editing is a manual process and complicated by the issues involved with version dependencies. With Easy Eclipse, the job of identifying the right plugins has already been taken care of and you can start using eclipse in all its glory right after the install.

12/27/06: I used the EasyEclipse Server Java 1.2.1 distro yesterday for setting up my development environment for learning EJB 3.0 with JBOSS 4.0.5 GA. And this distro installs JBoss Eclipse IDE with Eclipse 3.2.1 platform and several other goodies (Subclipse for subversion support, Web tools 1.5 which also brings in J2EE perspective, etc.).

Friday, October 27, 2006

Joy of Tech - Linux Lovers

When i bought my present PC for home, it came with Turbo Linux distribution. The PC is a Compaq make with AMD XP 2400+ processor. It was 2004 July when i bought it. I first decided to keep the Turbo Linux distribution. Later i experimented with a few more distributions (Fedora Core 2, SuSE 10.x, RH 9). It was a good setup and i was gradually getting used to the habit of doing common things from command line (like playing music using mplayer). It was a dream like phase for me as i saw the developer tools which came free (vi, xemacs, and GNU GCC toolchain, linux kernel sources) and felt very passionate about someday becoming a linux systems programmer geek :). Those days i used to be learning unix systems programming, linux kernel development and fundamentals of embedded systems programming - all of it in self-taught way. I read some books then like - Linux Kernel Development by Robert Love, Advanced Programming in the Unix Environment (almost completed it) by R Stevens, An Embedded Software Primer by David E Simons and some books i started but did not complete like Fundamentals of Embedded Software Development (read only first few chapters) by D Lewis and Assembly Language Step-by-Step: Programming with DOS and Linux (only read half of it) by Duntemann. That phase did not last very long with me (wanned in about six months) as i found that i could teach myself to program in assembly using the nasm assembler for x86 even on Windows using the DJGPP port of GCC plus i was more used to Windows as a user, and whatever the Geeks of the world have to say, Windows appeared to be more stabler an option when running RAD tools (IDEs) and other daily use applications (browsers like firefox and opera, email clients, chat applications etc). I lost my patience with Linux desktop at home and bought and installed WinXP Home edition.

Now, i feel i need a Linux system (systems programming, driver development) preferrably Kubuntu distribution, together with a Windows system (for email, chat, java dev etc). At work for the last one year i have not used any unix so i miss my Linux setup at home sometimes. Upgrading my present system with another hard disk where i can install linux is one possibility or will get another system (this time a laptop when i have the dough :) and install both win and linux in dual boot partitions. Ubuntu linux is good choice (as its all fats removed distribution of linux) with only the essential software (no more 3 word processors, 4 media players, 3 browsers etc as is still common with many other linux distros). Read more on the latest Ubuntu 6.10 Edgy Eft release.

Friday, October 20, 2006

SCBCD likely to be updated for EJB 3.0

On a post in Javaranch.com, Valentin Crettaz commented that SCBCD is likely to be updated for EJB 3.0 and the new exam will be available by early next year (ie 2007). Of late, many have posted on Javaranch on whether its wise to take the present SCBCD exam (viz aligned to J2EE 1.3 version of EJB Spec 2.0) or wait for the upgrade when the exam aligns with Java EE 5.0 version of EJB Spec 3.0. Now the same question is being asked about the present SCDJWS 1.4 exam (aligned to J2EE 1.4 version of WS specs). Sun has made some major architectural changes to the erstwhile JAX-RPC 1.1 (so much so that the new stack is called JAX-WS 2.0) and also the other standards have evolved in the due course (like SOAP 1.1 obsoleted bySOAP 1.2, WSDL 1.1 obsoleted by WSDL 2.0 etc). But experts at Javaranch feel that an upgrade to the present SCDJWS 1.4 will take some time (it may even be upgraded by Java EE 6.0).
In my opinion, those planning to take SCBCD 1.3 may want to wait for the newer version of the exam as its just around the cornor now. For those who planned to take SCDJWS 1.4, they need to take it now and upgrade whenever the later version becomes available. From my experience, the person taking this exam will definitely benefit from his learnings of even an older version of Spec as the newer specs in general have evolved in a backward compatible manner.

The architecture and design of webservices application has remained unaffected. And even the most hit aspect of the exam, JAX-RPC (viz is about 30% of exam) continues to be used in the industry today.

Also, there will be alot of work aimed towards upgrading the older EJB 2.0/2.1 app to EJB 3.0 and a JAX-RPC 1.1 client/service to JAX-WS 2.0. And to do such a work, one will require not only the knowledge of EJB 3.0 or JAX-WS 2.0 but also of the earlier version viz the source of upgrade.

Friday, October 13, 2006

$100 MIT Laptop



Seen above is the $100 laptop for kids in the third world countries. Dont you find its amazing ! And our Indian govt. said no to it.

More info regarding this laptop can be found at : http://laptop.media.mit.edu/.

My views: In my opinion, rather than simply writing off the $100 laptop the indian govt could have atleast introduced these to those children who dont sit under trees and do have a proper school where they could have used the laptop as a device to learn from better (and more funnier than their books). Many children in india leave education only because they never found studies interesting enough. I have seen child labors in my own state Bihar, India, where they chose to opt out of school just because they did not find it fun and so spent time away from school bunking classes. Providing those children with an interesting electronic device and showing them how to use it is all that will be needed to get them started using it. Also even if 10% of children pick up the basics, the knowledge will spread among the remaining like fire in the jungle (you know how children are! and laptop is not only ebooks - its games too :)) - and over time the mission (to spread literacy) will be accomplished.

Also programmers like Linus Torvalds have attested to the fact that he has been able to accomplish most in the computer science arena mainly as he started pretty early (Read the answer of Linus for how he learnt to program). I quote:
"I didn’t learn programming in school, but mostly on my own reading books and just doing it (initially on a Commodore VIC-20, later on a Sinclair QL)." - Linus Torvalds.

And to answer the question on what he (Linus) thinks makes some programmers 10 or 100 times more productive than others:
"I really have no idea. I think some people are just better able to concentrate on the things that matter, and I think a lot of it is just doing it. Most of the really good programmers I know started doing it fairly young." - Linus Torvalds.

So the point i am driving at is let them (the children) have an opportunity to get started with technology early in their lives. And thus, they can themselves be able to shape their lives based on what interests them most. Empower them by just providing them the right tools to learn the fun way. Note, laptops are not as dry as books and even a child who gets really interested in playing games may end up writing one some day just because he got too interested in knowing how the game thing works (you know children how they are!).

If Indian govt can invest in crores to buy more arms to make the nation feel safe, then its high time they start thinking on how to build the nation by spreading means of education among the populace. Why we want literacy afterall! Its because it enables the citizens to be educated enough to act responsibly.

Still many children born to poor families living in towns dont get to use a computer just because their parents cannot afford to buy one for them. If a laptop is cheaply available then atleast (like a mobile phone or television became a household item for even a rickshaw puller) parents can provide their children with the device to learn from the fun way. And you never know how many get sincerely attached to their devices and start bringing to our world more innovation. I sincerely feel that we must let this device be introduced in developing countries with rising population as this can serve as a medium to get free ebooks and in general to get the children interested earlier in electronics and reading.

Tuesday, October 10, 2006

Reading of SNMP, SNMPv2, SNMPv3, and RMON 1 and 2 Third Edition by William Stallings

I have started reading this book on SNMP by William Stallings recently. I have read just 6 of 17 chapters till now. What i wanted was a complete but simplified (than RFC's) write up on SNMP protocol and some of the standard MIBs. I have worked in SNMP for almost 7 yrs now and whatever i learnt was on-the-job. So i needed one book which puts together the different pieces of information pertaining to SNMP-based network management in a coherent form. Much of what i read in this book is what i already knew but reading it from a book gives a different perspective. Like for eg, sysUpTime can be used to deduce if the agent has been restarted since the last poll or that the ifAdminStatus reflects the value set by management station to change the operational state of the interface but ifOperStatus reflects the current operational status (and is RO). So if ifAdminStatus is up(1) and ifOperStatus is down(2) then the interface has failed can be concluded. And so on.. Another book which i am planning to read after having completed this one, is, Network Management: Principals and Practices by N. Subramanian (a GaTech Prof.) which covers ADSL/HFC management in some detail and introduction to various tools (HP OV, MRTG) and alternative technologies (WBEM).

Saturday, September 30, 2006

Rocky wallpaper collection

boxing
Sep 29, 2006 - 7 Photos

Here are some of my favorite star (Sly Stallone's) pics from his movie Rocky (which i adore - as i adore boxing sport) and someday in this lifetime i will want to look like the above pic ;) ... and will update this blog post then with my pics by his side. Just kidding! Enjoy this small collection for now.

Monday, September 18, 2006

Preparing for SCBCD 1.3

Sun certified Business Component Developer exam (SCBCD 1.3)
is the exam i am going to take next on the coming monday (30 th Sept, 2006).
This exam covers EJB 2.0 spec (of J2EE 1.3). I am going to prepare for it inthe following way:
1. First refer to my notes from Mastering EJB 3rd Edn book by Ed Roman et al (covers EJB 2.1 and not 2.0 as required by exam).
2. Read Head first EJB book by Kathy Sierra and Bert Bates.
3. Mocks from Enthuware's EJBPlus.

Thats all of it i will do (or rather i can do) with 1 week of preparation.

Update 30th Sept, 2006: I passed this exam with 85% (85.7% in fact ;) ). Read my post on javarach of the customary how-i-prepared-for-it.

Saturday, September 09, 2006

H1B Visa Stamping Experience

I got my H1B visa stamped yesterday (8th Sept, 2006) at USA Consulate in Chennai, India. My appointment time was 8am in the morning but i was allowed in at 7am itself. Then i was asked to wait for my turn in a seated queue in the first building where the documents are verified before you are asked to proceed to the next building (where the actual visa interview happens). At about 7.30 i was asked to stand in the queue of the first building when all people who had their appointment at 8am where asked to stand in the queue. Here they verified the documents and matched the barcode on the visa fee receipt with the passport number as mentioned in their system and finally they took one barcode sticker from the yellow receipt and pasted it on the back of my passport. They also put one form which reflected at what stage i was in, in my visa stamping process (ie docs verified, finger printed, visa approved). Once the docs verification was done we were being asked to go to the next building. There again we had a queue outside the building. I waited in the queue for some 10mins and then a security personnel allowed us in based on our visa appointment time. Once in, two ladies were coordinating the seating of ppl asking them to keeping moving in a seated queue. First, one of them asked us to stand in the queue for being finger printed. This counter was in the center of the hall. First the left and then the right index fingers were scanned and this record was stored against our passport details (as the lady on the counter took first the passport and then asked to put the finger on the scanner). OK, hereafter, i was in another queue waiting for my turn for the final visa stamping interview. The guy just before me was from TCS and he got a 221(g). His was an L1 case. I saw a few oft repeated questions to L1/H1B:
1. What is the project on which you will be working in the USA?
2. Whether you will be working at the client site or in your company's USA office? If you said client site, then you may be asked to present the client invitation letter and probably if the client is lesser known name then some photographs of the client and probably its annual revenue etc.
3. Why have you been chosen to go to USA for this project (why not someone else from your company)? Basically i think they want to know how your skills map to the requirements of the project and how confidently can you state them.
4. Your academic qualifications? If you are not a comp. sci. graduate then probably you will be asked to tell where/how you learnt software development skills.

The communication skills matter alot. Some ppl i saw were asked something and they answered something else, and this irritated the VO. Note: The VO has a very short time span to gauge you and so you should give all positive signs about you (especially so by communicating well - ie speak good english). As they say, if you have the right skills then it shows by the way you talk.

My visa interview was brief (lasted 1min or so). The questions asked were the following:
1. Which project was i going to work on in USA?
2. What client?
3. What is my academic qualification?
4. Since i am a non comp. sci grad (a BE in electronics) she then asked me how i learnt software development skills. (any training etc). I said i am working for the past 7yrs in the industry (so most of the skills were acquired on the job plus i had a post graduate diploma from National center for software tech).

Thats all! I hope this post is useful to you. May you have a good experience in your visa interview as i had :).

Sunday, September 03, 2006

Book Review: JUnit in Action


Well i dont have anything to add as of now as i just bought this book but as i read some reviews (especially the one on eXtremeComponents site) i decided to benefit by learning how to unit test from this book. Yes the contents are very impressive as it covers mock objects, stubs and in-container testing strategies using JUnit and derivatives of it. The author is also a creator of Jakarta Cactus web-testing framework.

Preparing for SCWCD 1.4

I have decided to take the SCWCD 1.4 (CX-310-081) exam and have booked a slot for taking the exam at the local prometric test center on 18th Sept, 2006. I had already read the book Head First Servlets and JSP by Bryan Basham, Kathy Sierra and Bert Bates before but it was some 10 months back that it did so, and i needed some time to recap on the theory. I am using MZ's WCD Study guide to prepare and practice using the exercises from Head First book. I plan to use Enthuware JWebplus mock exam together with the mock exam with the Head first book and the mock exam at JavaRanch.com.

Update 18th Sept, 2006: I have passed the exam today morning and could complete it 45mins earlier (ie i took 1hr 30mins of time to complete the exam). Refer to my post on javaranch about how i prepared for it and where i went wrong to end up with the low score of 82%.

Popular micro services patterns

Here are some popular Microservice design patterns that a programmer should know: Service Registry  pattern provides a  central location  fo...