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
Monday, August 22, 2005
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:
Then you can configure your script with its location and inject all the properties used by it:
The Groovy script used will be the following. You can see that the value of the "message" property has been injected using Spring...
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.
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:
The factory is simply configured as following:
<bean id="groovyScriptFactory"
class="org.springframework.beans.factory.script.groovy.GroovyScriptFactory">
<property name="expirySeconds">
<value>1</value>
</property>
</bean>
Then you can configure your script with its location and inject all the properties used by it:
<bean id="testGroovy" singleton="true"
factory-bean="groovyScriptFactory"
factory-method="create">
<constructor-arg>
<value>classpath:/groovy/simple.groovy</value>
</constructor-arg>
<property name="message">
<value>the value of my propertylt;/value>
</property>
</bean>
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;
method(message);
list("test");
}
}
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!!
JCA CCI
See the following url to read it!!
JCA CCI
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...
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
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
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!
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:
http://cvs.sourceforge.net/viewcvs.py/springframework/spring/src/org/springframework/jca/
You can view the corresponding org.springframework.jca package in the Spring CVS of at the following url:
http://cvs.sourceforge.net/viewcvs.py/springframework/spring/src/org/springframework/jca/
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.
To do this, you can use a system property for the ant process (-D).
-Dbuild.compiler=org.eclipse.jdt.core.JDTCompilerAdapter
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>
<target name="page-preface" depends="eclipse" description="overview">
...
</target>
...
</project>
Subscribe to:
Posts (Atom)