Injection with CDI (Part III)

If you follow this blog you should know that latelly I've been writing (and talking) about CDI (Contexts and Dependency Injection). CDI has many aspects to it but until now I've focused on how to boostrap CDI in several environments, how to add CDI to an existing Java EE 6 application,  and more recently how to use injection with CDI. Actually this post is the third on CDI Injection : Part I focused on default injection and qualifiers, and Part II on all the possible injection points (field, constructor and setters). In this post I'll explain producers or "how you can inject anything anywhere in a type safe manner".

Read More →

Walking through the Java EE 6 implementation maze

I've been asked so many times "what are the implementations of such or such specification in Java EE 6 ?" or "what is the reference implementation of such a spec ?". Because I always forget some (and to be honest, sometimes I don't even know if a spec has several implementations of not), I'm writing this post to help me (and you) to remember.

So here is a non-exhaustive list of the several Java EE 6 implementations (please leave a comment to add anything to this list) ...

Read More →

[Debate] – And what about configuration in Java EE 7 ?

How do you configure your enterprise application ? Or to be more precise "what is configuration, what can you configure in Java EE and how can you configure it ?"

What is configuration ?

Sometimes your application needs to change parts of its behavior at deployment time. You then need to provide some external configuration for some components. For example, in your development environment you don't want to use a datasource and instead hit the database with a user & password, in your test environment you lookup for the datasource and use it. If you deploy your application in Europe you need to use the Euro as the current currency and if you deploy it in the US you need dollars...

Read More →

To inject or not to inject: CDI is the question

Two weeks ago I did a little tour around several JUGs and conferences to talk about dependency injections with CDI. The final goal of this road movie was to end up at GeeCon in Krakow. It was my second time at GeeCon and I have to say that this conference is like good wine : getting better with age. This community based conference is on its third edition and attracts people through out central and eastern Europe. Plenty of good speakers, nice location, skilled attendees... and a lot of fun (GeeCon organizers are party addicts). So make sure you mark this conference into your agenda for next year....

Read More →

Injection with CDI (Part II)

This is the second post based on pure CDI Injection (see Part I) after having talked about how to bootstrap CDI in several environments and how to add CDI to an existing Java EE 6 application. In this post I quickly want to show the different injection points in CDI : field, constructor and setter. To illustrate these different injection points I'll use a subset of the previous example : a servlet injecting an ISBN generator POJO ...

Read More →

A week in central Europe… with CDI

I haven't talked much lately at conferences or JUGs. The last one was Devoxx in November 2010 and I have been quite ever since (working on some other plans ;o) But it's time to do a bit of touring again. This time it will be Central Europe and the topic with injection in CDI. The presentation of the talk is To inject or not to inject: CDI is the question and the description roughly is :

After a quick introduction of CDI (Contexts and Dependency Injection) I will concentrate on dependency injection and the type-safe approach on injection in CDI. If you are fed up of using String based configuration, come to this talk and have a type-safe journey on CDI.

How come I am touring again ? Everything started with an invitation from my friends at GeeCon. I discovered GeeCon in 2009. It was the first edition of this conference in Cracow (Poland) created by the local user group.

Read More →

Injection with CDI (Part I)

After writing a post about how to bootstrap CDI in your environment and giving you some tips about how to incorporate CDI in an existing Java EE 6 application, I want to talk about injection. Yes, pure injection or how to inject a bean into another one. As you'll see in this series of three articles (Part II), many different cases can happen. Let's start with a simple one : a straight forward injection.

Default injection

The simplest possible injection case is... simple. You have something, and you inject something into it. Why am I using the word something ? Because until Java EE 5 we could only inject resources (EntityManager, Datasource, JMS destinations and factories...) into certain components (EJBs and Servlets). With CDI, you can inject nearly anything into anything else.

Read More →

Java EE 7 – I have a (few) dream(s)

If you haven't used your RSS feed reader lately, you might have missed that Java EE 7 is starting to kick off : JPA 2.1 (JSR 338) and JAX-RS 2.0 (JSR 339) have been voted, Robert Chinnici has talked about it, some conferences have mentioned it... Java EE 7 will happen and quite quickly (Q4 2012). The main focus is the cloud. I will not talk here about the cloud, I'll talk about everything else (well, not everything ;o)

Java EE 7 is an umbrella specification, meaning it's made of several specifications. Its goal is to give the other JSRs a common target (here, the cloud) and to make sure these specifications interact well with each other. The Java EE 7 expert group is not responsible for all the JSRs, just the umbrella. That means if the Java EE 7 expert group wants to add something new to the platform (eg. it would be nice to have batch processing into the platform) it will not do it : it will rely on some other spec (i.e. someone else) to specify it and to interact well with the other specs.

