/** * Return current thread's context classloader * * @return Classloder context of current thread */ public ClassLoader getClassLoader() { return applicationContext.getClassLoader(); }
public static boolean isJsr303Present(ApplicationContext applicationContext) { ClassLoader classLoader = applicationContext.getClassLoader(); for (String validatorClass : VALIDATOR_CLASSES) { if (!ClassUtils.isPresent(validatorClass, classLoader)) { return false; } } return true; }
static boolean shouldConfigure(ApplicationContext context) { ClassLoader loader = context.getClassLoader(); Class<?> reactiveClientRegistrationRepositoryClass = ClassUtils.resolveClassName(REACTIVE_CLIENT_REGISTRATION_REPOSITORY_CLASSNAME, loader); return context.getBeanNamesForType(reactiveClientRegistrationRepositoryClass).length == 1; } }
protected ScriptEngine createEngineFromName(String engineName) { ScriptEngineManager scriptEngineManager = this.scriptEngineManager; if (scriptEngineManager == null) { scriptEngineManager = new ScriptEngineManager(obtainApplicationContext().getClassLoader()); this.scriptEngineManager = scriptEngineManager; } ScriptEngine engine = StandardScriptUtils.retrieveEngineByName(scriptEngineManager, engineName); loadScripts(engine); return engine; }
protected ScriptEngine createEngineFromName(String engineName) { ScriptEngineManager scriptEngineManager = this.scriptEngineManager; if (scriptEngineManager == null) { scriptEngineManager = new ScriptEngineManager(obtainApplicationContext().getClassLoader()); this.scriptEngineManager = scriptEngineManager; } ScriptEngine engine = StandardScriptUtils.retrieveEngineByName(scriptEngineManager, engineName); loadScripts(engine); return engine; }
/** * Create a parent ClassLoader for Groovy to use as parent ClassLoader * when loading and compiling templates. */ protected ClassLoader createTemplateClassLoader() throws IOException { String[] paths = StringUtils.commaDelimitedListToStringArray(getResourceLoaderPath()); List<URL> urls = new ArrayList<>(); for (String path : paths) { Resource[] resources = getApplicationContext().getResources(path); if (resources.length > 0) { for (Resource resource : resources) { if (resource.exists()) { urls.add(resource.getURL()); } } } } ClassLoader classLoader = getApplicationContext().getClassLoader(); Assert.state(classLoader != null, "No ClassLoader"); return (!urls.isEmpty() ? new URLClassLoader(urls.toArray(new URL[0]), classLoader) : classLoader); }
/** * Create a parent ClassLoader for Groovy to use as parent ClassLoader * when loading and compiling templates. */ protected ClassLoader createTemplateClassLoader() throws IOException { String[] paths = StringUtils.commaDelimitedListToStringArray(getResourceLoaderPath()); List<URL> urls = new ArrayList<>(); for (String path : paths) { Resource[] resources = getApplicationContext().getResources(path); if (resources.length > 0) { for (Resource resource : resources) { if (resource.exists()) { urls.add(resource.getURL()); } } } } ClassLoader classLoader = getApplicationContext().getClassLoader(); Assert.state(classLoader != null, "No ClassLoader"); return (!urls.isEmpty() ? new URLClassLoader(urls.toArray(new URL[0]), classLoader) : classLoader); }
protected ScriptEngine createEngineFromName(String engineName) { ScriptEngineManager scriptEngineManager = this.scriptEngineManager; if (scriptEngineManager == null) { scriptEngineManager = new ScriptEngineManager(obtainApplicationContext().getClassLoader()); this.scriptEngineManager = scriptEngineManager; } ScriptEngine engine = StandardScriptUtils.retrieveEngineByName(scriptEngineManager, engineName); loadScripts(engine); return engine; }
private CorsFilter getCorsFilter(ApplicationContext context) { if (this.configurationSource != null) { return new CorsFilter(this.configurationSource); } boolean containsCorsFilter = context .containsBeanDefinition(CORS_FILTER_BEAN_NAME); if (containsCorsFilter) { return context.getBean(CORS_FILTER_BEAN_NAME, CorsFilter.class); } boolean containsCorsSource = context .containsBean(CORS_CONFIGURATION_SOURCE_BEAN_NAME); if (containsCorsSource) { CorsConfigurationSource configurationSource = context.getBean( CORS_CONFIGURATION_SOURCE_BEAN_NAME, CorsConfigurationSource.class); return new CorsFilter(configurationSource); } boolean mvcPresent = ClassUtils.isPresent(HANDLER_MAPPING_INTROSPECTOR, context.getClassLoader()); if (mvcPresent) { return MvcCorsFilter.getMvcCorsFilter(context); } return null; }
ClassLoader loader = common.getClassLoader(); Class<?> pluginClass; String pluginMainMethod = null;
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { prepareIndexCreator(applicationContext); eventPublisher = applicationContext; if (mappingContext instanceof ApplicationEventPublisherAware) { ((ApplicationEventPublisherAware) mappingContext).setApplicationEventPublisher(eventPublisher); } projectionFactory.setBeanFactory(applicationContext); projectionFactory.setBeanClassLoader(applicationContext.getClassLoader()); }
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { prepareIndexCreator(applicationContext); eventPublisher = applicationContext; if (mappingContext instanceof ApplicationEventPublisherAware) { ((ApplicationEventPublisherAware) mappingContext).setApplicationEventPublisher(eventPublisher); } resourceLoader = applicationContext; projectionFactory.setBeanFactory(applicationContext); projectionFactory.setBeanClassLoader(applicationContext.getClassLoader()); }
try { Method eclMethod = configuration.getClass().getMethod("externalClassLoader", ClassLoader.class); ReflectionUtils.invokeMethod(eclMethod, configuration, this.applicationContext.getClassLoader());
try { Method eclMethod = configuration.getClass().getMethod("externalClassLoader", ClassLoader.class); ReflectionUtils.invokeMethod(eclMethod, configuration, this.applicationContext.getClassLoader());
static boolean shouldConfigure(ApplicationContext context) { ClassLoader loader = context.getClassLoader(); Class<?> reactiveClientRegistrationRepositoryClass = ClassUtils.resolveClassName(REACTIVE_CLIENT_REGISTRATION_REPOSITORY_CLASSNAME, loader); return context.getBeanNamesForType(reactiveClientRegistrationRepositoryClass).length == 1; } }
.logout(); ClassLoader classLoader = this.context.getClassLoader(); List<AbstractHttpConfigurer> defaultHttpConfigurers = SpringFactoriesLoader.loadFactories(AbstractHttpConfigurer.class, classLoader);
private Class<?> resolveClassFromName(String className) { try { Assert.state(getApplicationContext() != null, "An ApplicationContext is required"); return ClassUtils.forName(className, getApplicationContext().getClassLoader()); } catch (ClassNotFoundException e) { throw new IllegalStateException("Cannot load class for channel mapping.", e); } }
private MessageGroupProcessor createGroupTimeoutProcessor() { MessageGroupProcessor processor = new ForceReleaseMessageGroupProcessor(); if (this.groupTimeoutExpression != null && !CollectionUtils.isEmpty(this.forceReleaseAdviceChain)) { ProxyFactory proxyFactory = new ProxyFactory(processor); this.forceReleaseAdviceChain.forEach(proxyFactory::addAdvice); return (MessageGroupProcessor) proxyFactory.getProxy(getApplicationContext().getClassLoader()); } return processor; }
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { prepareIndexCreator(applicationContext); eventPublisher = applicationContext; if (mappingContext instanceof ApplicationEventPublisherAware) { ((ApplicationEventPublisherAware) mappingContext).setApplicationEventPublisher(eventPublisher); } projectionFactory.setBeanFactory(applicationContext); projectionFactory.setBeanClassLoader(applicationContext.getClassLoader()); }
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { prepareIndexCreator(applicationContext); eventPublisher = applicationContext; if (mappingContext instanceof ApplicationEventPublisherAware) { ((ApplicationEventPublisherAware) mappingContext).setApplicationEventPublisher(eventPublisher); } resourceLoader = applicationContext; projectionFactory.setBeanFactory(applicationContext); projectionFactory.setBeanClassLoader(applicationContext.getClassLoader()); }