Skip to main content

Posts

Showing posts from 2008

What a Year! Phew..

-- Art by Baran

Happy Holidays!

I am a Hindu by faith. but I love christmas, for the sense of good it cultivates in you (or atleast thats what it attempts). I am big sucker for those 25 days to Chirstmas on ABC, and the movies of that genre..
Having said that I have my own (small) list for Santa..
Love, Peace, Harmony, Health and Success. For Me, My Family, Friends, My Country, and the whole World.
I am sure I have been nice all year, and Santa Obliges..
So be good for Goodness sake.. Happy Holidays!
image by mcgraths

Using Equinox CommandProvider to make OSGi console interactive.

After fiddling with the First Bundles that "Hello World"-ed upon Activation, You want to see more interactivity in OSGi. Although Using OSGi for an interactive Command Line Application would be like this one would be, well, a callable over-kill, I am going to start with an example and Expand it in later posts. So, please Welcome CommandProvider.

CommandProvider is an EQUINOX specific API for extending the Console. This basic Example illustrates how to get a command from console and do something in java and also gets your feet wet on Service Registry
package com.so.examples.commandconsole; import org.eclipse.osgi.framework.console.CommandInterpreter; import org.eclipse.osgi.framework.console.CommandProvider; public class DisplayMessageCommand implements CommandProvider { public void _say(CommandInterpreter ci) { ci.print("You said:" + ci.nextArgument()); } @Override public String getHelp() { return "\tsay - repeats what you say\n"; } }
This pr…

OSGi: Starters Guide for Install, Update and Refresh Bundles

In OSGi, with a Bundle you could Install, Update or Refresh. There is a subtle difference in all these three. Just enough for a beginner to entangle the mind. To help, This post gives an a practical insight. I recorded the commands and thier out puts.

To Begin with, Install puts a bundle in the framework runtime. It also records the file location (on FileSystem or URL). It doesnot start or resolve dependents on it.

sarath@sar-akshaya:~/zbin/equinox$ ls bundles equinox.jar org.eclipse.osgi_3.4.0.v20080605-1900.jar sarath@sar-akshaya:~/zbin/equinox$ ls bundles/ FirstBundle-1.0.0.jar SecondBundle-1.0.0.jar sarath@sar-akshaya:~/zbin/equinox$ java -jar equinox.jar -console osgi> ss Framework is launched. id State Bundle 0 ACTIVE org.eclipse.osgi_3.4.0.v20080605-1900 osgi> install file:bundles/FirstBundle-1.0.0.jar Bundle id is 1 //Try starting osgi> start 1 org.osgi.framework.BundleException: The bundle could not be resolved. Reason: Missing Constraint: Im…

Days after Nov 26 2008

I wish this long weekend never happened in time. No less than 200 people were reported killed in terror attacks in Mumbai, India. I was driving to new york when I first heard about the reports on NPR at around 3 in the after noon. The death toll reported was ~50. For a year like 2008, in which there had been blasts almost every fortnight, this initially did not come to strike me as hard as it did with every 10 minutes of passing time. The number slowly jumped to 70s and then to 100 by the time I lost NPR signal on my car.


By the end of the evening, I reached New Jersey, stayed over at my uncles place. From then, till late night, I was glued to Indian news channels on TV. NDTV and IBN live on the internet. Words cant explain the state of mind watching those gory initial pictures and videos of the happenings. State of dismay, panic and confusion reined through out the night. All the while, There was only one question. What in the world is a Country doing when handful terrorists have b…

Sample ant build file for OSGi bundles

Okay.. after I put the example the other day, I realised it is so worse to be clicking on export and choosing the manifest file all the time. So For a quick start people can use this build.xml

<?xml version="1.0" encoding="UTF-8"?> <project name="BundleName" default="deploy" basedir="."> <property name="version" value="1.0.0" /> <property name="src" location="src" /> <property name="build" location="build" /> <property name="deployloc" location="/home/to/equinox/bundles" /> <property name="dist" location="dist" /> <property name="buildfilename" value="${ant.project.name}-${version}.jar"/> <path id="classpath.buildtime"> <pathelement location="/home/to/equinox/equinox.jar" /> <pathelement loca…

Intrepid: Keyboard repeats keys too fast - Sovled!

Yet another weekend, Yet another fix :).. Well a workaround, actually..

