• Post Reply Bookmark Topic Watch Topic
  • New Topic

EJB3 improves on EJB2?  RSS feed

 
jim cato
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I've used EJB 2 and not really EJB 3.

I am wondering apart from the use of annotations as metadata to reduce/remove XML configuration, how does EJB 3 address some of the major problems of EJB 2 such as performance and complexity (i.e. specific container required)?

Does EJB3 still advocate the use of a distributed architecture?


What are your thoughts?

Cheers,
Jim
 
arulk pillai
Author
Ranch Hand
Posts: 3404
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
EJB 3.0 is taking ease of development very seriously and has adjusted its model to offer the POJO (Plain Old Java Object) persistence and the new O/R mapping model inspired by and based on Hibernate (a less intrusive model). In EJB 3.0, all kinds of enterprise beans are just POJOs. EJB 3.0 extensively uses Java annotations, which replace excessive XML based configuration files and eliminate the need for rigid component model used in EJB 1.x, 2.x. Annotations can be used to define a bean�s business interface, O/R mapping information, resource references etc. EJB 3.0 also supports XML files for overriding default values and configuring external resources such as database connections.

-- EJB 3.0 defines smart default values. For example by default all generated interfaces are local, but the @Remote annotation can be used to indicate that a remote interface should be generated.


-- In EJB 1.x, 2.x the container manages the behavior and internal state of the bean instances at runtime. All the EJB 1.x, 2.x beans must adhere to a rigid specification. In EJB 3.0, all container services can be configured and delivered to any POJO in the application via annotations. You can build complex object structures with POJOs. Java objects can inherit from each other. EJB 3.0 components are only coupled via their published business interfaces hence the implementation classes can be changed without affecting rest of the application. This makes the application more robust, easier to test, more portable and makes it easier to build loosely coupled business components in POJO.


-- EJB 3.0 unlike EJB 1.x, 2.x does not have a home interface. The bean class may or may not implement a business interface. If the bean class does not implement any business interface, a business interface will be generated using the public methods. If only certain methods should be exposed in the business interface, all of those methods can be marked with @BusinessMethod annotation.


-- In EJB 3.0, you can extend the container services by writing your own interceptors using the @AroundInvoke annotation. You can specify any bean method as the interceptor method that will execute before and after any other bean method runs.


There are lot more differences.
[ September 03, 2008: Message edited by: arulk pillai ]
 
Scott Selikoff
author
Bartender
Posts: 4081
21
Eclipse IDE Flex Google Web Toolkit
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's a lot about code mainability. EJB2 code is difficult to work with in large teams and can make making even small modifications extremely time consuming and error pone. EJB3 on the other hand gets rid of a lot of excess code management issues. For example, it gets rid of the EJB deployment descriptor for entity beans all together.
 
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Posts: 4968
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
EJB 3 is a massive leap forward. If EJB3 was only about the introduction of JPA, and the disposal of CMPs and BMPs, well, it'd be a great improvement, but it's much more than that!

I'm really enjoying working with it. And yes, it is still a distributed architecture. EJBs can still have remote interfaces that distributed clients can invoke.

-Cameron McKenzie
 
aleem khan
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1 year back i started preparing for EJB2.0 and after 3 months i left as HeadFirst Java for EJB2.0 is little complicated... it was difficult to learn and i never thought that i will learn EJB in future as it was totally different concepts...now again i have started EJB 3.0 and it is so easy and just like POJO , i am enjoying it and feel like i will definetely clear SCBCD
 
jim cato
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, that's very interesting. I reckon the spec definately deserves a read

I would say that most of the points made refer to the simpler use of EJB 3 as opposed to previous versions. Presumably, while very useful and important in making the technology viable, this will encourage its use further. If the underlying problems of earlier versions remain: poor performance; no scalability advantage; difficulty to test; will this not cause a re-proliferation of poor applications, i.e. is the fundamental EJB component model flawed?

Sorry, don't mean to sound so negative so early in the morning

Jim
[ September 04, 2008: Message edited by: jim cato ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!