I made a change in the blogger configuration to ease the later work when blogging. It is possible that older entries are not correctly formatted.

Thursday 21 January 2010

Gradle - a groovy Make

So in my search for some maven solution. I fell on YAPMT (Yet Another Project Management Tool). I am not sure it does the same things as Maven. It uses Maven and looks much more like a script mechanism. So I will have to see whether it is suitable. While Maven is quite useful since it has a lot of plugins and a really well organized workflow. I would say that gradle seems to be like a groovy shell with a certain number of plugins for project management.

I will have to keep an eye on it.

Sunday 17 January 2010

Dojo Toolkit - Yet another javascript toolkit

After looking at roo, I noticed that they used the Dojo Toolkit for their default implementation of the web toolkit of the page. I Have not yet done a real comparison of the two frameworks. It seems to have more or less the same functionality as ext-js. I will have to keep an eye on both systems. At least from the licence point of view is Dojo more appropriate for companies, since it uses a BSD/Apache licence, where as ext-js under GPL ( I do not think that it has also a LGPL version apart from the core). Dojo seems to be composed of three parts:
  • Dojo core
  • dijit
  • dojox
Dojo core contains a number of utility methods for querying web pages content and perform operations on it. Dijit is a widget mechanism. Dojox are extensions based on dijit.

Saturday 16 January 2010

URL Rewriting Code in Java

Some time ago, I had to take a look and have something work with URL rewriting. My colleague told me there was an URL rewriting tool called URLRewrite. I will later introduce it here: http://tuckey.org/urlrewrite/.

On Top of the Monitoring

So the new trend in naming of projects is to top every thing, in order to imply that these tools are similar to the top command. So the idea is to have a console (text-based) tool indicating what process or activity are currently at the top of their category (e.g memory consumption, processor last)...

So here are the few project I just discovered:

  • htop
  • innotop
  • ApacheTop

And I suppose there are many others.

htop

htop is the closest to (the ;-) ) top, since it is a kind of enhanced top. I tried it. And it was quite nice.

innotop

The name of this one comes from innoDB which is one of the possible backend to a mysql database. I have not tried this tool but I suppose it is like top but just for a mysql database.

ApacheTop

A kind of top for apache request. I think I should take a look, because it might be useful for debugging purposes of our applications.

Thursday 14 January 2010

Coole Eclipse Shortcuts

I found this link on http://viralpatel.net/blogs/2009/07/20-very-useful-eclipse-ide-shortcuts-for-developers.html.

I found the following shortcuts really great:

# Alt + Shift + L : Extract to Local Variable

Say you have the following method:

public void myTest(){ String finalVariable = "first part" + "second part"+ "third part"; }

if you select "first part" + "second part" and use the short cut :

Alt + Shift + L : Extract to Local Variable

Then eclipse ask for the name of the new local variable, e.g firstTwoParts, and the method looks like:

public void myTest(){
  String firstTwoParts = "first part" + "second part";
  String finalVariable = firstTwoParts + "third part";
}

# Alt + Shift + M : Extract to Method

The same also works with methods. Say you have the following method:

public final static void main(String[] args){
  if (args.length >2){
   System.out.println(args[0]);
   System.out.println(args[1]);
  }
}
if you select the whole if statement up to the }, and use the shortcut: Alt + Shift + M eclipse prompts for the name of the method and creates the parameter, for args.

# Alt + Shift + W : show the class in the package view.

Well I did not know that. But this is very useful, because I often need it.

# Ctrl+Q : Last edit

There is also a button to find this. But a short cut is even better.

# Alt + Left or Alt + Right : Navigate Left and Right

I knew this one but this is also very useful, since it is much quicker than using the mouse every time.

Java scrapbook page

I discovered the java scrapbook page. Which allows you to try simple snippets of code very easily. I should try that. It is really cool.

Myllyn WikiText - Edit documentation easily for different formats

I just discovered that there is in the Eclipse Galileo a very easy and simple way to edit documentation called Wikitext. Documentation for this can be found in the eclipse documentation. Try it. It is just great.

