ThreadLocal is your friend
Thursday 22 December 2005 @ 12:48 pm
Filed under:

Some years ago I found out about this class being very usefull in your application. You never used a ThreadLocal? I’ll explain the concept and provide some examples.
So what’s the difference between a thread-local variable and a normal variable? When a thread accesses a thread-local variable it has its own independently initialized copy of the variable. Each thread holds an implicit reference to its copy as long as the thread is alive. So when the thread goes away, all of its thread-local instances are subject to gc.
You typically use an anonymous inner class to provide an initial value (if any) using an appropriate constructor and return the newly constructed object.

You can use this ThreadLocal in several situations:

To keep state with a thread (user-id, transaction-id, logging-id)
Log4j uses this for the NDC (Nested Diagnostic Contexts) feature, you surely need this if you ever want to be able to debug a heavily used production application (some more info here).
My current project uses ThreadLocals to trace incoming and outgoing messages (XML via JMS). When we receive a message we put a pseudorandom 44-bit number into the thread-local variable. Important events (exceptions, any outgoing messages, result of processing) are logged with the value of the thread-local variable. This way we correlate events in the main log of the application.

To cache objects which you need frequently
Another way of using a ThreadLocal is for performance optimalization. You can imagine that there are certain objects which are relatively expensive to initialize, but are not threadsafe. Examples of these objects are XML DocumentBuilders (with XSD validation), and SimpleDateFormat (needs a Calendar instance).
When you put the SimpleDateFormat in a thread-local variable, you don’t have to create a local one for every format operation you need to do (we need them quite often), but still are safe with concurrent processing. Implement this as:

public class DateUtil {
   private static final ThreadLocal datetimeFormatter = new ThreadLocal() {
      protected Object initialValue() {
         return new SimpleDateFormat("yyyyMMdd HHmm");
   public static String toDateTime(Date d) {
      SimpleDateFormat sdf = (SimpleDateFormat) datetimeFormatter.get();
      return sdf.format(d);

Watch out
Be careful, do not use thread-local variables as instance variables. Although it is not explicitly stated as such in the SDK API docs, they will cause problems when you don’t use them as static variables. Note that this is still an issue in 1.5.

For you J2EE-addicted, these objects can also be held as instance variable in a SLSB (because they’re accessed by one thread at a time), but I tell you, there are still situations you don’t want to create a Enterprise Bean ;-)

— By Klaas van der Ploeg   Comments (4)   PermaLink
A refreshing and emerging 2005
Wednesday 21 December 2005 @ 2:28 pm
Filed under:

The year has almost come to an end so it’s time to look back. In general I have to say, 2005 was a surprising year. Surprising as refreshing. Surprising as emerging. Finally the tendency, already started in 2004, to make (enterprise/web) development more straight forward has been evolved into mainstream body of thought. Some (won’t mention names, won’t call them dropouts, won’t call them visionaries either but I encourage their way of thinking) have turned this evolution rather drastic into a revolution and the idea to leave java behind our back is alive and kicking. And the good, surprising, emerging and fresh aspect of this situation is the java world finally has opened their eyes and room is created for new approaches.

Most promising framework on the move: Wicket
Component oriented web development with a twist. And a very nice twist! Over the years I have played with several frameworks that applied the Swing approach in web applications. And somehow all those frameworks did not fit. Mostly because when doing web development, fine grained control over rendering is a must. And wicket is one of the first frameworks doing rendering web look and feel the right way (by plain HTML!). Yep, Tapestry and XMLC are build around the same paradigm but the first has a way to steep learning curve (assuming your axis are layed out correctly) and XMLC is not an application framework but a presentation engine. Wicket is just wicket! And that is exactly its power.

Most over-hyped but o so beloved abbreviation: AJAX
It’s a combination of old technologies that brought something new to the web: RIA, another abbreviation: rich internet applications. Sometimes I wonder what is wrong with the desktop? Why on earth do we need a hyper text markup language rendering engine to give an application a decent look and feel? Your browser has been designed to bring you information, not to interact with you. Okay, admit, browser based applications are handy. Wherever you are, you can access them. Actually, when writing this text, I use an application that has been delivered to me through a browser. And I can not ignore the fact this really is handy! But I doubt the combination of XML, Javascript and asynchronous calls from client to server are the most ideal solution to pimp a web application. Nevertheless, AJAX is here (And in combination with for example Wicket a nice way to decorate your app) and why not use it while waiting for technology that will enable even more richness to the client.

Most eye-opening technology: DB4O
DB4O rocks! Object oriented databases have always been a bit clumsy. Either the way they interacted with a programming language (JDO for example) or the way they are installed, setup and configured (Ozone for example) never felt comfortable. DB4O takes a fresh approach: It’s embedded in the language and you can embed it into your application. Code needed to persist and re-retrieve your objects never has been that simple (I’ve been flabbergasted by their native queries: just write actual, no criterium api alike, java code to express a query). Forget ORM but go OO the right way!

And finally the music album that has boosted my java performance: LCD Sound system
Java development is not efficient. It’s not handy. There is a lot of overhead. It is complicated. It is cumbersome. It is redundant. It is everything you can imagine to slow you down. But happily there are frameworks, tools, code generators, model transformers and whatever to speed you up. But what really speeds up my personal productivity is some groovy music that fills the room.

By the way, Echo2 is also a nice Ajax based, component orient web framework like Wicket, but it misses the fine control (or at least, it is not implemented in a natural way).

Another by the way: SOA is also a pretty over-hyped (and by some beloved) abbreviation but I’m sure it will die like any other enterprise buzz for the sole reason money can only be made by new buzzwords and in 2007 SOA is so 2005!

and some more music that made java programming a party: Bloc Party, Death from above 79, Kaiser Chiefs, Art Brut, Nine inch nails, Brazilian Girls, The ponys and Patrick Wolf


— By Okke van 't Verlaat   Comments (1)   PermaLink
Safari Bookshelf
Wednesday 21 December 2005 @ 11:06 am
Filed under:

Last couple of months I’ve been using this online bookshelf from Safari.

With this service you can search across, read, browse through 3500+ technical books. I should note that they have all the recent titles, be it on Java, OO, WebServices, .NOT etc. I’m using this service on a personal account (about € 10,- per month) and I am very pleased with it. (Though I wouldn’t mind if my boss would pay for it, as it is of both personal and professional value)
On a yearly basis this amounts to +/- € 120,- which is the price of 3 books. For this I have a virtual bookshelf with 5 slots. Some books take 2 slots, most take 1. Once you place a book on this shelf, you have to keep it there for at least a month. After that you can swap it for another one. This seems like a long time, but I usually don’t read more than 5 technical books a month :)

Most books I read, are read and put aside. There are ofcource some books I like to keep as a reference guide. For those this is a perfect place to make a decision before buying. They also offer a nice discount when you buy books online through their site.

I think it can also be very valuable at a corporate level. Think of study material, training, research, etc.

I know I would like to have an unlimited version of this service at my immediate disposal :-)

for some other reviews have a look at this or this page (or google for safari review).

Actually, I can’t believe that some of you aren’t also using this…
I would like to know if some of you are using this and if so, what you think of it.
If not, why not give it a try.

— By Ruben Sprangemeijer   Comments (2)   PermaLink
First tries within JDeveloper 10.1.3 and ADF
Tuesday 20 December 2005 @ 4:35 pm
Filed under:

Just having ‘fun’ today exploring the new framework Oracle has launched a little time back. For some time Oracle JDeveloper 10.1.3 EA (Early Access) has been available. It boasts the new stack of technology for Oracle. The technology stack (for us) consist of:

