August 17, 2009

Java EE is just Java

I write Java EE applications for about some years. During those years I learn some things and give some cents to others. But most productive things which were happen were the discussions on that topic. When you talk with somebody on a subject where both have some knowledge, you find usually nice points of view. Also I noticed that in the same the same time, the same problems are bypassed.

A lot of discussions on this subject happens having in mind that Java Enterprise applications are applications made from distributed components. That's true. Java Enterprise applications some standard services provided by EJB and web container. That is also true. Java Enterprise are build only from EJB layers ( entity beans - now JPA, session beans, message beans, etc) and presentation layers. That is not true. There is something missing here. Java Enterprise applications are still Java applications. What is the meaning of this note? The fact that Java Enterprise applications are still Java applications is an aspect which is often forgotten or simply not took into consideration. When you build a Java Enterprise application you don't loose the possibility to do the same things as you would do in a normal Java application.

When you debug a Java Enterprise application, as a matter of fact you debug a Java application. The debugging feature is something which happen on the virtual machine and class loader level (more on that on a future article). You debug in the same way a Java EE application as you would do with a desktop application, even local or remote, even through shared memory or TCP port.

You can have static or singletons or factories as would you have with normal Java application. I remember a discussion on a forum when somebody put the following problem. Every client is represented by a stateful session bean. How you would implement a communication between those clients? A saw a lot of responses, more that 15 on that topic. All of them stating more or less that you cannot avoid to use persistence layer to store information to be used by different clients. Nobody thought at a simple solution. A singleton which would hold information send by every client and requested by others (was a IM problem). Don't say that the singleton is the best solution. I state only that developing Java EE solutions sometime makes you think that the only things that you can do are EJB components. That's not true. You can however do everything you want.

The only differences between a Java application and a Java Enterprise are:

  • The Java Enterprise application is loaded and started by a special piece of code called container (EJB/web), the normal Java application does not need to be started by something else, could have it's own main entry point
  • Java Enterprise applications are packaged in a specific way to achieve the third difference, while normal Java applications don't have this constraint
  • Java Enterprise applications can use services provided by EJB and web container, while normal Java applications can't (only if you you an embedded environment)

An that's all. In every other aspect these applications are the same: Java applications.

No comments:

Post a Comment