Read More →

Adding CDI to an existing Java EE 6 application

In my previous post I've shown you how to bootstrap CDI in several environments (GlassFish, Tomcat, Jetty, Java SE). So now let's go a bit further and use it in real code. As its name states, CDI (Contexts and Dependency Injection) is also about Dependency Injection, so let's focus on just this feature for now. I will not define what DI (Dependency Injection) is. If you don't know I'll leave you to check the definition, the origins of this pattern and even a book that covers it all.

Read More →

Bootstrapping CDI in several environments

I feel like writing some posts about CDI (Contexts and Dependency Injection). So this is the first one of a series of x posts (0<x<10). I will not go through the entire history of CDI (formerly called Web Beans, splitted in two JSRs... and so on), but will try to give you information on how to use it in different environments, explain you injection, context management, scoping, decorators and so on. So you can think of this series of posts as a humble step by step CDI tutorial. You can also read the very good documentation on the JBoss website (where I got some help and inspiration).

Read More →

Séance de dédicace groupée

Vous l'avez certainement lu dans tous les magasines, la rentrée littéraire 2010 ce n'est ni Michel Houellebecq ni Amélie Nothomb, mais bel et bien la seconde édition de Java EE 6 (aux éditions Apress). Pour fêter cet évènement inter galactique, je m'associe à Emmanuel Bernard (Hibernate Search in Action aux éditions Manning) et Arnaud Héritier (Maven aux éditions Pearson) pour une séance de dédicace groupée à la librairie Le Monde en Tique. Vous aurez ainsi l'honneur et le privilège de rencontrer vos idoles, d'acheter leur superbe ouvrage, de vous les faire dédicacer, de boire un verre et de papoter de tout et de rien.

Read More →

I don’t know anything about Silverlight nor .Net

I haven't blogged for quite a long time. That's not because I am lazy (well, I took 4 weeks of holidays) or I have nothing to say (titles you could have read in this blog "the rise of Java EE 6", "the lightweight container strikes back", "in EJB we trust" or "god save CDI"). No, I was busy finishing the second edition of Beginning Java EE 6 with GlassFish v3.

This second edition has many updates. I've updated all the tools of course (GlassFish 3.0.1, Derby 10.6, JDK 1.6.0_20...) but also added extra sections (on JPA, EJB, JSF & JAX-RS) as well as taking into account readers' feedback. I would like to thank everybody who read the first edition and sent me feedback on Get Satisfaction. That allowed me to correct some mistakes or clarify some concepts. If you get the book, remember to download the code of the examples from Kenai. I've also updated lots of code, improved javadoc and added some readme.txt files.

Read More →

Java EE 6 ? Excuse my French !

It's been a long time since I haven't blogged about what I am doing on evenings and week-ends. For people who think that I watch TV and have BBQs on Saturdays, I have to tell you that I don't have any TV (it's been over 20 years now) and I don't have a garden to cook my burgers. No, I've spent my spare time updating my Java EE 6 book.

In this second edition I have updated the content and added new sections. When the first version of the book got out it was in June 2009 and Java EE 6 hadn't been released yet (December 2009). So there were some topics that I didn't cover because they were not completely finished (like the Criteria API in JPA 2.0). I've also updated the frameworks (GlassFish 3.0.1) and the code so it's more accurate. The book is planned to be published in September 2010. As always there is a full list of people I need to thank for this second edition. Writing or updating a book is hard work and comfort is always needed.

Read More →

Bean Validation with JPA 1.0

For those of you who still don’t know Bean Validation, you should check the JSR 303 and the documentation of the reference implementation Hibernate Validator. In fact, like many other JSRs, Hibernate Validator existed on its own for quite a long time as an open source project (until version 3.1.x) and then got specified under the JSR 303 and became the reference implementation from its version 4.x. Bean Validation 1.0 was born and is now part of Java EE 6. But keep in mind that Bean Validation doesn’t need Java EE 6 to run (like other specs such as JPA 2.0, JSF 2.0, CDI 1.0…) and can be used outside any container. So, what is it for ? Well, the short answer is to validate your POJOs. Imagine that you have a Book POJO and you want to check that the title of the book is not null and the author’s name is greater than 5 caracters and shorter than 20. Where do you validate these simple business rules ? In which later ? Different schools exist. In the Anemic Domain Model school, your model doesn’t have any intelligence and the validation should be done outside (typically in a service layer). In the Rich Object Model school, the object should validate itself and is the best place to encapsulate its own business logic. Bean Validation is part of the second school. So, how do you add validation constraints to your POJO […]

Read More →

O Application Servers, Where Art Thou?