This has been a problem for a while. Ubuntu Intrepid has very annoying too fast key repeat rate. and the gnome-keyboard-properties ignores any setting changed. There were some workarounds proposed like xorg.conf. they dint work on my lappy. I also played around experiments, in vain. Miserably. But very well pointed out by Jorge Peixoto de Morais Neto, You can set the repeat settings with kbdrate

just add the following line in /etc/rc.local
#/etc/rc.local kbdrate -r 25 -d 500
This should solve the quick repeats. If this fixes your issue, Please contribute at the bug in launchpad.

Google App Engine vs Microsoft Azure

Side Stepping on my OSGi trail, I saw a few articles on the new Azure platform for Cloud computing from Microsoft! People claiming it to be up agains Amazon EC2 and Google App Engine.



Come on.. Having never used it, I cant speak for EC2 but; App Engine and Azure? Where is the comparision.

By Choosing Azure, I am basically TIED to Windows all the way! Just look at the long list of Auzure SDK Requirements:

Supported Operating Systems: Windows Server 2008 Enterprise; Windows Server 2008 Standard; Windows Vista Business; Windows Vista Business 64-bit edition; Windows Vista Home Premium; Windows Vista Home Premium 64-bit edition; Windows Vista Ultimate; Windows Vista Ultimate 64-bit editionRequired SoftwareWindows Vista SP1 (when installing on Windows Vista) .NET Framework 3.5 SP1 IIS 7.0 (with ASP.NET and WCF HTTP Activation) Microsoft SQL Server Express 2005 or Microsoft SQL Server Express 2008 Windows PowerShell (optional)
On the other hand, App engine can live on Windoze, Linux or Mac. …

(NOT) yet Another Getting Started with OSGi

Last week I have been learning OSGi.

I got my first application running in OSGi. I am not going to write another getting started post with code that will show a hello world. But rather give you an idea how to start getting in the mud. And then may be show you more than a direction :)

I used Equinox 3.4 (OSGi R4) implementation. I prefered it over Felix. Why - Eqinox is simple, and a single jar download. But I guess that aint a thing to notice. You can get Equinox jar from here. If the link is broken, go here, download the equinox framework, it should be ~0.95MB.

Start equinox framework as java -jar equinox.jar -consoleYou would have seen this on a lot of sites. but I did fall on two things flat on my face; missing -console and doing it wrong --console :P

As per the spec, (and by now, you know) a bundle is a jar with some special informtion in MANIFIEST.MF. A Bundle jar need not DO anything. It could just sit installed or be active (by exporting packages and services). So if you have…

Get Nerdy with VLC.

VLC media player gives a few things with less explored Extended Settings. A Webcam (in-built on lappy, prefered) together with VLC can do some pretty nerdy stuff. I cought a collegue by suprise when she walked into my cube saw her self in my laptop movin on my screen. Well.. thats only the beginning of endless uses and other things you can do. (You can even shave without a mirror- Yeah it is so good)

Open vlc. Open Capture Device from the Media(older File) menu.

Select the one for opening the webcam (V4L or DirectShow)For the basic use, just click play. At this point youu should see a vlc window playing what the webcam is capturing.Go full screen (there is your mirror, go ahead shave :)
This is good enough for basic nerd level. Stop here unless you want to get really nerdy :).

Now Open Extended Settings (CTRL+E) from tools.
Go to Video Tab. Play aroound.. Have fun
Examples:
go to Color Fun > Color Extraction > enter 00FF00 and Image modification > Motion Detect.. Coool eh?
Geo…

MANIFEST.MF in Plain Java, EJB, OSGi - catching the drift

While reading about OSGi, I realised how the importance of MANIFEST.MF has grown over time. The once only-a-jar-information file has had its ups and downs. When I was in school, *chapter jar* was an "assignment" / "reference". It wasn't worth a class' time spent on it. Today a whole new technology relies on this humble text file.

Past: Long long ago, in stone age (yeah I am exaggerating), the MANIFEST.MF was auto-generated while jar-ing. More or less it was not used. Well, yeah if you are developing a java application to be distributed to end-users (the jars you used to double click, which are so replaced by jnlpa.k.a WebStart apps now). This file would give a place to specify the class path
Manifest-Version: 1.0 Created-By: 1.4.2 (Sun Microsystems Inc.) Main-Class: com.big.long.package.MyAppMain Class-Path: mod1.jar mod2.jar lib/lib.jarThis will be set when running
java -jar myapp.jarwhich other wise would have to be something like
java -jar myapp.jar -cp al…

