Friday, November 6, 2009

Movies With Friendship Meaning

A bit 'of ... Guice and EJB3, very exotic! - Part 1

But in the end. It is now a bit 'that development in the field of web applications and java in the world of work I see the same old naivete: the use of very old framework (pre-ajax!) and many, but many "professionals" in the field who shoot without even a scratch on technologies know them.

Now I am a bit 'tired and I started this blog to discuss a bit' of technologies that I decided to use in my latest work.

I am working on a web project that involves the use of various J2EE components. Ok lets start.

Given the choice I chose to use the technologies to structure the project using the latest web framework. Why '?

1) I want a project that has the best design of the code.
2) I want a project that is easy to test
3) I want a project that is easy to extend
4) I want to realize a project that is easy to change
5) I want to make a project that ensures better maintainability 'possible
that projects in this vast and' a huge problem to consider.
6) I also want to make a project that is as' powerful and scalable as possible.

and last but not least ... passion for personal use of the latest technologies on the market! um seems to me a great respect. :)

(the list above and 'tidy but you can read random access, I resisted the temptation to confuse the issues)

I considered that the development environment and JBoss' scalable (and easily clustering) and the following libraries:

GWT and 'without doubt the best java framework which is being released in recent years as a strength and' chance 'to compile Java code directly in JavaScript code in a portable among different browsers on the market. Allows you to program the View as a web application if programmed a desktop application with Swing. After years spent on JSF and quarreled with designers, I can not help it to GWT.

MVP4G-GWT and GWT-Presenter
are two extensions of GWT to implement the Model-View-Presenter on GWT. I often worked with the MVC pattern also use the implementation of lightwave GWT-Ext but the MVP model and 'much more' adaptable to the logic GWT.

GWT-Dispatch other useful library that allows me to use one and only one servlet! The communication model on the server and 'Remote Procedure Call using GWT smooth but you have to write a servlet to call remote. Following the indications of Google ... command pattern.

To implement the business logic I wanted to map the POJO that make up the Domain Model using Hibernate and EJB3 Entity Bean. This approach and 'very fast and functional because' using Hibernate allows you to automatically map the logical model to my items directly on the logical model of the relational database, the database used in a transparent way! How wonderful!

The choice of business logic and 'fall on EJB3 session beans (stateful and stateless). The EJB3 are very interesting as a technology, and above all 'easy to control inputs remotely via RMI (which as he says, and' a lot more technology ' webservices fast ...).

I encountered a problem. It 's not possible to inject through Dependency Iniection managed components such as EJB3 components inside not managed as a POJO.

And how did this for me would be a problem? Simple! when I use a type of pattern or strategy for my RPC command, no longer uses' a servlet for remote call to me but a Pojo implements the handler of the call. So I find myself in difficulty 'of having to inject EJB3 components inside managed. And the standard annotation for Dependency Iniection "@ EJB" not permit it!

We circumvent limitation. I found myself making choices that were:

1) Use patterns and old fashion BusinessDelegate ServiceLocator pattern?
2) Use an extension of Spring to make the DI of EJB3?
3) Use a totally new approach ... chess' Guice? :-)

The first option seems to be discarded. I worked with Business Delegate and Service Locator pattern and inspire me just a little.
The second option sounds interesting but ... there is' a but. Spring is uncomfortable with the EJB3, the are just unpleasant. In particular, I found this: # ref it is possible to specify in the configuration of spring we are going to inject components jee. But the reflexive invocation of the objects in question introduces an overhead.
The third possibility 'of using Guice, and' the most interesting. but we leave in an orderly fashion.

What ' Guice?

Guice and 'a library provided by Google (again her!) To create and inject the object graph. And it 'code-configured. That is no longer 'cursed XML file that just can not stand (and you're asking me why I like jboss ..).
but the beauty of Guice and 'that allows you to configure, create and inject through of entire object graphs, indicating the desired goal, much Simple!

For example:

I have my own class that extends my class B, from which I want to instantiate an object through OF.

Nothing more 'simple!

 bind (B.class). To (A.class). In (Singleton.class) 

and to inject?

 @ A Iniect myObj; 

that's it! how wonderful!

I'll talk 'more' extensively Guice and how to use EJB3 with in the next post.

0 comments:

Post a Comment