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.

Monday, 29 September 2008

Some Ideas for Desktop Improvements

I have few ideas to improve the desktop presentation to support better my needs. Basically a few things that I find important:

To Do List

I want a to do list which is more or less always present when the desktop is on.
  • classification by priorities
    • important and urgent
    • not important but urgent
    • important and not urgent
    • not important and not urgent
    • not classified
  • classification by subject
    • work
    • administrativ
    • Hobby
    • Family
  • Style of the task and Icons
    • Position of Tasks as Desktop Icons
    • Size of Desktop Icons
I had seen a few months ago a presentation by Mozilla Labs (if I recall well) as well as others on how to improve the display of the desktop. I find this really good. This might not be that complex to implement. But before starting the implementation, I only need to know where the different parts are stored, as well as the process used for making the changes. I am not completely sure whether the information remains in memory or is stored on file. For instance, the position of the different icons is found in the following file: ~/.nautilus/metafiles/file:%2F%2F%2Fhome%2Fusername%2FDesktop.xml

Organized Important Files

I want that the files which I have on my desktop are organized in a meaningful way, for example in thematic and time oriented way. From left to right time oriented, top to bottom thematic. Of course the classification cannot be automatic for the thematic way. Moreover, the time oriented way might not always be relevant.

Friday, 26 September 2008

Firefox Plugins

There are a number of useful firefox add-ons:
No Script
an add on to control easily whether scripts (java, javascript, flash) are allowed to be performed. This is a per domain enabling or not.
Download Them All
with this add on, it easier to download many resources from a web page
Download Status Bar
adds a status bar which shows the status of downloading of things from firefox.
Greasemonkey
using greasemonkey allows to write scripts to be performed on top of web pages
Firebug
This is a utility to help in developing javascripts.

Monday, 22 September 2008

Hibernate

Hibernate is an OR-Mappping. Mostly adapted the examples from the chapter 2 of Java Persistence with Hibernate
Second Edition of Hibernate in Action
Christian Bauer and Gavin King
November, 2006 | 880 pages
ISBN: 1-932394-88-5
The goal is to map the objects created by a object programming language such as Java to a relational database in order to provide persistent objects, i.e object which can be stored on disk and which do not disappear when the virtual machine shutdowns. Hibernate performs the mapping using configurations files in xml (or other). Here is an example of XML file for a mapping called tasks.hbm.xml:
<?xml version="1.0"?>
 <!DOCTYPE hibernate-mapping PUBLIC
   "-//Hibernate/Hibernate Mapping DTD//EN"
   "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
 <hibernate-mapping>
   <class
     name="mytasks.Task"
      table="TASKS">
    <id
       name="id"
       column="TASK_NAME">
       <generator class="increment"/>
    </id>
    <property
        name="name"
        column="Task_NAME"/>
    <many-to-one
       name="nexttask"
       cascade="all"
       column="SPOUSE_ID"
       foreign-key="FK_NEXT_TASK"/>
   </class>