Mission OSGi

Finally some time for OSGi.

With release of Spring dm Server, My interest for OSGi got two-fold. Although I did have some close-encounters with OSGi (aah its just a jar called differently - bundle; and MANIFEST.MF drives it all, o I know OSGi), I haven't read into a lot of it. So now, I am diving into it.

To start I picked Neil's blog. He also has a draft of his upcoming book, OSGi in Practice. So It is a good place to start.

That gives me to start a new tag (osgi) :)

Switch (ing) enum (s) in java

Java 1.5 enums are a life saver. There is a small gotcha in thier use especially in a switch statement(More so for a guy coming from hard core 1.4).

When creating an enum reference - you would need to Qualify with enum Type. However, The case labels while switch(ing) on an enum variable will only take enum constant of the *SAME* enum type. And ONLY the constant name. It SHOULD not be QUALIFIED.

Ex: In the following code, The second case label gives a compilation error.

public class EnumTest { enum WeekDays {SUN, MON, TUE, WED, THU, FRI, SAT}; public static void main(String arg[]) { WeekDays r = WeekDays.SUN; switch (r) { case SUN: break; case WeekDays.MON: break; default: break; } } }
There are good advantages here. For one, Refactoring doesnot involve lot of changes. Maintains Typesafety. It avoids a possibility of human error where you are comparing Fruit enums and Vegitable enums. Because they are different :)

44th President of America - Barack Obama

"Yes we can!" - Hope - Change - *United* Stated of America

Now they are - Barack Obama - 44th President of America.

I am proud that I am a part of this. And I consider myself fortunate to be living this moment.

I hope that all this Good Will is converted to Peace, Prosperity for the US and the World. So the next generation is given a better tomorrow.

God Speed!

Slow Login Intrepid Ibex - X is the problem?.

I have upgraded my laptop to the latest Ubuntu (Intrepid Ibex). I was happy to notice My Audio is now working fine. Headphones too :) My flash issue is still open (I think it is in Adobe's Court - and they dont seem to bother) Everything else *looked* fine.

However, on a deeper examination. There is a small issue (not a deal breaker, though). The user login takes a little longer. I looked at the syslog.

There are some noticiably interesting things (All I think it boils down to X11, I may be wrong)
X (crashes? and) is restarted RIGHT before gdm login screen appears. There a log of compiz real segfault-ing
WARNING: gdm_slave_xioerror_handler: Fatal X error - Restarting :0Nov 2 13:02:27 sar-akshaya kernel: [ 6185.471607] compiz.real[5767]: segfault at 2b0021 ip 08055c8c sp bf9ad770 error 4 in compiz.real[8048000+34000] Nov 2 13:02:28 sar-akshaya gdm[5326]: Sigfile not found. After a couple quick screen flickers, login screen appears and after login credentials are entered, for the WH…

Americans! Go and Vote!

There is only a little chance you will find yourself in a more important day in history. And for you americans who can vote, I cant urge you more, Please Vote. If I cant motivate you, May be a cup of Starbucks can!

(I like the way "proudly" is emphasised!!)
Like Linus Torvolds, I can't vote. But make yours worthwhile.

Solved - Eclipse looks good in Ubuntu Now!

This is a follow up post that solved an issue I had. This post will also illustrate how to run a GTK application on a different theme
Recently I posted that Eclipse on Ubuntu is the Ugly Betty. I was looking for a Theme that would make it look better(and a way to use it only for eclipse).

A digg commentor suggested that I get Clearlooks Compact Theme.
Another commentor (Victor Ott) suggested that I install a plugin That will save some screen real estate. I tried both. While the plugin is good, It makes eclipsel lose its easthetics. I then saw this post. So I improvised a little more.. Mixed all the ideas.

First get the Libertarian fonts, as described in max's post. (They are really good indeed, I even made them my gnome defaults).
Then, Download this archive and extract in the eclipse directory. And "chmod 755 ec" . Thats it! run ec instead of eclipse.

What this does:
The gtkrc-sar is a theme rc for GTK engine. Think of it as a CSS in HTML page, to GTK application.
ec …

Ubuntu Intrepid Ibex: A week to go

O so long, I have been waiting. With hopes that Intrepid will solve my sound issue out of box (I could have checked in live CD but it can wait), I am counting this week down for the next release of Ubuntu. This is not a major release but you could have seen a lot of beta (p)reviews if you follow digg enough.
What I am looking for:

Latest Gnome, X.org, Kernel (Solve My audio issues.. )
Encrypted FS Mounts(Protect my Data)
Networking improvements (Bluetooth, Network Manager[ndiswrapper - would be needed futher?])
DKMS (interesting feature, eh?)
Flash (My web cam issue)

Today: Consumer JRE released, Andriod open sourced!

Big news, Android - the collaborative effort from Openhandset Alliance and Google to take mobiles to the next level - has been open sourced today. The code, 2Gigs in total size, is now available to anyone interested in its research and/or development.

In another story, Sun meekly released Java 1.6.0_10 (dubbed - Consumer JRE) available to download. There is no confetti this time, I guess the management is all the more concerned with its share value. Hopefully, it will reduce the stress on the java *user* world. Change is good :)