It is in that way possible to use a WikiText format (out of a choice of 3 or 4 different one to write documentation. This Wikitext cabn be then used to generate html or docbook format. This is therefore very useful to create documentation.

See more at http://help.eclipse.org/galileo/topic/org.eclipse.mylyn.wikitext.help.ui/help/Mylyn%20WikiText%20User%20Guide.html

ROO - a spring and Maven based rapid development framework

I just discovered ROO. I tried it. But I had some problems running it under fedora with java 1.6 and maven 2.0.8. It seems that it need maven 2.0.9. The idea behind roo is to have a command line based system to develop. It is somewhat similar to Ruby on Rails. You issue commands and create and edit the entities that way. I give here an example of script:
project --topLevelPackage org.myexample persistence setup --provider HIBERNATE --database HYPERSONIC_PERSISTENT database properties list database properties set --key database.url --value jdbc:hsqldb:${user.home}/tmp/datasources/my-example database properties list
This first part of the script creates a project pom.xml (for maven) and sets the necessary properties for working with hibernate using an in memory database.
entity --class ~.domain.MyExample field string code --notNull --sizeMin 32 --sizeMax 32 field string firstName --sizeMax 65 field string lastName --sizeMax 65 field string email --sizeMax 65 field number age --type java.lang.Integer field date confirmed --type java.util.Date
This second party from the script creates an entity: MyExample. It also creates a number of fields: code, firstName, lastName, email. The next part of the script takes care of creating controllers and tests. The line:
controller scaffold ~.web.MyExampleController
creates a controller for CRUD operations. It also performs the tests to make sure it works correctly. Finally, it sets up the logging framework as well as the security framework.
test integration controller scaffold ~.web.MyExampleController selenium test --controller ~.web.MyExampleController perform test // (OPTION: quit, mvn tomcat:run, localhost:8080/myexample, mvn selenium:selenese) logging setup --level DEBUG --package WEB security setup
The next section creates a new controller class called: org.myexample.web.My2ndExampleController. It lists the finders and adds the finder to the class.
controller class --class ~.web.My2ndExampleController finder list --class ~.domain.MyExample --filter code,equ finder add --finderName findMyExamplesByCodeEquals perform eclipse
At the end the perform eclipse sets the system for using the system under eclipse.

Wednesday 13 January 2010

Interesting Loading Properties or files in Servlet Context

I was reading the documentation on tomcat in the web to be sure not to miss important information. And I found this at this wiki FAQ:

How do I load a properties file? Here are the two most popular ways:

  • Use a ResourceBundle. See the Java docs for the specifics of how the ResourceBundle class works. Using this method, the properties file must go into the WEB-INF/classes directory or in a jar file contained in the WEB-INF/lib directory.

  • Another way is to use the method getResourceAsStream() from the ServletContext class. This allows you update the file without having to reload the webapp as required by the first method. Here is an example code snippet, without any error trapping:

    // Assuming you are in a Servlet extending HttpServlet
    // This will look for a file called "/more/cowbell.properties" relative
    // to your servlet Root Context
    InputStream is = getServletContext().getResourceAsStream("/more/cowbell.properties");
    Properties p = new Properties();
    p.load(is);
    is.close();

Thursday 7 January 2010

The long way to a maveniozed Eclipse: M2Eclipse

I had some trouble installing everything for M2Eclipse. One part of the problem was that the fedora installation from eclipse did not really allow the installation of the correct packages. I used the description found in the free online book documenting M2: Developing with Eclipse and Maven.

Therefore, I downloaded the new eclipse from the web site and then I could install subclipse, AJDT and WST as needed. Though WST should have been there since it was the JEE version of eclipse.

Then I could install M2 from the http://m2eclipse.sonatype.org/update/ site.

It is interesting to have the poms. But since the poms are a little complex, I generate them from a more simple xml file. And these XML files can be generated using an even more simple XML file (though this is not yet finished). The goal is to help the bootstrapping of projects. In a simple manner.