December 2005

Announcing module release automatically

It’s been a couple of days now that I am learning how to use Confluence. The product is very nice, I had some minor problems which are currently handled by the support team. So far so good.

I used SOAP a couple of years ago now and I wanted to play a bit again with web services and all that. Confluence has a very rich SOAP API which allows users to pull but also push content. While creating my spaces and the page structure, I was thinking that integrating maven with confluence would be very convenient. The first use case in mind was to store a blog entry (i.e. a news) when a maven project was released. If you have used maven a bit, you are used to those mails warning users that a new plugin was released, check this link for an example.

Let’s say that you have a confluence space to share all things about one of your project. It would be nice to create a blog entry in this space every time you release a new version of your project, right? Well, I have implemented a quick and dirty solution using maven one and I am currently busy improving this solution. The plugin is based on the announcement plugin: it simply posts the result of the plugin in a blog entry. You can beta test the plugin if you want, simply invoke this command to download the plugin:

maven plugin:download
-Dmaven.repo.remote=http://stephane.nicoll.net/maven1
-DgroupId=nicoll
-DartifactId=maven-confluence-plugin
-Dversion=1.0-SNAPSHOT

Have fun and stay tuned…

Logging Service 1.0.1

So after some comments I decided to perform a full m2 lifecycle and deploy my simple logging service to some repository. It's up now and available on my own website here.

That's cool, I now need to play with the release plugin. Once I have gathered the info, I will share my experience with you. Meanwhile, I implemented the new features discussed in my last post about this very simple log4j service:

  • The reconfigure bug is fixed, reconfigure reset the log4j configuration so any custom logger is removed
  • The service now holds the URL of the current configuration file ; it is also able to dump the content of this file

For instance, deploying the service in the JMX domain allows you to dump the current configuration file using JConsole. This gives the following:

dump of the logging configuration file

If you want to use my logging service in your maven project, just add the following dependency:

XML:
  1. <dependency>
  2.       <groupid>net.nicoll</groupid>
  3.       <artifactid>log4j-service</artifactid>
  4.       <version>1.0.1</version>   
  5. </dependency>

You need of course to add my maven repository to your pom:

XML:
  1. <repositories>
  2.     <repository>
  3.         <id>nicoll-net</id>
  4.         <url>http://stephane.nicoll.net/maven</url>
  5.     </repository>
  6. </repositories>

A Simple Logging Service

Logging stuff in enterprise applications is really a tough task. Actually, logging introduces a paradox: on one hand logging is really critical when something went wrong ; on the other hand, nobody cares about logging when everything is just fine. We, as developers, have to really take that into account.

Honestly, choosing a logging framework in Java is an easy task: log4j is a reasonable choice as it is widely used. The only advice that I have in mind is to take attention to resource consumption, especially if you are logging to several files.

Let's say that you have found a critical bug in production and you need more logging on a particular piece of code. You need to be able to act on your logging configuration live, right? Well, all frameworks have their own Log4jService: JBoss, Spring, Geronimo, whatever. What I am proposing you is a very simple logging service that you could deploy in any environment, even as an MBean if you want. The interface of this service is really basic:

JAVA:
  1. public interface Log4jServiceMBean {
  2.  
  3.     String getLoggerLevel(String loggerName);
  4.  
  5.     void setLoggerLevel(String loggerName, String levelName)
  6.             throws IllegalArgumentException;
  7.  
  8.     void reconfigure(String configurationUrl)
  9.             throws java.io.IOException, java.net.MalformedURLException;
  10.  
  11.     String dumpConfiguredLoggers();
  12.  
  13.     Map getLoggingConfiguration();
  14. }

If you know me, you would be surprised to see that the interface is lacking of Javadoc. Well it has, I just remove it to improve readability :) . The reason why the interface is named MBean is to allow the service to be deployed as an MBean.

The first method is really simple and allows you to know the level (e.g. ERROR, DEBUG, etc) of a given logger. The second one is more interesting since it allows you to change the level of a logger live! This answer our use case above. Two methods allow you to see the logging configuration.

The last one is nice since you can reconfigure entierly your logging configuration by passing an url to another log4j configuration file. It could be:

Note that the last case is home-made. Whenever the url starts with classpath: it is handled as a reference in the classpath. If you have Tiger (Java 1.5), you can register this service in your application as follows:

JAVA:
  1. Log4jService log4jService = new Log4jService();
  2. MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
  3. serviceObjectName = new ObjectName("nicoll.net:service=Logging");
  4. mBeanServer.registerMBean(log4jService, serviceObjectName);

The code is released as LGPL so feel free to use it.

Javapolis Day Five

Javapolis was really a great experience: interesting people, excellent organization, technologies all over the place but also great speakers (I've also seen very bad presentations, I won't talk much about them).

Each presentation always ends with If You Would Remember One Thing containing one short sentence about the presentation. I must say, If I had to remember one thing of these five days, it's the amazing presentation on Agile methodologies by Scott W. Ambler. Folks, this men knows how to share the content of his presentation with the audience. I heard a lot about agile methodologies lately but to be honnest, I didn't know much before the presentation.

Presentations will be made available on the Javapolis Wiki ; I'll try to keep you posted.

Javapolis Day Four

Day four started with some interesting SUN roadmap over their products. Java SE 6, aka Mustang is expected to be released by Mid-2006 while Dolphin - Java SE 7 - is expected to be released by the beginning of 2008. Regarding enterprise edition, Java EE 5 is expected to be released by the second quarter of 2006. Jesus, they finally get rid of this weird Java 2 we used to know.

Regarding enterprise edition, I had a chance to attend an EJB 3.0 presentation by Linda DeMichiel (it was actually on Day 3). They finally simplified all this ; no more home, no more EJB object, no more complex jndi lookup. Dependency injections, easy deploiement with annotations and default configurations. Gosh, sounds like Spring :)

Talking about Spring, I attended the Spring Update presentation by Rod Johnson. Guys, this men does not like EJBs and has quite a lot of good examples to justify his position. Everything seems so simple with Spring that I will definitely have a look in the next weeks (christmas holiday are coming).

I was at the Maven presentation of course! (first row). The presentation was nice but one hour was too short to present all new aspects of maven properly. As Vincent said, maven 2 is not yet mature and users need to closely work with the dev team. I hope this will not discourage people from using it because it's a great tool. It was quite funny when Vincent asks if Hani was in the room (the men used to vomit at maven in his blog) but he was at ApacheCon. Too bad!

Javapolis Day Three

A bit late and on a SUN workstation with a *very* weird keyboard!

I learned a lot about the JCP during day three. Namely an amazing presentation by some woman having his powerpoint tool in edition mode during the presentation and using the slide tabs below the page to switch slides. Someone should show her the page up and page dowm keys some day.

The presentation of Eemann McManus on JMX was really great. I saw the JConsole for the first time of my life and feel a bit stupid since it's there for ages now.

This keyboard is driving me crazy. If you want links about those concepts people, go search yourself! I will add links later on...

Javapolis Day Two

So I am on wireless at 10€ per 2 hours so it's gonna be short! (I actually have 5 minutes left)

Today's presentations were great. Particularly, Effective Enterprise Java by Ted Neward who is the author of a book with the same name.

Guys, this men is amazing: his presentation was full of really interseting examples and it was globally fun. It gaves me idea about interesting stuff we could do regarding monitoring and application availability testing, a.k.a. the Happy Page.

I'll come back later on this topic with a real example.

Javapolis Day One

So today was Javapolis Day One. I am so glad that my company allowed me to join ; I met already some ex-colleagues today and globally it was fun. Regarding the presentation, I went to the Business Rules Engines presentation from Mark Proctor. One word to qualify it: faaaaAAAaaaast. The men speaks way too fast, I am just waiting for the slides to read them back slower.

Lunch was quite ridiculous, A (very) basic sandwich in a room full a people smoking (no kidding).

On the afternoon, I went to the IDEA In Action presentation. To be honest, I know quite well IDEA so I knew it would be boring at some point. Jetbrains had the excellent idea to organize a lottery (20 Free IntelliJ IDEA 5.0 Personal Licenses). Thanks to Julien I have now my IDEA 5.0 Personal License. I bet I will talk about new IDEA's features soon here.

I came back earlier home because I am sick ; I have the flu or something :(

Maven news

Some maven news that I wish to share with you.

Maven 1.1 beta 3 is on its way, some plugins have already been released ; watch out the eclipse plugin namely which provides (at least!) support for sources for external libraries / modules (changes in 1.10 are available here).

Maven 2.0.1 will be released soon even if the release date is not confirmed at this time.

Enjoy ...