Flash in Ubuntu: WebCam doesnot work : Camera is unavailable

Yet another day looking for a solution to an issue in ubuntu. but I am loving it :)

I am trying to get my webcam work with live.yahoo.com or justin.tv in ubuntu. For some reason adobe flash is unable to open my web cam. It shows up a modal dialog box: "Camera is unavailable, may be in use by another application" Results from video test on Skype, on the other hand, is positive on my system. So My webcam is not the issue here. Also the tabs in the options are not focusable. I mean I click on them, NOTHING happens.

There was a bug raised in Adobe Support forums. I posted back, if you know a solution let me know.

System : Lenovo Y410
Browser: Firefox 3.0
Flash: 10 downloaded from adobe.com



Why Firefox 3.1 can wait

The FOSS community is rejoicing another release of FF - 3.1beta. Mozilla released FF3.1beta on tuesday. I was one of those beta-ers last time around during FF3 release. I even did countdown to the release. I even got my own download certificate :). However, I don't want to eager myself to it this time. Here is why its different this time.

Firstly, its not a major release, meaning nothing changed BIG! If at all, The only thing that will get me motivated is the CTRL+Tab feature. But my existing Tab-Mix Plus plugin gives a tab list that is adequate. A 3D preview is nice to have but not so much to hurry to.

All the goodies are unused, The geocoding, Video, Audio, HTML5 and CSS3 support have nothing to offer until there are some REAL websites that start utilizing them. Especially the Geocoding, As much as it sounds cool, until it becomes a standard - it would be another browser specific dumb-a$$-nerdy feature I would refrain myself as a webmaster. The others follow the same rationale…

Eclipse in Ubuntu Human Theme

By now, many people are done making a switch to ubuntu. Fallen in love with it and oogled on Compiz and its sooper dooper Cube (Okay, you might have even gone farther.. awn, conky..). However, You might still be dependent on Windoze for some applications. Among other things, Development is one such. I have created everything on my site and on this blog in Gimp and Eclipse. Needless to say Eclipse is my favorite IDE.

So, I have had my share of issues in the past on my ubuntu. But now, I am hell bent on going full time on it. I have a lenovo Y410. It maxes out on 1280x800 resolution. I should say an experienced developer would clearly have issues with such *low* resolution. To make it worse, it appeared eclipse on linux was not built with this configuration in mind. A screenshot looks like this.

.

Apparently a large portion of the real estate is taken up by spacing in the toolbar icons, height of the tab, spacing in the tree etc. (my windoze eclipse is okay). The fonts, colors, and spa…

classpath*: making your Modular Spring Resources

Spring gives multiple options to load XML resources for building contexts. the reference documentation does explain this feature quite well. However, I am taking my shot at explaining the different practical scenarios ( by order of growing modularisation)

For Example, A simplest Spring based web Context Loader can be configured with resources like this
<context-param> <param-name>contextConfigLocation</param-name> <param-value>applicationContext.xml</param-value> </context-param> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener>
You just need to put applicationContext.xml in WEB-INF/ folder of your webapp.

However, Typically an application is n-tiered. You can also have multiple files setup and in relative paths.
like
<param-value> context-files/applicationContext.xml context-files/dao.xml context-files/service.xml </param-value>
put them …

Javascript RegEx missing group feature

I was looking for examples in Javascript to get grouped regular expressions into an array. Say a time string which I am collecting hour, min, and sec with a regular expression. I could do it in perl in a easy way, Something like this:
$_ = "10:23:25" if (/(..):(..):(..)/) { @t = ($1, $2, $3); } But in javascript looks like there is no such way. the only way you could collect that is using the String.replace() and running the RE on it. Something like this.
str = "10:23:25" re = /(..):(..):(..)/ hr = str.replace(re,"$1"); min = str.replace(re,"$2"); sec = str.replace(re,"$3"); t = new Array(hr, min, sec); If you know of some other way, let me know :)

java code if and return

I have seen code that looks like this
public void static fn(boolean someCondition){ if(someCondition) { return error(); } return success(); }
Although there is nothing wrong in this, conventions suggest that this be written in a readable way like
return someCondition ? error() : success();
but lets say we have some more statements like this
public void static fn(boolean someCondition){ if(someCondition) { statement1; statement2; return error(); } statement2; statement4; return success(); }
I would consider it will be more readable to put it as
public void static fn(boolean someCondition){ if(someCondition) { statement1; statement2; return error(); }else{ statement2; statement4; return success(); } }

Bush administration's final straw: The new US dollor proposed!

One of the witty forwards I recieved in the recent past :)

Back to business

Hello all, I am back. I am glad to come back and to have my father recover well to the treament. He was diagnosed with Neuro Endocrine Carcinoma of Rectum (something related to colorectal cancer). I am planning on writing about his diagnosis and what he(and we) went through all this time. But good heavens, and wishes from a lot of friends and relatives - He is doing very well now.

Stepping out.

I am stepping off from professional chores for some more time. I am not following Olympics either. I have to visit India to take care of my father, who is undergoing a diagnosis for a tumor.

Thanks for all those who have given me thier support. I shall start writing again soon.

Abhinav Bhindra - The First Individial Olympics Gold medalist for India

I am off until olympics, I will catch up later.. And I am blogging this Historical moment.. Thanks to Abhinav Bindra who did India proud

Using Spring XML Schema based bean definitions

Spring's bean definitions (and configuration files) may go very verbose after your projects goes two or three iterations old. By verbose I mean, too many bean definitions, and complex injection graph. And many a times, these xml files go fat because of common definition types - props, lists, etc. These beans are generally configured using FactoryBeans.

To reduce this verbatim Spring provides XML schema based configuration, for various types of FactoryBeans. There are some shortcuts presented in that appendix, I frequently use. I recomend those to others too.

Here are some of those.

<!-- creates a java.util.Properties instance with values loaded from the supplied location --> <bean id="jdbcConfiguration" class="org.springframework.beans.factory.config.PropertiesFactoryBean"> <property name="location" value="classpath:com/foo/jdbc-production.properties"/> </bean>Could be written as
<!-- creates a java.util.Propertie…

Moving on to Ivy.

Maven has its share of success, at the same time it has some shortcomings. Many felt the Idea was right, the implementation was not. There were a few rants too. Project Ivy was started on that note. Today, Everyone is talking about Ivy and How Ivy can fix your woes from maven.

So, I began to test drive Ivy. Ivy has got pretty good documentation. And the edge over maven is, that you dont have to adapt your project to it (like maven). You can make ivy adapt to your project. All you need to start is a jar to put in your ant lib folder. The examples list a mighty hard way of starting with ivy - So I modified a little bit to get it easy and install ivy automatically. Also this can be used as a template build.xml file for starting from scratch :)

<!-- Use namespace even before bootstrap --> <project xmlns:ivy="antlib:org.apache.ivy.ant" default="build" name="SarathPOC"> <property file="build.properties" /> <path id="compile…

Acegi onSuccessfulAuthentication

Some time back, I raised a jira in Acegi, which was turned down. There was no adequate response from spring team. Here I am writing about it, so other spring users (read gurus) may pitch in.
//Edited to short and precise protected void successfulAuthentication(HttpServletRequest request, HttpServletResponse response, Authentication authResult) throws IOException { SecurityContextHolder.getContext().setAuthentication(authResult); String targetUrl = (String) request.getSession() .getAttribute(ACEGI_SECURITY_TARGET_URL_KEY); request.getSession().removeAttribute(ACEGI_SECURITY_TARGET_URL_KEY); if (alwaysUseDefaultTargetUrl == true) { targetUrl = null; } if (targetUrl == null) { targetUrl = request.getContextPath() + defaultTargetUrl; } // user call back hook onSuccessfulAuthentication(request, response, authResult); //... response.sendRedirect(response.encodeRedirectURL(targetUrl)); } The Acegi frame…

