This is one of the most asked question at this time. The EJB3 specification has incopored interesting concepts and ideas from leading open source projects to make easier to use, remove lines of code and improve the time of application development.
Spring and EJB3 together
I think that these two technologies don't make exactly the same things and it's a great things to use them together.
There are two parts:
- Access EJB with Spring.
- Use Spring in EJB (transaction, components).
Spring philosophy
Spring permit to build well-defined applications both in an application server and outside/without an application server. This framework underlines that you need to use the appropriated technology for your application: do you really need ejb / jta technologies? Is a servlet container enough? Local or global transactions?
It focuses too on best pratices and design patterns to have a flexible, modular, reusable applications.
EJB3 will surely be easier to use but the technology needs too to have best pratices and design patterns...
Finally, before asking using Spring or EJB3, you may wonder which kind of applications, you need to develop. Then you can choose the appropriate technology(ies)!
Spring, not a specification...
Finally, I think the important thing against is that Spring isn't a specification but EJB3 is...
Readings
Made you your opinion with the following readings!!!
Some threads in the Spring forum on this subject:
EJB3
EJB3.0 without Spring :-)
An article on the onjava site on this subject:
POJO Application Frameworks: Spring Vs. EJB 3.0
Some insteresting blog entries on that subject:
The EJB cult Part 3 - Integrating Spring and EJB 3.0 dependency injection
Spring, EJB 3, and the future
A interesting article of Rob Harrop and Jan Machacek on Spring / EJB integration:
Pro Spring: Spring and EJB
The EJB section of the Spring 1.2.x reference documentation:
Accessing and implementing EJBs
Thursday, June 30, 2005
Wednesday, June 29, 2005
JCA articles on developerWorks
Geronimo documentations on developerWorks
IBM puts some interesting documentations about Geronimo on the developerWorks web site at the following url:
http://www-128.ibm.com/developerworks/opensource/top-projects/geronimo.html
http://www-128.ibm.com/developerworks/opensource/top-projects/geronimo.html
Monday, May 30, 2005
Tranql and XAPool
Geronimo uses an interesting project to transform a jdbc driver into a resource adapter. This project is called Tranql. Its home page is http://tranql.codehaus.org/.
This page doesn't show a lot of informations and it is preferable to go to look at directly in the cvs ;-). The cvs is hosted by codehaus (cvs.tranql.codehaus.org) and the cvs root is /home/projects/tranql/scm.
The project only wrap JDBC driver and doesn't add support to convert a no-xa driver into an xa driver... An interested approach is to develop an integration between Tranql and XAPool. So you can easily create an XA DataSource from a simple DataSource and manage its connections with a JCA connection manager.
For example, with Tranql, you can configure a pool of connections with JCA in this way (using the Spring JCA support of Spring):
So, to transform this DataSource in a XA compliant one, you only need to change the implementation of the ManagedConnectionManager. This XAPoolDataSourceMCF one integrates XAPool and use its StandardXADataSource class.
The configuration is now:
Note: A big problem is that XAPool internally manages the enlistment/delistment of XAResource. So you need to patch this tool to remove the call of enlist and delist on the current transaction.
Here is a sample implementation of XAPoolDataSourceMCF:
The latest ManagedConnectionFactory implementation supports XA transactions!
This page doesn't show a lot of informations and it is preferable to go to look at directly in the cvs ;-). The cvs is hosted by codehaus (cvs.tranql.codehaus.org) and the cvs root is /home/projects/tranql/scm.
The project only wrap JDBC driver and doesn't add support to convert a no-xa driver into an xa driver... An interested approach is to develop an integration between Tranql and XAPool. So you can easily create an XA DataSource from a simple DataSource and manage its connections with a JCA connection manager.
For example, with Tranql, you can configure a pool of connections with JCA in this way (using the Spring JCA support of Spring):
<bean id="tranqlManagedConnectionFactory"
class="org.tranql.connector.jdbc.XADriverMCF">
<property name="driverName">
<value>org.hsqldb.jdbcDriver</value>
</property>
<property name="url">
<value>jdbc:hsqldb:hsql://localhost:9002</value>
</property>
<property name="user">
<value>sa</value>
</property>
<property name="password">
<value></value>
</property>
</bean>
So, to transform this DataSource in a XA compliant one, you only need to change the implementation of the ManagedConnectionManager. This XAPoolDataSourceMCF one integrates XAPool and use its StandardXADataSource class.
The configuration is now:
<bean id="tranqlManagedConnectionFactory"
class="org.tranql.connector.jdbc.XAPoolDataSourceMCF ">
<property name="driverName">
<value>org.hsqldb.jdbcDriver</value>
</property>
<property name="url">
<value>jdbc:hsqldb:hsql://localhost:9002</value>
</property>
<property name="user">
<value>sa</value>
</property>
<property name="password">
<value></value>
</property>
</bean>
Note: A big problem is that XAPool internally manages the enlistment/delistment of XAResource. So you need to patch this tool to remove the call of enlist and delist on the current transaction.
Here is a sample implementation of XAPoolDataSourceMCF:
package org.tranql.connector.jdbc;
import java.sql.SQLException;
import javax.sql.XAConnection;
import javax.sql.XADataSource;
import org.enhydra.jdbc.standard.StandardXADataSource;
import org.tranql.connector.AllExceptionsAreFatalSorter;
public class XAPoolDataSourceMCF extends AbstractXADataSourceMCF {
public XAPoolDataSourceMCF() {
super(new StandardXADataSource(),new AllExceptionsAreFatalSorter());
}
public String getUserName() {
return ((StandardXADataSource)xaDataSource).getUser();
}
public String getPassword() {
return ((StandardXADataSource)xaDataSource).getPassword();
}
public void setDriverName(String driverName) {
try {
((StandardXADataSource)xaDataSource).setDriverName(driverName);
} catch (SQLException ex) { ex.printStackTrace(); }
}
public void setUrl(String url) {
((StandardXADataSource)xaDataSource).setUrl(url);
}
public void setUser(String user) {
((StandardXADataSource)xaDataSource).setUser(user);
}
public void setPassword(String password) {
((StandardXADataSource)xaDataSource).setPassword(password);
}
}
The latest ManagedConnectionFactory implementation supports XA transactions!
Subscribe to:
Posts (Atom)