Ce jeudi 15 mai 2008, j’ai eu le plaisir de rejoindre la société Iris Luxembourg (sise à Windhof).

Mon rôle principal sera de réaliser des analyses pour des applications IBM/Lotus, en particulier pour des applications basées sur les solutions Websphere Portal et WCM d’IBM.

L’accueil que m’ont réservé mes nouveaux collègues est très bon (comparé à mes expériences précédentes). Ce que j’ai trouvé le plus remarquable: tous semblent avoir du plaisir à y travailler, ce qui est très encourageant.

Je serai actif sur le projet de développement du nouveau site public de la chambre des députés, qui utilise une variété de technologies modernes.

J’ai donc de bonnes raisons d’espérer que j’ai enfin trouvé une entreprise dans laquelle il fait bon s’investir et où je pourrai développer ma carrière professionnelle de façon satisfaisante.

Iris Luxembourg: http://www.irislink.lu

Mon email professionnel: Yannick.Loth[AT]irislink.lu

The Java Instrumentation API provides services that allow Java programming language agents to instrument programs running on the JVM. The mechanism for instrumentation is modification at runtime of the byte-codes of methods.

This API may be used to transparently add method-call logging to any Java code at runtime, without changing the source code or the compiled byte code. This automation of the generation of log statements reliefs the programmers of this tedious task.

The following URL links to an interesting article about how to implement automatic logging:

add-logging-at-class-load-time-with-instrumentation.html

The following URL links to the same article printed as a PDF file.

Add logging at class load time with java instrumentation

A transaction is a unit of work that is treated in a coherent and reliable way independant of other transactions.

This unit of work may, for example, be composed of database operations and messaging services operations. If a part of this unit of work fails, the whole unit is considered as having failed.

Database transactions should be atomic, consistend, isolated, durable: ACID.

  • Atomicity ensures that either the whole work is done or nothing is done.
  • Consistency guarantees the respect of integrity constraints.
  • Isolation defines how the changes made by a current operation are visible from other current operations.
  • Durability guarantees that transactions that are successfully commited will survive permanently and cannot be undone by system failure.

Transactions may be global (they work across several transactionnal ressources, for example a transaction may be composed of DB operations and messaging operations) or local (they only work with one transactional resource).

Transactions have different properties that define their behaviour: propagation, isolation, read-only, timeout.

  • Propagation specifies how code behaves when a transaction method is executed when another transaction context exists (continue running in the same transaction, suspend the running transaction and run in a new transaction context,…).
  • Isolation was described as a member of ACID, and is composed of several levels.
  • Read-only indicates that no write operations will be done during the transaction.
  • Timeout indicates the time after which a transaction must be rolled back.

Isolation levels:

  • Serializable provides the highest transaction isolation. This emulates serial transactions, as if transactions occured the one after the other.
  • Repeatable read occurs when a transaction re-reads data and the data cannot have been modified by another transactions’ commit since the initial read.
  • Read committed occurs when a transaction can only access data that was committed before the select query began.
  • Read uncommitted (also known as dirty read) occurs when a transaction reads data written by concurrent uncommitted transaction.

The three phenomena that must be prevented are:

 

  • Dirty reads: Occur when a transaction reads data written by concurrent uncommitted transaction.
  • Non-repeatable reads: Occur when a transaction re-reads data it has previously read and finds that data has been modified by another transaction (that committed since the initial read).
  • Phantom reads: Occur when a transaction re-executes a query returning a set of rows that satisfy a search condition and finds that the set of rows satisfying the condition has changed due to another recently-committed transaction.

This matrix shows how isolation levels may be used to avoid these phenomena:

Isolation Level Dirty Read Non-Repeatable Read Phantom Read
Read uncommitted Possible Possible Possible
Read committed Not possible Possible Possible
Repeatable read Not possible Not possible Possible
Serializable Not possible Not possible Not possible

Note that transactions are different in DB and in programming languages.  Programming languages introduce the concept of propagation.

Propagation levels in the Spring framework:

  • Required : In the case that during a running transaction, a second one is started, the second transaction operations are executed in the same existing context of the first transaction.
  • RequiresNew : Each transaction uses a completely different context.
  • Nested : Uses a single physical transaction with several savepoints that it can rollback to.

Last week I started a new project on Sourceforge.net, which aims to design and implement a general purpose tree API for the Java language. In fact, I’ve never found a such one.

This API will provide binary as well as n-ary trees, different iteration algorithms, the observer design pattern and interception possibilities (pre- and post-operation).

The project is called javatreeapi.

Ideally, this API will be as easy to use as the Collections framework.

Any comment or link to some theoretical works about trees or link to existing implementations with the same purpose are welcome.

The Java Platform Debugger Architecture (JPDA) provides the infrastructure you need to build end-user debugger applications for the Java Platform.

This permits to remote debug local and remote applications, provided the JVM is started with the right arguments.

Using this functionality, even applications run in remote web containers like Tomcat and Jetty may be debugged.

To remote-debug Tomcat, you have several options, and I’ll describe one of these here:

  1. Set environment variables JPDA_ADDRESS=8000 and JPDA_TRANSPORT=dt_socket and then start tomcat using catalina jpda start.
  2. Start Tomcat with the following JVM options: -Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n

The second option is actually valid for any Java application.

On Linux systems, if the port 8000 is already used by another process (on my system dbus already uses this port), you may use any other free port. I use the port 38000 for JPDA. To see which ports are used and by which applications, run the following command: netstat -a -n.

For more information about JPDA, you may go to the Sun site: http://java.sun.com/javase/technologies/core/toolsapis/jpda/

The implementation of JSF used in Alfresco is MyFaces, and as such, it is incompatible with some J2EE application servers which come with some other implementation.

In JBoss, depending on the AS version, some actions must be done to disable the standard implementation.  These actions are described in the JBoss Wiki, follow this URL: http://wiki.jboss.org/wiki/Wiki.jsp?page=Running2.6WithJBossAS4.2.xAndMyFaces

The easiest is to use the bundled version of alfresco with Tomcat, change its ports to avoid clashes with other instances of Tomcat or other servers and attach it to an Apache httpd server with the Tomcat connector.