Are we really Going Green

When I bought my Hybrid, I donated my old car. At that time, I thought, If I am buying a Hybrid, I am reducing my carbon foot print. But, Someone else is getting that old car and driving it for another 3 years. So am I really reducing the foot print?

We want to use paper bags instead of plastic ones, but the earlier weighs a lot more than the latter - so transporting them burns more carbon. Same applies to using paper towels or Blow Driers.

Who is calculating the trade offs? how do we know we are really going Green? Be sure of that next time.. For now, on a lighter note - Catch a bit of Colbert's Report.


Reentrant Locks - Synchronization on multiple Conditions

After looking at a way you can do a waited lock on a synchronised monitor in java, it needs a much more object oriented way of handling multiple scenarios.

The sychronised-wait-notify paradigm works if you wait and notify on the monitor based on one condition (wait before borrow if not available). The Give back doesnot wait ever, It just gives back. The pool kills any over flow. What if you need to put a conditional wait on that too? something like (give back only if object pool is not full and WAIT until space is available)

Here is where you have Java 5's Lock - Conditions paradim comes handy. A lock is objectification of the monitor, Threads that need to be synchronised on one monitor is can go through Locks instead. However, Locks are more useful if you have multiple conditions on which you what these threads to wait and be notified.

Take the above scenario, which is the case of a Bounded buffer where there are two conditions on which threads need to wait, empty and full. If b…

Public and Private JRE

This one is basic. Newbies in Java are overwhelmed with too many techy terms. Most know JRE, but some find it hard to understand the notation of a Public and Private JRE.

A JRE is nothing but a folder that contains JVM executables, setting files, required lib files, and extensions. You can install multiple JREs on your system Sun generally installs versions in C:\Program Files\Java as jre eg.jre1.6.0_06.

A Public JRE is available to all Java programs, Browsers, and the libs in this JRE folder are available to applications started in command line like
java com.sarathonline.cli.HelloWorld
This JRE is also registered in path, and Browser plugin.

A Private JRE is something that is installed in the system by is not refered to by default. This could be a copy of the JRE / JDK folder from another installed directory. If you see a my earlier post:  starting eclipse with jre 1.6 where your environment is in 1.4, The JRE1.6 is used only by Eclipse, This is a private JRE. While the JAVA_HOME po…

Java Object - wait - notify - a practical example

Object is the super class of anything in Java. But, Most people fear the wait and notify methods in Object. The common java practitioner might not need to use these for all practical purposes. However, the fear is not because they are hard to understand, but because of the assumption and false notion (generally pushed from the *experts* to the newbies) that these are for *super users*. The easiest way to understand this is by example. Most examples include Produce Consumer, But in practice where is this applied?

Some time back I wrote about Commons Pooling. Ever wonder how an Object pool Implemention, like this one, would time out on a blocking call without creating a new thread on its own? It uses a wait - notify[All] paradigm.

To understand that Look at the source code of the said GenericObjectPool.

