Created
September 24, 2015 10:36
-
-
Save matthewbednarski/a65ef94f5b158059e563 to your computer and use it in GitHub Desktop.
gives access to the ApplicationContext
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
package it.solinfo.xdsindexer.utils; | |
import org.apache.log4j.Logger; | |
import org.springframework.beans.BeansException; | |
import org.springframework.context.ApplicationContext; | |
import org.springframework.context.ApplicationContextAware; | |
import javax.inject.Named; | |
/** | |
* Created by arch on 4/9/15. | |
*/ | |
@Named | |
public class AppContext implements ApplicationContextAware{ | |
protected final Logger log = Logger.getLogger(getClass()); | |
@Override | |
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { | |
log.debug("Setting context with: " + applicationContext); | |
AppContext.ctx = applicationContext; | |
} | |
private static ApplicationContext ctx; | |
/** | |
* Get access to the Spring ApplicationContext from everywhere in your Application. | |
* | |
* @return | |
*/ | |
public static ApplicationContext getApplicationContext() { | |
return ctx; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment