JBoss + Spring + EJB 3.0 Integration
This wiki page is dedicated to link to various docs and resources that facilitate the integration of the JBoss and Spring projects.
Ales Justin has written a Spring and EJB3 Deployer for JBoss so that you can deploy .spring archives into JBoss. You can download the Spring deployer distribution at Sourceforge and discuss and ask questions here.
The Spring Deployer distribution contains a JBoss Deployer that supports Spring packaging in JBoss. What this means is that you can create JAR archives with a META-INF/jboss-spring.xml file and your Spring bean factories will automatically be deployed. Also supported in this distribution is EJB 3.0 integration. You can deploy Spring archives and be able to inject beans created in these deployment directly into an EJB using a @Spring annotation.
What follows describes the 2005-08-26 release of Spring Deployer.
Installation
If you are using EJB 3.0 and JDK 5 integration, copy the jboss-spring-jdk5.deployer directory into the JBoss deploy/ directory. If you are using JDK 1.4, then copy the jboss-spring.deployer/ into the deploy directory. If you look inside these .deployer deployments you will see that only a partial Spring distribution is contained. If you need a full Spring distribution, then copy those jars into the .deployer directory or into the lib/ directory of your JBoss configuration.
Spring deployments
You can create Spring deployments that work much in the same way .sar's, .war's, .ear's, .har's, and .rar's work. Using the JBoss Spring deployer you can create Spring jars:
my-app.spring/ org/ acme/ ~MyBean.class ~MyBean2.class META-INF/ jboss-spring.xml
So, my-app.spring is a jar that contains classes, like any other JAR and a jboss-spring.xml file in the META-INF/ of the jar. This jboss-spring.xml file is like any other Spring xml file. By default, the JBoss Spring Deployer will register this bean factory defined in the XML file into JNDI. It will be registered in a non-serialized form so you don't have to worry about JNDI serialization! The default JNDI name will be the short name of the deployment file. So in this example, the bean factory described in the META-INF/jboss-spring.xml file will be registered under the "my-app" JNDI name.
Alternatively, you do not have to create an archive. You can put your jar libraries under server/-spring.xml into the JBoss deploy directory. For example, my-app-spring.xml. Again, the JNDI name will be by default, the short name of the XML file, in the case my-app-spring.xml will produce a JNDI binding of "my-app".
Deployment
Once you have created a .spring archive or a -spring.xml file, all you have to do is put it in the JBoss deploy/ directory and it will be deployed into the JBoss runtime. You can also embed these deployments inside an EAR, EJB-JAR, SAR, etc. as JBoss supports nested archives.
To Learn More
This is only a brief description of the project. To learn more, download the distribution using the link at the top of the page (documentation is provided). An detailed article can be found here http://java.sys-con.com/read/180386_1.htm
Comments