Search This Blog

2009-12-28

High-Tech

Hello again,

Since I am somehow related to Sweden I travel to this country regularly.
Every time I go there I am astonished by the wide spread technological progress and its common use in every day life. Not only young people are using new technologies, but also grandmas, or grandpas!
To give you some examples.

Number 1: In the supermarket:
At ICA, the largest retail company in the Nordic countries, you can chose between paying your food the normal way (shopping cart, scanning, checkout) OR with a self scanning service. See the following video.



After you chose all of your things you have to go to one of those machines and pay: By the way, I didn't have any problems scanning the goods. And yes, you can cheat, but the Swedes are honest people.




Number 2: Virtual bus ticket (SMS)
If you want to purchase a bus ticket in a city in Sweden, you can send a text message to obtain your virtual ticket. After you receive the message (your ticket) you have to show it to the bus driver.


There's also a nice article about this topic.


Number 3: Facebook usage
Another amazing thing is the fact that in Sweden even grandmas have facebook accounts. They sometimes use facebook to invite their grandchildren for "fika" (the swedish word for coffee break). Unbeliveable! I have problems explaining my dad the difference between SMS, CD, DVD and Email :)

Last but not least, for all the statistics lovers, visit this link
For all the developers out there, the next possibility for a visit to sweden will be on March 16-17, at the Scandinavian Developer Conference 2010. By the way, the Swedes speak English very well, so there are no language barriers not to visit this country :)

Hälsningar/Greetings (from Sweden)
Daniel

2009-12-23

Java EE 6 - CDI (JSR 299) - my first impressions

Hi there!

After taking some time to go through various documents (see link list below) and do some coding samples about the topic CDI, the following things came into my mind:
"lots of annotations", "very abstract specification", "what role will CDI play in JavaEE within the next years?", "can become quite powerful", "I need some best practices".

The specification of CDI (CDI stands for Context and Dependency Injection) with its 92 pages is in my opinion not the right place to start if you want to learn CDI. It is an abstract specification, which shows all the elements a CDI capable container must implement. I really like the specification, but as the code samples didn't really help me (due to missing explanations), I think it is just not the best place to start.
Weld, the reference CDI implementation, offers a great documentation (see link below).
By the way, there are other implementations, too: Resin Candi and Apache Open Web Beans.
If you use Glassfish V3, Weld is included and if you develop using the WebProfile (see earlier post), Weld is even included.

But what is CDi all about? CDI offers..
- an improved lifecycle for stateful objects, bound to well-defined contexts
- a typesafe approach to dependency injection
- object interaction via an event notification facility
- a better approach to binding interceptors to objects, along with a new kind of interceptor, called a decorator, that is more appropriate for use in solving business problems
- an SPI for developing portable extensions to the container.

Gavin King mentioned in the interview:
Originally JSR 299 was called Web Beans, to emphasize its role in making the web technologies of Java EE 6 work better with the transactional access technologies. Originally, one of the key problems we wanted to solve was how can we build an application that uses JSF very easily together with technologies like EJB. So it was originally called Web Beans...It over‑emphasized that this was a web technology, when if you actually look at CDI, it's actually something much more general than that. So after much discussion, the name of the spec ended up being changed to “Context and Dependency Injection."

One of the main buzz words is (Managed) Bean. We have been using beans in Java a lot before. There are Enterprise Java Beans, Message Driven Beans or JSF managed beans. Now, in JavaEE 6 the word bean finally gets a well defined definition.
Managed Beans are defined as container managed objects which support a small set of basic services, such as resource injection, lifecycle callbacks and interceptors
With very few exceptions, almost every concrete Java class (also known as pojo) that has a constructor with no parameters (or a constructor designated with the annotation @Inject) is a bean. This includes every JavaBean and every EJB session bean.

To give you a short impression about what a Managed Bean can look like see my BeyonceBean :)

@Named
@SessionScoped
public class BeyonceBean implements Serializable {

@PrivateMusicLabel
@Inject
private Label label;

@Produces
@Named(value = "singBeyonce")
public String singBeyonce() {
return "Everywhere I am looking now, I am surrounded by your embrace...Halo Halo Halo";
}

public String getInjectedMusicLabelInfo() {
return label.toString();
}
}

If you want to learn CDI you should stick to the Weld Documentation provided by JBoss. There are many well described code samples. Maybe this code sample explains what first came into my mind: " lots of annotations" . I am sure it'll take some time to get used to this way of Java enterprise coding. With CDI you really focus on creating/using lots of annotations, either for type safety reasons, for interceptors or decorators.
UPDATE 01-23-2010
Reza Rahman, a Resin team member, provides some perfect articles for CDI beginners. I really like the way he explains the CDI features. So this link might be a perfect if you are new to CDI.

Another reflection I would like to share with you is my CDI experience with Netbeans 6.8 and Glassfish V3.
- If you don't annotate your Bean with @ManagedBean you don't get the JSF code completion feature. This is very inconvenient. But I am sure the Netbeans developers and community will provide a solution soon.
However, there is actually a more general problem with the @ManagedBeanAnnotation. The article Is @javax.faces.bean.ManagedBean Dead on Arrival?. describes that there are 3 different ways in JavaEE6 of how to define a ManagedBean in the source code: with JSR 316,250/JEE6Spec,AnnotationSpec javax.annotation.ManagedBean, with JSR 314/JSF2Spec javax.faces.bean.ManagedBean and with JSR299/CDISpec javax.inject.Named. So which one should we use? Use the @Named annotation!
- Then I had some problems with the Deploy on Save. When I changed the scope of the bean from request to session, I had to do a clean, otherwise I got a deployment error "Managed bean declaring a passivating scope must be passivation capable" -- which means must implement serializable (even though I added the Serializable interface).
I am going to take a closer look at this and see if there already are some open issues. Otherwise I will submit this problem.

My conclusion:
As I haven't figured out the full capacity of CDI and as it seems to have the power to change the way of writing Java EE applications essentially (or may even become the new JEE6 core programming model), I am very interested in CDI and I will continue reading about it.. As soon as ICEFaces 2.0 will be released I will update my training application from JavaEE5 to EE6 and focus on applying CDI features. As I will have to wait for at least another month I will keep an eye on how CDI is evolving.

Here are the links:
Specification - JCP 299 CDI
Weld documentation - JBOSS about CDI
Gavin King on CDI - tech discussion @ javalobby
CDI capable servers and deployment - see here

UPDATED 01-20-2010:
Java EE 6 Codecamp - Here you can do some CDI homework examples. A great way to learn Java EE.

2009-12-19

Java EE 6 - The WebProfile

Hi guys,

Within the next few weeks/months I will write about the new Java EE6 components.
The first new feature I am focussing on is the so called WebProfile.
The Web Profile is targeted at developers of modern web applications.
Within the last years developing web applications has become more and more important. However, there has also been a large number of technologies for the creation of web applications. All of them had to face similar challenges, like security handling, persitence or transaction handling. The WebProfile aims at defining a basic stack for developing web applications using the Java platform.

The following technologies are required components of the Web Profile:
•Servlet 3.0
•JavaServer Pages (JSP) 2.2
•Expression Language (EL) 2.2
•Debugging Support for Other Languages (JSR-45) 1.0
•Standard Tag Library for JavaServer Pages (JSTL) 1.2
•JavaServer Faces (JSF) 2.0
•Common Annotations for Java Platform (JSR-250) 1.1
•Enterprise JavaBeans (EJB) 3.1 Lite
•Java Transaction API (JTA) 1.1
•Java Persistence API (JPA) 2.0
•Context and Dependency Injection (JSR-299)

The maven repository offers the following jar for the WebProfile
(see maven repository url).
Include it into your pom like this:

<repositories>
<repository>
<id>java.net2</id>
<name>Repository hosting the jee6 artifacts</name>
<url>http://download.java.net/maven/2</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
<version>6.0</version>
<scope>provided</scope>
</dependency>
</dependencies>

If you chose Netbeans 6.8 as your development environment you can create a maven built web project. In the project properties within the run menu you can switch between the different profiles (full and web).

After switching you see the difference in the libraries (the full profile uses the javaee-api-6.0.jar).

The Java EE6 reference implementation Glassfish V3, based on OSGI, allows the dynamic addition of new functionality both from Sun and third parties. Glassfish V3 offers both the Full JavaEE profile and the new WebProfile.
Based on internal Sun benchmarks, Sun GlassFish Enterprise Server v3 startup times are over twice as fast as v2 and in the case of the Web Profile offering, nearly three times faster.
The following glassfish page gives you a perfect overview between what is included in the Web Profile and in the Full Java EE Profile.


I really love the new WebProfile. Not only because of the performance boost, but also because of the simplified packaging (No EAR packaging needed anymore). So if you don't depend on JMS or remote EJBs, the new WebProfile is what you were looking for as a web developer. Give it a try.

2009-12-13

Java EE 6 - The Overview

Hi altogether,

While enjoying my christmas holidays in Sweden I have enough time to look at some of the new features Java EE 6 offers.
Here's the overview:

- JavaTM Platform, Enterprise Edition 6 (Java EE 6) Specification, JSR 316
- Contexts and Dependency Injection for the Java EE Platform (CDI), JSR 299
- Enterprise JavaBeans 3.1 (No Interface, Singelton, asynchronous EJBs vs MDBs, Timer), JSR 318
- Java API for RESTful Web Services (JAX-RS), JSR 311
- JPA 2.0 (Support for Pessimistic Locking), JSR 317
- Dependency Injection for Java, JSR 330:
- Bean Validation, JSR 303
- Servlet 3.0, JSR 315
- JSF 2.0, JSR 314
- new Deployment possibilities
- improved/simplified testing

Right now I am focussing on CDI (JSR 299), which is a pretty big new part in Java EE 6. It'll take some time to summarize. In the meantime, I hope you're enjoying your free days over christmas.

So God Jul, Merry Christmas, Frohe Weihnacht, Feliz navidad, Joyeux Noël! or if you need some more translations...

So JavaEE 6 and Glassfish V3 are ready to rock!

Hi guys,

I want to tell you my first experiences with JavaEE 6 and Glassfish V3.
By the way, I favor Netbeans over Eclipse because of the great JavaEE wizards and maven integration (Netbeans Version 6.8 was released on the same day as Glassfish V3)

The first thing I did was trying to deploy my JavaEE 5 application on glassfish V3. BUT, not as an EAR project, but as a Web Project.
I really like the fact, that you don't necessarily need the EAR packaging. If you put your packaged EJB Content (xxx.jar) into the folder WEB-INF/lib of your WebProject, Glassfish automatically recognizes that your application contains EJBs. The same if have JPA Entities.



One of the biggest benefits I get from using only the WAR file is the great deployment time and the Deploy on Save functionality. There are still problems with Netbeans if you want to use the deploy on save feature with maven built javaEE projects. (Ear, War, EJB), see this post. But with only one war file all the changes you do to your web project will be deployed automatically. You just have to turn on the Deploy on Save within the Projects Properties .



Starting GlassFish V3 and deploying my application on my MacBook Pro takes about 19 seconds:
INFO: GlassFish v3 (74.2) startup time : Felix(3459ms) startup services(15633ms) total(19092ms)
Once started the redeployment due to deploy on save is so fast, i don't event see netbeans redeployment status window in the corner down right. :)
So to make my application be JavaEE 6 compatible I also had to do some changes on the Web Project itself. I had to update the web.xml and I moved the configuration within the faces-config.xml into the beans itself by using the following annotations:
@ManagedBean(name = "Login")
@RequestScoped

But as I use ICEFaces and ICESoft hasn't released the final JSF2.0 compatible version I still have to wait until I can benefit from this great perfomance boost, JavaEE6 will bring. There is a alpha release of ICEFaces V2.0 however, there's too much things to fix if you want to make it work. If you are interested in the latest problems see this post.

So this was just my first impression on JavaEE6 and glassfish. I will tell you more about the new features of JavaEE as soon as ICEFaces 2.0 is released.
Greetings and have a nice day!

2009-12-10

Waiting for JavaEE 6

Hi alltogether,

After the approval of the Java Enterprise Edition 6 (Java EE 6) Specification we are very close to the final release.
Roberto Chinnici writes in his blog that the release date will be december 10, 2009, when Glassfish V3 will be available.
I am really looking forward to these releases. However, as a user of the ICEFaces Framework, I still have to wait until ICEFaces 2.0 is going to be released. ICEFaces 2.0 will be the JSF2.0 compatible version. Right now there's only a alpha version available.

So, if you like to read more about the new features of JavaEE6 and Glassfish V3, check out the following links:
- JavaEE6 @Sun
- GlassFish V3