</hibernate-mapping>
a class like:
class Task {
   private String name;
   private Task nexttask;
}
package mytasks; import org.hibernate.*;
import persistence.*;
import java.util.*;
public class TaskExample {
     public static void main(String[] args) {
         // First unit of work
         Session session =
          
        HibernateUtil.getSessionFactory().openSession();
         Transaction tx = session.beginTransaction();
         Task firsttask = new Task("Learn Hibernate");
         Long meberId = (Long) session.save(firsttask);
         tx.commit();
         session.close();
         // Second unit of work
         Session newSession =                     HibernateUtil.getSessionFactory().openSession();
         Transaction newTransaction =            newSession.beginTransaction();
         List tasks =            newSession.createQuery("from Task m order by m.name asc").list();
         System.out.println( tasks.size() + " Task(s) found:" );
         for ( Iterator iter = members.iterator(); iter.hasNext(); ) {
           Tasks task = (Task) iter.next();
           System.out.println( task.getName() );
         }
         newTransaction.commit();
         newSession.close();
         // Shutting down the application
         HibernateUtil.shutdown();
     }
}
It is possible to set the configuration file for the session factory using new Configuration().configure(<locationof config file>); for example:
SessionFactory sessionFactory = new Configuration()      .configure("/persistence/tasks.cfg.xml")      .buildSessionFactory();
calling new Configuration().configure(); would look for a file called: hibernate.properties in the class path directory outside of any package. the Hibernate Configuration file:
<!DOCTYPE hibernate-configuration SYSTEM "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
     <session-factory>
       <property name="hibernate.connection.driver_class">
         org.postgresql.Driver        </property>
       <property name="hibernate.connection.url">
         jdbc:postgresqll://localhost
       </property>
       <property name="hibernate.connection.username">
         sa
       </property>
       <property name="hibernate.dialect">
         org.hibernate.dialect.HSQLDialect
       </property>
     <!-- Use the C3P0 connection pool provider -->
       <property name="hibernate.c3p0.min_size">5</property>
         <property name="hibernate.c3p0.max_size">20</property>
         <property name="hibernate.c3p0.timeout">300</property>
         <property name="hibernate.c3p0.max_statements">50</property>
         <property name="hibernate.c3p0.idle_test_period">3000</property>
         <!-- Show and print nice SQL on stdout -->
         <property name="show_sql">true</property>
         <property name="format_sql">true</property>
         <!-- List of XML mapping files -->
         <mapping resource="mytasks/tasks.hbm.xml"/>
     </session-factory>
</hibernate-configuration>

Note the use of a certain number of configuration entries:

  • the Hibernate connection pool provider: here the C3PO-connection-pool-provider
  • the hibernate dialect used, here the HSQLDialect
  • the connection information: drivers, url and username
  • the mapping file

There are a number of other possibilities to configure Hibernate.

Antipatterns and Code Problems

Here a few resources for antipatterns, which are patterns of behaviour or architecture which tend to create problems. First of all, there is a well known book on the subject. There is also a web site for the books: http://www.antipatterns.com/. Here another resource about Antipatterns in the software development: AntiPattern in der Softwareentwicklung (Note the text is in German). Also in addition a resource on symptoms which call for refactoring: SmellsToRefactorings.

Tuesday, 16 September 2008

Java AWT bug on linux with XCB

When starting my java application on linux, I have the following traceback:

Locking assertion failure. Backtrace:
#0 /usr/lib/libxcb-xlib.so.0 [0xc3e767]
#1 /usr/lib/libxcb-xlib.so.0(xcb_xlib_unlock+0x31) [0xc3e831]
#2 /usr/lib/libX11.so.6(_XReply+0x244) [0xc89f64]
#3 /usr/java/jre1.6.0_03/lib/i386/xawt/libmawt.so [0xb534064e]
#4 /usr/java/jre1.6.0_03/lib/i386/xawt/libmawt.so [0xb531ef97]
#5 /usr/java/jre1.6.0_03/lib/i386/xawt/libmawt.so [0xb531f248]
#6 /usr/java/jre1.6.0_03/lib/i386/xawt/libmawt.so(Java_sun_awt_X11GraphicsEnvironment_initD

It has already been discussed in a number of forums and bug reports:

http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6532373, or https://bugs.launchpad.net/ubuntu/+source/libxcb/+bug/87947

One possible work around seems to be to add the following variable setting when starting the application:

export LIBXCB_ALLOW_SLOPPY_LOCK=1

Monday, 15 September 2008

Autotest - WOW they did it!!!!

Welll I was reading as always a little bit of this automated testing approach. And I was again on this page: http://autotest.kernel.org/ Autotest is a software which allows the automated testing of the linux kernel, that is, it is an infrastructure to build, boot and ... linux kernels. It has quite a lot of features:
  • bisection...
  • building
  • booting
  • filesystem check
  • python based library to automate scripts
There is a good presentation on autotest presentation.

PXE Problems with NAS 1000

A good friend of mine gave me a NAS 1000 so that I could try a few things with it. In particular, I wanted to try PXE and diskless solutions with the installation files or disk data on the NAS server.

First I had some troubles starting the atftpd daemon because of user and group information which did not work. I should have checked the messages information right away... duh!!! It would have saved me a lot to time.

But then as I tried getting the data from my linux box using the fedora tftp client, it did not work. Well actually I am still not sure why it is not. Some routing errors obviously:

Jan 1 13:36:21 icybox daemon.info atftpd[1951]: Server thread exiting
Jan 1 13:36:26 icybox daemon.notice atftpd[1952]: Fetching from 192.168.0.104 to ess

Saturday, 13 September 2008

Syntax highlighting for the Web

As I was reading an interesting post from Otaku, Cedric's weblog, I learned about the existence of a web syntax highlighting solution: pastebin, which is GPL software. It seems to be based on another GPL software: Genshi. This may prove useful once in a while. Especially if I intend to port my post to another blogging software since I am not completely sure about the user settings of blogger.

Friday, 12 September 2008

Java invokeLater

A number of month ago, I took a look at the new features of Java 1.5 and 1.6. And I fell on the new java.util.concurrent package.

Whoever programmed GUI interfaces in Java is certainly aware of the importance of using thread to run in the background in order to enable the user to perform other tasks and not just wait in front of a screen which is not refreshing. Using nice runnable threads, you could have a much more responsive GUI. A typical example was things of the sort:

Thread t = new Thread(){
  public void run(){
   // the task to perform which requires a certain amount of time
  }
};

SwingUtilities.invokeLater(t);

This technique is really fundamental to a well programmed graphical interface.

But since Java 1.5, there are a number of supplementary structures which can be used to perform tasks in parallel. And these are found in the package java.util.concurrent which will be the topic of a future entry.

Overview of Maven

Maven is a tool design to support as many task as possible for the management of a software project.

Its purpose is to provide a simple tool to achieve the following tasks:

  • Builds
  • Documentation
  • Reporting
  • Dependencies
  • SCMs
  • Releases
  • Distribution

A number of good tutorials can be found on maven's guide page.

Archetypes:

In maven there is the possibility to create archetype models of projects. This means that it is possible to create very easily new projects which have a number of templates to start with. This is related to the possibilities of RAILS.

This is performed by issueing the following command:

$ mvn archetype:create -DgroupId=com.mycompany.app -DartifactId=my-app

Project Object Model: POM

There is a concept of project object model somewhat similar to the ant build files.

An example from the website (see this page):

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.mycompany.app</groupId>
  <artifactId>my-app</artifactId>
  <packaging>jar</packaging>
  <version>1.0-SNAPSHOT</version>
  <name>Maven Quick Start Archetype</name>
  <url>http://maven.apache.org</url>
  <dependencies>
      <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>3.8.1</version>
        <scope>test</scope>
      </dependency>
  </dependencies>
</project>

This model is quite easy to understand.

Project File and Directory Structure

The project file and directory structure depends on the archetype chosen to create a new project. There are means of configuring this, see: http://maven.apache.org/guides/mini/guide-creating-archetypes.html.

The build Life cycle

Each possible tasks (e.g. validate, compile, package) may require other to be performed first. This means that there are dependencies between the tasks (like in ant).

Common tasks
  • mvn compile (compile the code)
  • mvn test (test the functionalities of this project)
  • mvn test-compile (compile test classes for this project)
  • mvn package (package the code of this project)
  • mvn clean (clean the builds and task )
  • mvn site (create a template website for the project)
  • mvn idea:idea (create an IntelliJ IDEA descriptor for the project)
  • mvn eclipse:eclipse (create the project description files for eclipse)
Maven Plugins

There are a number of plugins which can be useful for maven. You can add them to the POM file of the project, see: How_do_I_use_plug-ins

A list of plugins can be found there.

SCM Plugin ( Source Code Management plugin)

One of the many pluging is the SCM plugin which offers useful tasks/goals for interacting with a SCM

External Dependencies

There is also the possibility to configure external dependencies.

Deployment

There are also possibilities of deployment if things are configured. For example, the created distribution can be copied and added to a repository using scp. For this, some information about user names, keys and/or passwords have to be configured.

Documentation

There are also some thing to help in the creation of a documentation site using archetypes. See: guide-site.