/** * Gets the applicationContext. * * @return the applicationContext. */ protected BeanFactory getApplicationContext() { try { if (applicationContext == null) { synchronized (LOCK) { if (applicationContext == null) { BeanFactoryLocator bfl = SingletonBeanFactoryLocator.getInstance(getBeanFactorySelector()); BeanFactoryReference bf = bfl.useBeanFactory(getApplicationContextKey()); BeanFactory tempApplicationContext = bf.getFactory(); if (tempApplicationContext instanceof ConfigurableApplicationContext) { ((ConfigurableApplicationContext) tempApplicationContext).registerShutdownHook(); } applicationContext = tempApplicationContext; } } } return applicationContext; } catch (RuntimeException ex) { LOG.error("{} context could not be instantiated.", getApplicationContextKey(), ex); throw ex; } }