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; }
@Override protected Map<String, JsonAction> loadActions() throws Exception { String springConfigFile = getServletConfig().getInitParameter(INIT_PARAM_SPRING_CFG_FILE); if (springConfigFile == null) { applicationContext = new ClassPathXmlApplicationContext(DEFAULT_CFG_FILE); } else { applicationContext = new ClassPathXmlApplicationContext(springConfigFile, DEFAULT_CFG_FILE); } applicationContext.setClassLoader(getClassLoader()); return applicationContext.getBeansOfType(JsonAction.class); }
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; } }
private RpcContext() { if (testMode) { this.applicationContext = new ClassPathXmlApplicationContext(SpringNames.CFG_CORE_FILE); } else { this.applicationContext = new ClassPathXmlApplicationContext(SpringNames.CFG_CORE_FILE, SpringNames.CFG_FILE); } this.applicationContext.setClassLoader(Thread.currentThread().getContextClassLoader()); loadBuiltServices(applicationContext); this.httpServices = ServiceLoader.loadServices(this.applicationContext, HttpAction.class); this.webSocketServices = ServiceLoader.loadServices(this.applicationContext, WebsocketAction.class); this.webSocketTopics = applicationContext.getBeansOfType(Topic.class); validateTopics(webSocketTopics); }
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("SpringBeans.xml"); ClassPathXmlApplicationContext helloContext = new ClassPathXmlApplicationContext("HelloBeans.xml"); helloContext.setParent(context); helloContext.setClassLoader(context.getClassLoader()); helloContext.refresh(); helloContext.registerShutdownHook();
context.setClassLoader(thisClassLoader); context.setConfigLocation("classpath:/MaskingFilterContext.xml"); context.refresh();
context.setClassLoader(thisClassLoader); context.setConfigLocation(JEXL_FUNCTION_NAMESPACE_CONTEXT); context.refresh();
/** * 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); } } }
cax.setClassLoader(ucl); cax.refresh();
cax.setClassLoader(ucl); logger.info("Classloader: " + cax.getClassLoader()); cax.refresh();