Mistři v programování na #hovnokod

Java #4574

Spring a Dependency Injection? Pche! Umíme sami! (A líp!)

@Configuration
public class SpringApplicationContext implements ApplicationContextAware {

	private static ApplicationContext context;

	@Override
	public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
		context = applicationContext;
	}

	public static <T> T getBean(Class<T> clazz) {
		return context.getBean(clazz);
	}
}

...
MojeBean mojeBean = SpringApplicationContext.getBean(MojeBean.class);

Anonymous,