Monday, August 22, 2005

Access CICS with Spring

Here is an article I have made to explain and show how to access CICS transactions and programs with the Spring JCA support.

This article is published by JavaWorld at the following url:
Access CICS applications with Spring

Tuesday, August 16, 2005

Use Groovy with Spring

Groovy is an interesting script engine on the JVM. The main is to provide an embedded component of a Java/J2EE application, to help write and customize business rules, or other moving parts of your application [cf G. Laforge].

I. Support in Spring

Spring offers a support for script tools in the sandbox. This support provides a generic component that can be extended in order to plug an implementation for a dedicated tool. This framework is localized in the org.springframework.beans.factory.script package and the groovy support in the org.springframework.beans.factory.script.groovy package.
This support is based on the facility of Spring to configure beans based on factory. Thus, the configuration of a Groovy object is divided into two steps:

  • Configuration of the Spring factory for Groovy

  • Configuration of the bean representing a Groovy object

  • The factory is simply configured as following:

    <bean id="groovyScriptFactory"
    <property name="expirySeconds">

    Then you can configure your script with its location and inject all the properties used by it:

    <bean id="testGroovy" singleton="true"
    <property name="message">
    <value>the value of my propertylt;/value>

    The Groovy script used will be the following. You can see that the value of the "message" property has been injected using Spring...

    package groovy;

    public class TestImpl implements Test {
    @Property test;
    @Property message;
    @Property method;
    @Property list = {
    param ->
    println "list - param : ${param} - "+param;

    @Property Closure list1 = {
    param ->
    println "hoho! list1 - param : ${param} - "+param;

    public TestImpl() {
    method = { |name| println "Hello, ${name}" }

    void test() {
    println message;

    In our case, we expose the bean on Groovy thanks to the Test interface, so the application see it and doesn't know that the implementation is a Groovy script!

    However, this use isn't mandatory and you can see the Groovy script as a GroovyObject directly and nevertheless inject properties with Spring!!

    In the next part of "Use Groovy with Spring", we will show and explain how Steven Devijver load and construct a J2EE based on Groovy scripts and its closure feature, in the Grails project.

    Monday, July 11, 2005

    JCA documentation in Spring

    The chapter of the JCA support in Spring has been added in the reference documentation with the version 1.2.2 of Spring.
    See the following url to read it!!

    Thursday, June 30, 2005

    "Is EJB3 a Spring killer?"

    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...

    Made you your opinion with the following readings!!!

    Some threads in the Spring forum on this subject:
    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

    Wednesday, June 29, 2005

    JCA articles on developerWorks

    IBM puts an interesting serie of articles about JCA 1.5 on the developerWorks web site at the following urls:
    Part 1
    Part 2
    Part 3

    Geronimo documentations on developerWorks

    IBM puts some interesting documentations about Geronimo on the developerWorks web site at the following url:

    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

    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 ( 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"
    <property name="driverName">
    <property name="url">
    <property name="user">
    <property name="password">

    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">
    <property name="url">
    <property name="user">
    <property name="password">

    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 {
    } catch (SQLException ex) { ex.printStackTrace(); }

    public void setUrl(String url) {

    public void setUser(String user) {

    public void setPassword(String password) {


    The latest ManagedConnectionFactory implementation supports XA transactions!

    Friday, May 20, 2005

    Spring JCA support is out

    The JCA CCI support is now integrated in the Spring framework 1.2.
    You can view the corresponding org.springframework.jca package in the Spring CVS of at the following url:

    Thursday, January 13, 2005

    Using of Ant in Eclipse

    In order to use the javac task of ant when you launch ant in Eclipse, you need to configure a system property to use the Eclipse compiler.
    To do this, you can use a system property for the ant process (-D).


    or a task in ant to initialize it. This task you must be called before every other tasks.

    <project name="spring-core" default="traduction" basedir=".">

    <target name="eclipse" if="eclipse.running">
    <property name="build.compiler"
    value="org.eclipse.jdt.core.JDTCompilerAdapter" />

    <target name="page-preface" depends="eclipse" description="overview">