jboss ejb3 and spring integration using jboss-spring deployer

jboss ejb3 spring integration using jboss-spring deployer

spring deployer download site:
http://sourceforge.net/project/showfiles.php?group_id=22866&package_id=161914

detailed tutorial:
http://java.sys-con.com/node/180386
http://wiki.jboss.org/wiki/JBossSpringIntegration

currently there is a distribution for jboss-spring deployer for:

jboss-5 + spring 2.5 
download :
jboss-spring-3.1.deployer
jboss-spring-3.1.jar

jboss-4.x + spring 2.03
download:
Spring Deployer 1.3 - file name; jboss-spring-version4.zip

to have a spring deployer for jboss-4.x and spring 2.0.8 or spring 2.5:

download Spring Deployer 1.3 - file name; jboss-spring-version4.zip

download one of the files under Spring Deployer 2.1 in spring deployer download site:
jboss-spring-jdk5-2.0.8.jar
or
jboss-spring-jdk5-2.5.jar

unpack jboss-spring-version4.zip

copy jboss-spring-version4/jboss-spring-jdk5.deployer and call it

jboss-4.x-spring-2.5-jdk5.deployer

under jboss-4.x-spring-2.5-jdk5.deployer delete all jar files.

copy jboss-spring-jdk5-2.5.jar to jboss-4.x-spring-2.5-jdk5.deployer

copy the spring 2.5 jar to  jboss-4.x-spring-2.5-jdk5.deployer

jboss-4.x-spring-2.5-jdk5.deployer is your deployer for jboss-4.x and spring 2.5

copy this folder to the jboss deploy directory.

it looks like that:

jboss-4.x-spring-2.5-jdk5.deployer/
           boss-spring-jdk5-2.5.jar
           spring.jar
           META-INF/
                 jboss-service.xml
                 MANIFEST.MF

 

add the spring injection interceptor to the ejb3 interceptor stack;

under jboss deploy directory edit ejb3-interceptors-aop.xml

add an interceptor:

<interceptor class="org.jboss.spring.interceptor.SpringInjectionInterceptor"/>

bind the interceptor to the domains you want, usually all domains;

<bind pointcut="execution(*->new(..))">

  <interceptor-ref name="org.jboss.spring.interceptor.SpringInjectionInterceptor"/>

</bind>

the deployer is complete.

 

package your spring app in a jar where the spring application-context.xml is under the META-INF folder and is called jboss-spring.xml, the jar ext should be .spring

for exp:

myapp.spring/
       MyBean.class
       META-INF/
            MANIFEST.MF
            jboss-spring.xml

deploy the spring app to the jboss deploy directory.

the deployer registers the spring bean factory in JNDI under the name of the spring application, for exp: 'myapp'. TODO:how to control this name?

to inject spring beans to ejb3 components:

you will need the deployer jar in your build path. in our case jboss-spring-jdk5-2.5.jar

add the @Spring annotation to the spring bean declaration in your ejb.

properties of @Spring:
j
ndiName is the jndi name of the registered spring app.
b
ean is the spring bean's name.

public class TempTaskProducerBean implements TempTaskProducer {

   @Spring(jndiName="myapp",bean="testBean")

   private TestSpringBean testSpringBean = null;

 

   public TestSpringBean getTestSpringBean() {

      return testBean;

   }

   public void setTestSpringBean(TestSpringBean testSpringBean) {

      this.testSpringBean = testSpringBean;

  }

}

 

you can of course deploy as many spring modules as you wish.

 

TODO:transactions?

 

thats it.

 

 

Thank you for your interest!

We will contact you as soon as possible.

Send us a message

Oops, something went wrong
Please try again or contact us by email at info@tikalk.com