views:

372

answers:

2

A friend and I are building a fairly complex website based on java. (PHP would have been more obvious but we chose for java because the educational aspect of this project is important to us)

We have already decided to use JSF (with richfaces) for the front end and JPA for the backend and so far we have decided not to use EJB3 for the business layer.

The reason we've decided not to use EJB3 is because - and please correct me if I am wrong - if we use EJB3 we can only run it on a full blown java application server like jboss and if we don't use EJB3 we can still run it on a lightweight server like tomcat. We want to keep speed and cost of our future web server in mind.

So far i've worked on two JEE projects and both used the full stack with

  • web
  • business logic
  • factories/persistence service
  • entities

with every layer a seperate module.

Now here is my question, if you dont use EJB3 in the business logic layer. What does the layer look like? Please tell what is common practice when developing java web projects without ejb3? Do you think business logic layer can be thrown out altogether and have business logic in the backing beans? If you keep the layer, do you have all business methods static? Or do you initialize each business class as needed in the backing beans in every session as needed?

A: 

People that don't use EJB usually use Spring or another dependency injection framework. JSF allows you to create beans and wire them together, however it would be better to use this only for the UI and use Spring for your business layer. A lot of information is available for integrating JSF with Spring.

kgiannakakis
+2  A: 

EJB3 is split into two layers:

  • persistance (JPA, old Entity beans)
  • business logic (old Session beans)

You can have the same architecture, without using explicitely EJB3.

Persistance

JPA is very close to Hibernate. We use, and prefer it to JPA.

The annotations come from JPA, but there is no need for a container, it's not really EJB.

Business

Spring also is very close to the Business layer of EJB3. With many more capabilities...


Some even say they are better than EJB3 !! ;-) They say that EJB3 was created from these two solutions (but still have to reach at their level on many points!).

KLE