  • Business Components (ADF BC)
  • JSR-227 (The binding layer)
  • ADF Faces (Oracle’s JSD implementation

Nice to play with but it is giving me quick some headaches. JSF is quite different from Struts as we used previously and JSF resembles ADF UIX (Oracles view layer in JDeveloper 10.1.2) but works very differently.

As i’m just randomly rambling on now i’ll let you share my experiences and big bone-headed blunders.

First of all… The development environment has been revamped. I quite like it, but i’m kind of partial to JDeveloper (oppossed to some co-workers). Refactoring has been extended quite a bit and they included the one feature i liked from Eclipse: double clicking on a title expands that window…

Secondly i started lookign at Business Components, not much new here, anybody that has worked with ADF BC in 10.1.2 should have no problem jumping in here.

Now the changes started: JSF! or in other words: ADF Faces… Completely back to the drawing board for me. Everything works a little different. A button on a page can call a method, back where does that method go? For my own purposes i made a mental mapping between the Struts Action and the JSF backing bean. All the code for the page goes in there. Just double click on the button and a method will be made for you (reminded me of those visual basic editors ;-) ). Now the problems started: i wanted to get at my data… but where was it stored? UIX gave you a nice event context from with you could get everything. The event context of JSF contains about nothing… However the OTN Forums helped me along. You need to leverage the strengths of JSF to get a connection to the bindings layer. You need to create a managed property in your managed JSF bean that is filled with #{bindings}. A presto the magic happens.

So far so good… we have a working data layer (ADF BC) and a ready to go binding layer (using JSR-227) to go and build our application.

I’ll keep you informed.

— By Robert Willems of Brilman   Comments (1)   PermaLink
Recap of the NLJUD 2005
Tuesday 20 December 2005 @ 3:30 pm
Filed under:

Within LogicaCMG we organize an event called the NLJUD. A strange acronym for something called “Nederlandse Java Update Dag”. The guy or girl who invented this aconym is yet to be found and propably hiding somewhere. If I had made up such an awfull acronym I propably would do the same thing. But nevertheless :)

The NLJUD is an internal event where people from within LogicaCMG have the opportunity to express their idea’s and knowledge. It is a perfect way to get in touch with Java enthousiast from within the entire LogicaCMG company.

