Friday, April 29, 2011

Spring Vs EJB Feature Comparison

Which is better Spring or EJB? What is the difference between Spring and EJB? Compare Spring and EJB features.
After releasing Spring Framework, most of the java developer moved from EJB to Spring. After that, EJB 3 is release to fight back with Spring framework by cleaning most of its weak points. EJB is heavy with respect to Spring and lots of component that can be used in option in Spring.
But lots of programmer might want to know the best part of Spring and EJB, lots of developer might be trying to find the main difference between Spring and EJB.
Lets have look in the main difference between Spring and EJB.

Feature EJB Spring
Transaction Management EJB supports transactions that span remote method calls, thsi must use JTA Transaction Manager Spring Framework Supports multiple transaction environments through its PlatformTransactionManager interface, including JTA, Hibernate, JDO, and JDBC.
Declarative Transaction Support In EJB, we can define transactions declaratively through the deployment descriptor, transaction behavior per method or per class by using the wildcard character like *. But its can't declaratively define rollback behavior which must be done programmatically. In Spring Framework ,we can define transactions declaratively through the Spring configuration file or through class metadata, can define which methods to apply transaction behavior explicitly or by using regular expressions, can declaratively define rollback behavior per method and per exception type.
Persistence EJBS upports programmatic bean-managed persistence and declarative container managed persistence. Spring framework provides a framework for integrating with several persistence technologies, including JDBC, Hibernate, JDO, and iBATIS.
Security EJB Supports declarative security through users and roles. The management and implementation of users and roles is container specific. IN EJB, declarative security is configured in the deployment descriptor. Spring Security Framework provide complete security that includes Authentication and Authorization.
Distributed Computing EJB provides container-managed remote method calls. Spring framework provides proxying for remote calls via RMI, JAX-RPC, and web services.
Metadata EJB use annotation for metadata. Spring use xml for metadata.

No comments:

Post a Comment