Java tutorial
/** * Project: warnme-server * File: ApplicationContextHolder.java * License: * This file is licensed under GNU General Public License version 3 * http://www.gnu.org/licenses/gpl-3.0.txt * * Copyright: Bartosz Cichecki [ cichecki.bartosz@gmail.com ] * Date: 19-03-2014 */ package dtu.ds.warnme.holders; import org.springframework.beans.BeansException; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextAware; /** * @author Bartosz Cichecki */ public class ApplicationContextHolder implements ApplicationContextAware { private static ApplicationContext applicationContext; public static ApplicationContext getContext() { return applicationContext; } @Override public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { synchronized (ApplicationContextHolder.class) { ApplicationContextHolder.applicationContext = applicationContext; } } }