During the event a spy from our Microsoft competence was spotted. He was taking pictures from people attending the event! We apprehended the spy and confiscated the contents of his digital camera. If you want to take a look at the contents please follow the link below :)

I will update this post with presentation material as I receive this from the speakers!

See you all next year during the next NLJUD! Or maybe someone can come up with a nicer acronym :)

— By Marco Pas   Comments (0)   PermaLink
Results of the JavaPolis Rad Race
Thursday 15 December 2005 @ 12:23 pm
Filed under:

JavaPolisI am happy to announce that two of my fellow employees (from LogicaCMG) have entered and won the Rad Race at the JavaPolis. Congratulations go towards Pascal Alma and Pascal Prins who entered the contest with a toolbox filled with Oracle goodies. (Oracle JDeveloper, JHeadstart and ADF etc)

It is fair enough to mention that there are 2 other teams that have received the 1st price so congratulations also to the teams from Axi and Oracle.

It is interesting to see that 2 out of 3 winners have made it with the use of a Oracle product stack. Is this coincedence?

More details can be found on the website of JavaPolis.

— By Marco Pas   Comments (3)   PermaLink
Choosing a development database
Thursday 15 December 2005 @ 9:09 am
Filed under:

OracleWhile installing MySQL for development purposes I remembered an announcement from Oracle in which they introduced Oracle Database 10g Express Edition (aka Oracle XE). According to the announcement and the Oracle website, XE is an entry-level database based on the code base of it’s big brother (or sister) that is free to develop, deploy, and distribute.

It is a great database for:

  • Developers working on PHP, Java, .NET, and Open Source applications (it looks that I am the target audience :) )..
  • …etc..

According to the Oracle website it should be easy to install and administer! While MySQL is a wonderfull database, easy to install and maintain, good tooling support etc, I still decided to take the plunge into the scary world called Oracle!

The download of 150 MB was ready and after 5 minutes I got my database up and running. Is this all I wondered! Yep indeed this was all. I switched a Java project to use the Oracle XE database and everything went smoothly from then onwards.

I must admit Oracle XE has it all in one download from database to administration. So am I going to use XE from now on :? ? Could be! It sure has made a very good impression on me. So thumbs up for Oracle. They released a fine database but that is something I should have been expecting.

And by the way.. talking to Oracle guys is not so scary after all :)

— By Marco Pas   Comments (10)   PermaLink
Is BEA preparing for something totally else?
Wednesday 14 December 2005 @ 8:21 pm
Filed under:

During a session at the JavaPolis, hosted by Sun and BEA, a few carefully placed sentences attracted my attention. The Vice President/General Manager of the BEA Workshop Business Unit aka Bill Roth mentioned that 75% of preparing WebLogic is put into the effort of making WebLogic scalable, extensible etc. So why not open up WebLogic for other upcoming languages!

The ability to deploy applications implemented in PHP/Ruby or even .Net onto the WebLogic application server could open a whole other revenue stream for companies like BEA. These companies have already put a lot of effort into the application server space but are feeling the heat of competitors like the Apache Foundation and JBoss.

Opening up WebLogic to other languages would be a logical step into the evolution of WebLogic!

— By Marco Pas   Comments (9)   PermaLink
Are we proud of our own invented complexity?
Wednesday 14 December 2005 @ 8:03 pm
Filed under:

Java is fun, Java is nice but most of all Java can be damn complex! This is something that hit me when visiting several sessions during the JavaPolis. A creepy feeling got hold of me when watching some ego’s fighting over the question “what is the best framework to use!”. People started talking about Spring, Seam, Rife and every framework you can think off. Offcourse frameworks are invented for some reason, but why is the Java community not able to settle and choose 1 standard framework?

Creativity is something that must be encouraged and nurtured but sometimes it is nice to share the same idea and head towards one direction.

One question stays on my mind:
Are we as Java developers taking pride of our own invented complexity?

— By Marco Pas   Comments (5)   PermaLink
Some JavaPolis figures…
Wednesday 14 December 2005 @ 7:54 pm
Filed under:

Also visiting the JavaPolis? If not, you are missing one nice event! After being plunged into Java technology for the last three days and two more to come. I already can say that the JavaPolis is worth every penny. The things I like most about this event are very the informal atmosphere and speaker quality!

Some figures:

  • 2100+ visitors and 150+ speakers (50% increase with respect to last year)
  • 11.500 registered users on the JavaPolis wiki
  • visitors from 43 countries

There will be another JavaPolis event next year so make sure you will be there.. :)

— By Marco Pas   Comments (3)   PermaLink
Next Page »


Sha256 mining

Blog Categories

Browse by Date
December 2005

Upcoming Events

Monthly Archives

Recent Comments


XML Feeds Option

Get Firefox  Powered by WordPress

code validations
Valid RSS 2.0  Valid Atom 0.3
Valid W3C XHTML 1.0  Valid W3C CSS