The borrowObject method (line 911 - so apt??) which optionally waits for a maxWait long secs, is used like for (;;) { synchronized (this) { // Some Logic try { if (_maxWait…

Using Java 1.4? Can't Use Webtools in Eclipse Ganymede?

At our new client, we still use Java 1.4 and I found that there is a problem installing Web tools in Eclipse 3.4 (Ganymede). The P2 Installer shows WST is installed, but I cannot see Server profiles, J2EE perspective, anything related to it.

Here is what I installed, as shown in P2


But I cannot see J2EE related stuff in Perspectives, Preferences or New windows


To resolve this, I installed a private 1.6 JRE. Started Eclipse with
eclipse -vm c:\java\jre1.6\bin\javaw

And it works!

Inspired by Randy Pausch

Yesterday's Google Blog had posted
[Randy Pausch, a professor of computer science at Carnegie Mellon University and a good friend of Google, passed away last night. In addition to being recognized as a pioneer in virtual reality research, he became widely known as a gifted teacher and a mentor to many. Millions of people saw his inspiring "Last Lecture" on YouTube. Read more about Randy and his contributions on our Research Blog.]
So I watched the video. And the related movies. Very Inspiring! I made a small playlist. Just play this, It will loop to finish with the actual lecture!

R.I.P Dr. Pausch

OpenSessionInView Filter, Sessions, Transactions and Connections

By now, I have worked enough on OpenSessionInViewFilter, Hibernate and Spring in some projects.

Hibernate 3 uses Lazy Loading by default. So, We use for maintaining lazy loaded collections to display in view. But, lately, as I mentioned in earlier posts, we were having some issues with connections that were not returned to pool.

To understand where connections were held up we need to see how OSIVfilter, Session, HibernateTransactionManager and Spring work together - Where and when connections are picked and released. OSIVFilter guarentees that each request will have one and only one Hibernate Session. A Session is a lightweight abstraction of data in the database pulled into vm converted as objects. So for a session to fetch data from db, it needs connections. This connection is available from the datasource through a TransactionManager. In general, if you have one database, You would use Springs HibernateTransactionManager.

A Session generally contains one Transaction. However, In OSIV…

Resource Contention in JEE for a layman

In terms of scalability, a frequent term used is "Resource Contention". Most commonly this means, there is a shared object, file handle, db connection, or similar for which Threads are trying to get ownership. Until they obtain this ownership they either wait or exit on a timeout mechanism. In normal flow, they simply wait - This state is called blocked state. In an asynchronous mode (generally meaning a spawned child thread), there can be a Time-Out flow that can be defined to control the maximum length of time the thread can take to complete a task.

In a blocked state, There may be "Resource Contention" in one thread that is avoiding other threads to proceed. In a JEE environment, This Resource Contention is caused commonly by Transactions(, Synchronized blocks, Locks). Since User Threads are discouraged in JEE, Synchronized blocks and Locks are less often encountered as issues.

That's theory. If you dint understand much, Dont feel despair. I come from the ver…

Spring Security Advisory

Many people consider this is not new. But there is a security advisory out for spring users.

http://www.springsource.com/securityadvisory

Quote:
For applications that bind request data to presentation-layer "form models", this is unlikely to be a problem since there is a one-to-one correspondence between a form backing object and a set of allowed request parameters. This issue is only relevant for applications that bind directly to a domain model which exposes properties that should not be updated by the client.

To understand it more clearly, look at an Example:
http://www.celerity.nl/blog/2008/04/security-implications-of-the-spring-databinder/

This is however an advanced usecase. If you are directly binding model to form objects you have a major design issue.

If you observe carefully, There is another case that we dont often remember. Most Web apps have CRUD jsps and the Update jsp will generally include the id of the model that is being edited. Most times, The only security is th…

Bright Side of High Gas prices

Look ma, finally the world understands - Its easier better to cruise than break hard after a speed rampage.

For all the better things, Look at the green side of high gas prices. People are talking thinking about mass commute or Car pooling. Resulting in Less Traffic. Lesser Accidents. And Much lesser pollution. Car manufacturing companies making cars not for *speed* but for *green*. Revolution and research in alternative fuels. Good Excuse for using your old bike to ride locally :). In turn improving your health!

As they say, Nature does take its course;

Moving On - A Consultant's journey

I am moving on to a new client. Consulting, by nature, is a good thing. You get to learn a lot. Having said that, Projects get over, You move forward to other things. Its hard some times, emotionally. You get attached to people around you. and Then You see you have to go. I am strongly attached to this team.

This a consultants life. I know. Even though I understand the practical ramifications, I still feel a little bad about *going away*. I am gonna miss the team for sure. So as a consultant I am supposed to reach an agreement with this fact. I am single. I can. But What when I get married? How will my fiance take it? How about when I have kids? I cannot dare imagine what would be going through my kid's mind if I do this to him.

So My advice is, Keep Consulting until you get married. You can consult part time after, but stick to a good old full time job.

My consolation for now is that I can be looking forward to better things. And I hope there will be. This gets me excited at the …

Using Commons Pooling for Objects in JEE

A little more than 3 weeks ago, I was asked to rewrite a Multi-threading component that *pooled* connections to Mainframe HTTP Gateway. There was an existing implementation with synchronized array of connections which was initialization with a configurable size. The problem was this implementation was home grown way back in history, and the confidence level in that code was very low. Especially because its going into a JEE container and code-managed threads were not scaling atone to the container.

My first instinct was to use Apache Commons pooling. For one, this would have been much more QA-ed than what I would have implemented. The primary logic would be approximately the same, create-pool > borrow-object > return object. Everything could be done with commons pooling, using the GenericObjectPool.

On a finer level, I need to manage the life of the objects themselves - make sure the encapsulated connection is not stale etc, in which case invalidate it
A sample example (as in JavaDo…

Maven - Is it worth the hype?

I am glad I entered a (somewhat) heated argument with a friend of mine about maven and its' usefulness. My stand was that maven saves developers' life. His stand was otherwise. The points I had were, quick start, arch types, version-ing in repo and a good M2 eclipse plugin. My friend however still believes ant is the best thing ever happened to Java community. He would rather deal with the jars himself than excluding every conflicting jar manually. That lead me researching.

For me the selling points in maven are
With Maven archetypes, You can create a project (template) in one command. And voila you are good to go. But this is not a very big selling point, because most times, you just create once. Maven also gives you a way to create a project for different IDEs automatically. This one is very nice, coz you need not check in the classpath and project (config) files into your source control. Also, A new user does not need a setup help since the project structure is familiar and I…

Firebug dom css come Default

Having installed FF3, the initial migration was hard on me. Firebug which is a daily life saver, was missing.

It was just days, I got Firebug 1.2.03beta. Life is back to normal. Infact a lot better, because Now, just to walk the dom, look at css, or edit html&css on the fly, I donot need to *enable* firebug, These three features come standard.


Console, Script and Net features require you to *enable* them seperately. This drastically improves performance of my FF. Now I don't need to make FF heavy during designing css.


Love you Firebug!

YUI Compressors

Easy things first! As you know, I have a back log of posts that I have to dump out of my brain into this blog. I will start with the easiest.

YUI Compressor. This is a freeware from YUI. I was looking at the MultiThreading in JS post in infoq.com and found that this Concurrent.Thread.js is around 500KB. Which is quite big for a js file. And imagine the poor vistor of my site from Bugaria on a dialup with 56 Kbps line, This page is as good as a download! So, What can be done? 1. Compress the JS, 2. Then Gzip the data transfer. Well The second option might not be in *your* hands as a developer, the first is always your decision.

Using YUI is absolutely easy. Download the jar file and run
java -jar yuicompressor.jar myjsfile.js

And you got a compressed and obfuscated file (would you not want this! The users can no longer steal your js code!). You can also do this to your CSS files. There are other compressors like dojo, JsMin but this one beats them all.

Google Bookmarklets

Some Times It is easier to just click a bookmark and *put it in google*. Bookmarklets are small javascripts that run to *do something* which would other wise take user intervention. These are a few google bookmarklets I use. I will make a set of features in sarathonline.com to have these too!! To learn a more about bookmarklets - see this wiki

Note Book - Note This
Bookmarks - Bookmark
Translate to English - Translate
Calender - Add event
Maps - Map This
Define a word - Define This

Org post, continued

Back from time off.

I just came back from a personal time off, I have been researching on so many things, just dint find time to blog it.

Here is what I have been looking into and so much still left to read. In the coming weeks I will wrap these readings. Concept of Actor Model. Scala, its eclipse plugin, its web frame work lift. Multi Threading in Java Script. YUI Compressor. Scrum Agile and XP.

I have also been improving contacts in my linkedIn profile. If I missed you, Please add me to your network.

What is Consumer JRE, Java Kernel

The JRE 1.6 update 10 around the corner. Sun's Initiative to slim down a huge 14 MB JRE download is very much understandable to keep itself in competition. But for an average joe, How would this matter? There is some confusion in understanding what is this release about. Why is this in minor release update? What is expected? Why now?

Java Kernel, has been in talks for a while now. Why now - because with AIR, SilverLight taking on RIA market, Java cannot lag behind sticking to its thick client apis (AWT,SWT). But here is the thing, This release hass no change in API. Its just a new JRE implementation.

Okay What is it? The JRE consists of a bootstrap library and a bunch of system, language and util libraries. There may be inter dependencies in these libraries. Making the smallest possible JRE that can start on itself is the Java Kernel. After You get java kernel, Consider that a java program is asking for some dependencies, The Java Kernel *downloads* it and loads in the program for …