Thursday, July 21, 2005

JBoss - Bad Vibes

JBoss Inc continues to destroy their own trademark.

I guess Mr Fleury and Mr Burke got tired of bashing BEA and IBM and instead decided to go after one of the Open Source projects that is stealing some of the spotlight from the almighty 'JBoss Monolithic AppServer' (insert compulsory reference to 'One ring to rule them all...' etc..) - Spring.

I wonder if this is what's called "Professional Open Source"?

Read Logemann's summary here.

Thursday, July 14, 2005

Default log4j configuration?

Something that really annoys me is how log4j behaves when there's no "log4j.properties" or "log4j.xml" in the classpath.

Instead of printing out my log statements to System.out I simply get:
log4j:WARN No appenders could be found for logger (com.foo.Bar).
log4j:WARN Please initialize the log4j system properly.
Wouldn't it be nice if log4j could provide a default configuration instead?

When discovering that there is no user-provided configuration, log4j would use a "fall-back" configuration instead (say, "default-log4j.properties" from the log4j.jar file). The content of such a file would be something really simple such as:

log4j.rootLogger=DEBUG, Console
log4j.appender.Console=org.apache.log4j.ConsoleAppender
log4j.appender.Console.layout=org.apache.log4j.PatternLayout
log4j.appender.Console.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n


Update: There's a version 1.3 of log4j that's supposed to be released at some point. Does anyone know if this feature (or something similar) will be included in that release?

Tuesday, May 11, 2004

Working with Dates and stuff

Java is known for its lousy date handling classes java.util.Date and java.util.Calendar. Working with, comparing and displaying dates is, simply put, a bitch.

A more manageable solution might be to store date information (in the database) using a plain long, and use a decorator class to access this information:


public class Time implements java.io.Serializable, Comparable {
private long internalTime = 0L;
public Time(long timestamp){
internalType = timestamp;
}
public long getValue(){
return internalType;
}
public static Time valueOf(java.util.Date date){
return new Time(date.getTime());
}
public java.util.Date toDate(){
return new java.util.Date(internalTime);
}
public int compareTo(Object another){
if(another instanceof Time){
return this.internalTime - ((Time)another).internalTime;
}
else { throw new ClassCastException(another+" is not an instance of "+getClass().getName()); }
}
}


A Time-class can also be constructed to represent a special interval such as Day, Month or the dreaded Week (there are actually two week "1" in most Calendar years... which is just plain stupid).

Testing posting through the API

This post is written in VIM and uploaded using the BloggerAPI from a Ruby XML-RPC client.

Coolt indeed!


Monday, May 10, 2004

First wobbly steps into BlogLand

Yupp, I suppose it's time to take a stand and publish all that shit I'm currently pestering my friends and co-workers with...

Don't expect to see daily updates though - I'm still trying to structure the way I'd like to do this.

This page is powered by Blogger. Isn't yours?