[jboss-user] [Spring Integration] - JBoss 5.1.0 and Multiple EARs and EJBs using the SpringBeanAutowiringInterceptor issue

Kyle Bober do-not-reply at jboss.com
Fri Jun 11 10:19:00 EDT 2010


Kyle Bober [http://community.jboss.org/people/kyle.bober] replied to the discussion

"JBoss 5.1.0 and Multiple EARs and EJBs using the SpringBeanAutowiringInterceptor issue"

To view the discussion, visit: http://community.jboss.org/message/547577#547577

--------------------------------------------------------------
Okay I have found a solution to my issue. I am not sure if this is the best way of handling this but it works for now and I have yet to run into any issue.

We overrode the getBeanFactoryLocator method in the SpringBeanAutowiringInterceptor class. We then used the new Interceptor in our EJB

@Interceptors(AnotherSpringBeanAutowiringInterceptor.class)

package com.somepackage;

import org.springframework.beans.factory.access.BeanFactoryLocator;
import org.springframework.context.access.ContextSingletonBeanFactoryLocator;
import org.springframework.ejb.interceptor.SpringBeanAutowiringInterceptor;

public class AnotherSpringBeanAutowiringInterceptor extends    SpringBeanAutowiringInterceptor {

    private static final String DEFAULT_RESOURCE_LOCATION = "classpath*:anotherBeanRefContext.xml";
    
    /**
     * Determine the BeanFactoryLocator to obtain the BeanFactoryReference from.
     * <p>The default implementation exposes Spring's default
     * {@link ContextSingletonBeanFactoryLocator}.
     * @param target the target bean to autowire
     * @return the BeanFactoryLocator to use (never <code>null</code>)
     * @see org.springframework.context.access.ContextSingletonBeanFactoryLocator#getInstance()
     */
    protected BeanFactoryLocator getBeanFactoryLocator(Object target) {
        return ContextSingletonBeanFactoryLocator.getInstance(DEFAULT_RESOURCE_LOCATION);
    }    
}

This worked for our multiple EARs which each contained a diffrent beanRefContext.xml. We needed to make the names beanRefContext.xml file unique per EAR and then override the SpringBeanAutowiringInterceptor getBeanFactoryLocator method. We also changed the DEFAULT_RESOURCE_LOCATION string to reference out EARs specific beanRefContext.xml file. If anyone sees an issue with this please let me know as to what side affects we may run into. For now this has been running just fine.

Thanks for everyones help and insight into this issue.
-Kyle Bober

--------------------------------------------------------------

Reply to this message by going to Community
[http://community.jboss.org/message/547577#547577]

Start a new discussion in Spring Integration at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2082]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20100611/16f594cf/attachment-0001.html 


More information about the jboss-user mailing list