Created
October 11, 2013 05:48
-
-
Save schakko/6930130 to your computer and use it in GitHub Desktop.
Interceptor for use @Autowired in EJBs with global Spring application context
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import javax.ejb.EJB; | |
import org.springframework.beans.factory.BeanFactory; | |
import org.springframework.ejb.interceptor.SpringBeanAutowiringInterceptor; | |
import de.ckl.ejb.SpringContextBean; | |
/** | |
* {@link SpringContextInterceptor} can be used for autowiring Spring beans | |
* inside EJBs. Unlike {@link SpringBeanAutowiringInterceptor} the | |
* {@link SpringContextInterceptor} uses the application wide shared Spring | |
* application context from {@link SpringContextBean}. | |
* | |
* @author ckl | |
*/ | |
public class SpringContextInterceptor extends SpringBeanAutowiringInterceptor { | |
@EJB | |
SpringContextBean springContextBean; | |
protected BeanFactory getBeanFactory(Object target) { | |
return springContextBean.getApplicationContext() | |
.getAutowireCapableBeanFactory(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment