/** * Create a new ClassPathXmlApplicationContext with the given parent, * loading the definitions from the given XML files. * @param configLocations array of resource locations * @param refresh whether to automatically refresh the context, * loading all bean definitions and creating all singletons. * Alternatively, call refresh manually after further configuring the context. * @param parent the parent context * @throws BeansException if context creation failed * @see #refresh() */ public ClassPathXmlApplicationContext( String[] configLocations, boolean refresh, @Nullable ApplicationContext parent) throws BeansException { super(parent); setConfigLocations(configLocations); if (refresh) { refresh(); } }
/** * Create a new ClassPathXmlApplicationContext with the given parent, * loading the definitions from the given XML files. * @param configLocations array of resource locations * @param refresh whether to automatically refresh the context, * loading all bean definitions and creating all singletons. * Alternatively, call refresh manually after further configuring the context. * @param parent the parent context * @throws BeansException if context creation failed * @see #refresh() */ public ClassPathXmlApplicationContext( String[] configLocations, boolean refresh, @Nullable ApplicationContext parent) throws BeansException { super(parent); setConfigLocations(configLocations); if (refresh) { refresh(); } }
context.setConfigLocations(new String[]{"classpath:org/springframework/integration/channel/channel-override-config.xml"}); context.setParent(parentContext); Method method = ReflectionUtils.findMethod(ClassPathXmlApplicationContext.class, "obtainFreshBeanFactory");
/** * Create a new ClassPathXmlApplicationContext with the given parent, * loading the definitions from the given XML files. * @param configLocations array of resource locations * @param refresh whether to automatically refresh the context, * loading all bean definitions and creating all singletons. * Alternatively, call refresh manually after further configuring the context. * @param parent the parent context * @throws BeansException if context creation failed * @see #refresh() */ public ClassPathXmlApplicationContext( String[] configLocations, boolean refresh, @Nullable ApplicationContext parent) throws BeansException { super(parent); setConfigLocations(configLocations); if (refresh) { refresh(); } }
public static synchronized MarkingFunctions createMarkingFunctions() { if (markingFunctions != null) return markingFunctions; ClassLoader thisClassLoader = MarkingFunctionsFactory.class.getClassLoader(); // ignore calls to close as this blows away the cache manager ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(); try { context.setClassLoader(thisClassLoader); context.setConfigLocations("classpath*:/MarkingFunctionsContext.xml", "classpath*:/CacheContext.xml"); context.refresh(); markingFunctions = context.getBean("markingFunctions", MarkingFunctions.class); } catch (Throwable t) { log.warn("Could not load spring context files! Got " + t); if (log.isDebugEnabled()) { log.debug("Failed to load Spring contexts", t); } } return markingFunctions; }
public static synchronized TypeMetadataProvider createTypeMetadataProvider() { if (typeMetadataProvider != null) return typeMetadataProvider; ClassLoader thisClassLoader = TypeMetadataProvider.Factory.class.getClassLoader(); // ignore calls to close as this blows away the cache manager ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(); try { // To prevent failure when this is run on the tservers: // The VFS ClassLoader has been created and has been made the current thread's context classloader, but its resource paths are empty at this // time. // The spring ApplicationContext will prefer the current thread's context classloader, so the spring context would fail to find // any classes or context files to load. // Instead, set the classloader on the ApplicationContext to be the one that is loading this class. // It is a VFSClassLoader that has the accumulo lib/ext jars set as its resources. // After setting the classloader, then set the config locations and refresh the context. context.setClassLoader(thisClassLoader); context.setConfigLocations("classpath:/TypeMetadataBridgeContext.xml", "classpath:/TypeMetadataProviderContext.xml"); context.refresh(); typeMetadataProvider = context.getBean("typeMetadataProvider", TypeMetadataProvider.class); } catch (Throwable t) { // got here because the VFSClassLoader on the tservers does not implement findResources // none of the spring wiring will work. log.warn("Could not load spring context files. got " + t); } return typeMetadataProvider; } }
/** * Initializes the internal field maps using the EdgeModelContext.xml config */ private void loadContext() { String contextOverride = System.getProperty("edge.model.context.path"); if (null != contextOverride) { FileSystemXmlApplicationContext context = new FileSystemXmlApplicationContext(contextOverride); loadMaps(context); context.close(); } else { ClassLoader thisClassLoader = EdgeModelAware.class.getClassLoader(); ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(); try { context.setClassLoader(thisClassLoader); context.setConfigLocations(EDGE_MODEL_CONTEXT); context.refresh(); loadMaps(context); context.close(); } catch (Throwable t) { log.fatal("Edge model configuration not loaded!! Edge queries will fail until this issue is corrected."); log.fatal(String.format("Ensure that the Spring config file '%s' is on the classpath and contains bean names '%s', '%s', and '%s'", EDGE_MODEL_CONTEXT, BASE_MODEL_BEAN, KEYUTIL_MODEL_BEAN, TRANSFORM_MODEL_BEAN), t); } } }
appCtx.setConfigLocations(listOfClassPathXml.toArray(new String[listOfClassPathXml.size()])); appCtx.addBeanFactoryPostProcessor(configurer); logger.warn("Updating database schema, this could take a few minutes ...");