Skip to content

Instantly share code, notes, and snippets.

@schakko
Created October 11, 2013 05:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save schakko/6930091 to your computer and use it in GitHub Desktop.
Save schakko/6930091 to your computer and use it in GitHub Desktop.
Global scoped Spring application context inside EJBs
import javax.ejb.Singleton;
import javax.enterprise.context.ApplicationScoped;
import org.springframework.context.ApplicationContext;
/**
* Global {@link ApplicationContext} holder which can be referenced inside any
* EJB/interceptor. This context is annotated with {@link Singleton} so there
* can only one application wide context be defined. Additionally, this class is
* marked as {@link ApplicationScoped}.
*
* @author ckl
*/
@Singleton
@ApplicationScoped
public class SpringContextBean {
private ApplicationContext applicationContext;
public ApplicationContext getApplicationContext() {
return applicationContext;
}
public void setApplicationContext(ApplicationContext applicationContext) {
this.applicationContext = applicationContext;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment