Monday, December 14, 2009

Webdriver with Lift

A briefing on webdriver is here:

Applying lift makes tests more readable:
LiFT allows writing automated tests in a style that makes them very readable, even for non-programmers. Using the LiFT API, we can write tests that read almost like natural language, allowing business requirements to be expressed very clearly. This aids communication amongst developers and customers, helping give all stakeholders confidence that the right things are being tested.

check https://lift.dev.java.net/


Wednesday, December 2, 2009

For your eyes only

Eye defender - take a break  http://www.eterlab.com/eyedefender/download/


Troubleshooting Oracle connections related problem

/* Display the number of sessions created for this db connection */
select username,schemaname, osuser,machine, terminal, program, type, module, event,service_name sid,  command, status from v$session

SELECT name, value FROM gv$parameter WHERE name = 'resource_limit';


maven-release-plugin

I think one of the nicer things about Maven is pluggability ( apart from ability to have mulptiple profiles).

Maven release plugin abstracts a bunch of task to be performed pre-release. This plugin comes default with maven 2.x.

This simple command does all the hard work for you:
  mvn release:clean release:prepare release:perform

This cleans any previous release config, tags the release, increments the snapshot version , commits themand finally sends artefacts to proxy maven repository(like archiva).

Gotchas:
1. This happened when I tried using release feature for the first time.
It would fail saying cannot tag the release.. inspite of able to commit the code with version changes.

Solution:
    <plugin>
         <artifactId>maven-release-plugin</artifactId>
         <version>2.0-beta-9</version>
     </plugin>      

Also check the scm config in your pom

 <scm>
        <connection>scm:svn:svn://svn.company.com/my_project/trunk</connection>
        <developerConnection>scm:svn:svn://svn.company.com/my_project/trunk</developerConnection>
        <url>http://svn.company.com/my_project/trunk</url>
    </scm>

Tuesday, November 24, 2009

Spring interceptor ordering

SimpleUrlHandlerMapping uses a hashMap to hold the interceptors. Ordering can only be guaranteed by setting  order property.. By default it does a random get from the hashMap.



http://kickjava.com/src/org/springframework/web/servlet/handler/SimpleUrlHandlerMapping.java.htm
extends
http://kickjava.com/src/org/springframework/web/servlet/handler/AbstractHandlerMapping.java.htm

I was wondering if such things goes live by getting a right value...how do they get caught as their order is  random without explicitly saying so.
Maybe spring should warn us upfront..(or maybe it does?)

Useful link : http://forum.springsource.org/showthread.php?t=51281


Wednesday, November 4, 2009

Subversion patch release

Releasing a patch to an already released (tagged) trunk would need some steps to be done.
Though it would take time it seems like a best practice to keep the code in sync across tags/ branches/ trunk.

The details:
a. Create copy of latest released tag into your branch B.
b. Fix bug in branch B
c. Copy fixed branch B to tag+1
d. Merge branch to trunk.
e. Remove branch.

Thursday, September 10, 2009

Ubuntu - linux

Setup ubuntu today.
First impressions:
- Very simple to install (very simple partition manager).
- GUI looks similar to fedora.
- Music started playing without any messy configuration( had to struggle to get it working on fedora)
  Bundled radio stations started singing the melody....
- Was looking around for a cool applications equivalent for ubuntu like "easylife" installer in Fedora.
sudo aptitude install [application name] looks reasonable but not so cool like eaylife.
- Windows XP gets automatically detected and drives get auto mounted.
- More to come..

Useful links:
Linux problem determination
Show all running process


OSGi - Open Services Gateway Initiative

Basics:
Distributed in the form of a bundle.
Ref: http://www.javaworld.com/javaworld/jw-03-2008/jw-03-osgi1.html?page=1


Take it to the server side
An interesting read to start off web app development using osgi with tomcat
http://www.javaworld.com/javaworld/jw-06-2008/jw-06-osgi3.html?page=1

Spring DM (dynamic module) + osgi

Cleanup dirty code using the power of regular expressions

In eclipse search for all irrelevant comments and clean them up:
/\*\s(\r\n.*\r\n)+(\s)+\*.*(@see)*.*(\r\n)+(\s)+\*/
or
For finding all comments blank use >> (?m:)/\*\*(\r\n)+(\s)+\* @[^/]*/
Note: m tells eclipse to search multi line.

Eg:
/*
  *
   * @see ...
   */

The above pattern can be cleaned up very easily with pattern above.



Thursday, August 27, 2009

Behaviour-driven development in Java - Junits evolved ?

As TDD is more of running junits(at a very unit level) and hence we focus very little in writing tests which check code as a functional unit.

BDD(behaviour-driven development) fills up this gap I think and is more closely aligned to developers way of thinking.
I see it more like an organized functional tests in code!

As such system work in unison and not just as a small unit. Hence a boundary has to be defined as to which all parts of the system should be tested and how based on time/money tradeoffs ?

Implementations of BDD for java: http://jbehave.org/
Implementations of BDD for groovy: Easyb

Reference: http://www.jroller.com/DhavalDalal/entry/preferring_bdd_over_tdd



Friday, August 21, 2009

Speed up your maven build

Imagine a company having 10 modules each depending on the other. Lets say building it would take 15 minutes using maven.
So the team would spend roughly in a day - (noOfBuildTimesPerDay x 15 minutes) x developerCount. This is bad.
Some options : "mvn clean install" is good for small/medium sized projects but not for bigger ones. Trade-off between time and space is always there. When space is not a major constraint , we can gain time by "mvn clean install -Dmaven.compile.fork=true -Dmaven.junit.jvmargs=-Xmx512m -Dmaven.junit.fork=true" With mvn clean, delete on windows is slower, instead if we rename it could boost the build time. http://bosy.dailydev.org/2009/02/speed-up-your-maven-build-four-times.html This cut the build time by around 30% on my PC. Thats an improvement isnt it.
I think it would be a big improvement if maven can reuse the classes generated by
eclipse. Also having an exploded war deployment is an option to reduce pack and unpack times.

Friday, August 14, 2009

Real-Time Tracking and Tuning for Busy Tomcat Servers

A very nice article which details on possible options for tomcat server monitoring to tweak its performance.
http://www.devx.com/Java/Article/32730/1954

Tuesday, August 11, 2009

Free your mind with mindmaps

Mindmaps help you quickly organize and load the knowledge into your brain. Also the noise words are minimal in a mindmap and hence our thinking pattern becomes clearer.

Some usefuls:
For presentation
http://www.mindmeister.com/26036305/presentation-zen-powerful-presentations
for vocabulary
http://www.mindmeister.com/1479825/new-words-oh-a-little-tidy

For a free software goto - freemind.org
online - http://www.mindmeister.com

Friday, June 19, 2009

Eclipse and Idea hot key bindings

Ok our developers use IDEA and Eclipse. And we do pair programming.
Hmmmn I dont want to learn another set of key bindings...!!

Here is the solution:

Using eclipse keys from idea:
  • Idea supports Eclipse key binding built-in;
  • you just have to switch to eclipse key bindings using preferences dialog;

Using idea key's from eclipse:



Tuesday, June 16, 2009

Tomcat Exploded war - cut deployment time

The time taken for a webapp to be packaged into a war, deploy and then have it unpackaged in tomcat container can be reduced. Simply have the exploded war deployed.  This could save time for developer!!



Steps to make exploded war deployment:

1. add this under pom.xml >> plugins
             
             
                org.codehaus.mojo
                tomcat-maven-plugin
                1.0-beta-1
               
                    admin
                    admin
                    <url>http://localhost:8080/manager

               

                                          


2. mvn war:exploded tomcat:undeploy tomcat:exploded
--This keeps the war exploded, undeploys the webapp context and copies over the exploded build to tomcat using the tomcat manager.


Also a better option to deploy to different servers and also generating the war ( instead of configuration above):
mvn clean install -Dmaven.test.skip=true  war:exploded tomcat:undeploy tomcat:exploded -Dmaven.tomcat.url=http://localhost:8080/manager -Dtomcat.password=admin -Dtomcat.username=admin


Refer for more http://mojo.codehaus.org/tomcat-maven-plugin/exploded-mojo.html








Monday, June 1, 2009

Etags - request header tags to speed up your site .

An ETag (entity tag) is an HTTP response header returned by an HTTP/1.1 compliant web server.

There are 2 possible implementations :
1. Shallow Etag
           - An MD5 hash is computed for first request from the response content and set in the response header by the web filter.For subsequent requests, the filter retreives the previous etag and checks with the new etag computed using the response content.

Minuses:
   -etag is computed after page is rendered on the server.
   - Doesnt work for pages with dynamic content per request (like date/time).
   Spring 3 has this support. It is called ShallowEtagHeaderFilter.

2. Deep Etag
     -This avoids page computation at a much granular level. Uses hibernate interceptors and is not so straightforward to implement. Spring 3 is yet to support this approach.


References:
infoq article


Saturday, May 23, 2009

Texter - An auto text expander

I just cant imagine how many times I would have typed the same sentence again and again...
Texter to the rescue.... thanks to Adam Pash!!
As the source is open for viewing, there is no nasty spyware in it I suppose!!
It is built using autohotkey for windows. Its scripting mode is excellent. Check this for syntax.