With Java EE 6 and GlassFish v3 out, it is time to take a little break and look at the application server world. J2EE 1.2 was created in 1999, that’s 10 years ago. The application server market at the time was completely different of the one today. There was Weblogic and Websphere, other proprietary application servers (not following J2EE) and no open source application server. Today, it is a completely different story. The application servers’ world has changed so much in the last 10 years, but people still have in mind the heavyweight server that takes huge amount of RAM, disk space and takes ages to start (being completely useless for agile developers who need to test and code quickly and often). So let’s focus on some application servers  (Geronimo, GlassFish, JBoss, Jetty, JOnAS, Resin, Tomcat, Weblogic and Webspere) and check some parameters. The benchmark Disclaimer :This is not a real benchmark ! In this little test I’m just concerned about the usability of an application server for a developer. The idea is to download it, install it, start it and take some measurements (size of download, ease of installation, size of disk, startup time, size of RAM…). That’s all. No deployment of an application, no fancy twists to gain performance…. Because some of these application servers are resource consuming, I’m doing all my tests on a Windows XP virtual machine (running on Virtual Box 3.1). It is a fresh […]

Read More →

A busy week at Devoxx

If you don’t already know it, next week is Devoxx : the biggest European Java conference. It’s my 4th time there and this year I’ll be doing 2 conferences, 1 BOF and 1 book signing session. Tuesday, from 9:30 to 12:30 : University talk The Java EE 6 Platform.  I’ll be doing a 3 hours talk with Alexis Moussine-Pouchkine with plenty of demos. We will gradually develop a web application using most of the EE specifications (Managed Bean 1.0, JPA 2.0, Servlet 3.0, EJB 3.1, JSF 2.0, Bean Validation 1.0 and JAX-RS 1.1) Tuesday, from 7pm to 8pm : BOF Why Should I Care About Java EE 6 ?. If you’ve attended the university talk or if you just want to talk about Java EE 6, come to this BOF. With Alexis we will be sharing this BOF with Paul Sandoz, Roberto Chinnici, Ludovic Champenois and Emmanuel Bernard. Wednesday, from 3:10 to 4:10 : Conference talk What’s new in Java EE 6 ?. This one hour talk is for people who already know Java EE 5 and want to discover what’s new in EE 6. I’m proud to say that I’ll be talking in room number 8 (the biggest) just after James Gosling. Cool ! Wednesday, from 4:10 to 4:40 : Book signing session. If you want to know more about Java EE 6 and get a copy of your book signed, let’s meet in the ground floor at the […]

Read More →

Java EE 6 is touring French JUGs

One beauty of living in a country with nearly 20 Java User Groups is that you can travel around while talking about your favourite topics. For me, at the moment, it’s Java EE 6 (thanks to my book). So last week I was invited to the Riviera JUG to give a talk about the new features of EE 6. As […]

Read More →

An interview about me, Java EE 6, the JUG, the JCP and some Jazz

A few weeks ago, Alexis Moussine-Pouchkine asked me for an interview. My book has been out for a couple of month now, Java EE 6 is getting hot, GlassFish V3 is closed to final, the Paris JUG is doing well, I’ve recently been nominated Java Champion, JSR 299 and 330 are working hand in hand, the Cast Codeurs podcast is a success, summer and vacations are on their way… it was time to have a break, a nice lunch with Alexis, a few glasses of wine, and have a chat. So if you want to know a little bit more about all that, you can listen to the podcast or/and read the transcription of it. GlassFish Podcast Podcast transcription Thanks Alexis

Read More →

I am a champion, my friends

Yes, I am a Java champion my friends, and I’ll keep on Javaing till the end. Do you know the Java Champion program ? It was created by Sun to recognize leaders in the Java developer community. The concept is to build an informal but select group of passionate Java technology and community people outside of Sun. As quoted in […]

Read More →

Derby is really an in-memory database

Up to Derby, the in-memory database mode wasn’t a real one because data was stored into files onto your disk. The new supports a real in-memory mode were data is only stored in memory, with no files being created. As stated in the new features page : Initial implementation of a storage engine for Derby where all data is kept in memory. There is no documentation for this feature. This functionality itself is not yet fully implemented, but users are welcome to experiment with it. So I did test it. First of all, if you are using Maven, you will be disappointed to know that the release is not in the default Apache repository. You need to add the following repository to your pom.xml : <repository> <id>Apache Repo</id> <name>Apache repository for Derby</name> <url></url> <layout>legacy</layout> </repository> Then, the JDBC URL has to be changed from jdbc:derby:chapter02DB;create=true to jdbc:derby:memory:chapter02DB;create=true. As a little benchmark, I have an application with 25 test cases using in-memory storage with Derby It took 5 minutes and 53 seconds to run all the tests. With the new it only took 21 seconds. Not bad.

Read More →