001/* 002 * The contents of this file are subject to the license and copyright 003 * detailed in the LICENSE and NOTICE files at the root of the source 004 * tree. 005 */ 006package org.fcrepo.http.commons.test.util; 007 008import org.springframework.beans.BeansException; 009import org.springframework.context.ApplicationContext; 010import org.springframework.context.ApplicationContextAware; 011 012 013/** 014 * Retrieves the application context in which it is configured, for testing 015 * purposes only. 016 * 017 * @since September 19, 2014 018 * @author Gregory Jansen 019 */ 020public class SpringContextSingleton implements ApplicationContextAware { 021 022 private static ApplicationContext applicationContext; 023 024 /* (non-Javadoc) 025 * @see org.springframework.context.ApplicationContextAware#setApplicationContext( 026 * org.springframework.context.ApplicationContext) 027 */ 028 @Override 029 public void setApplicationContext(final ApplicationContext applicationContext) 030 throws BeansException { 031 SpringContextSingleton.applicationContext = applicationContext; 032 } 033 034 public static ApplicationContext getApplicationContext() { 035 return applicationContext; 036 } 037 038}