Last active
March 17, 2016 01:55
-
-
Save dovidkopel/28c964336952c6fa19d1 to your computer and use it in GitHub Desktop.
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 org.springframework.beans.factory.BeanFactory; | |
public enum BeanAccessor { | |
INSTANCE; | |
private static BeanFactory beanFactory; | |
public static void setBeanFactory(BeanFactory _beanFactory) { | |
beanFactory = _beanFactory; | |
} | |
public static <T> T getBean(Class<T> clazz) { | |
return beanFactory.getBean(clazz); | |
} | |
} |
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 org.springframework.beans.factory.BeanFactory; | |
import org.springframework.beans.factory.annotation.Autowired; | |
import org.springframework.context.annotation.Bean; | |
import org.springframework.context.annotation.Configuration; | |
@Configuration | |
public class BeanFactoryConfiguration { | |
@Autowired | |
public void setBeanAccessor(BeanFactory beanFactory) { | |
BeanAccessor.setBeanFactory(beanFactory); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment