org.springframework.context.ApplicationContext.getClassLoader()方法的使用及代码示例

x33g5p2x  于2022-01-15 转载在 其他  
字(9.1k)|赞(0)|评价(0)|浏览(170)

本文整理了Java中org.springframework.context.ApplicationContext.getClassLoader()方法的一些代码示例,展示了ApplicationContext.getClassLoader()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ApplicationContext.getClassLoader()方法的具体详情如下:
包路径:org.springframework.context.ApplicationContext
类名称:ApplicationContext
方法名:getClassLoader

ApplicationContext.getClassLoader介绍

暂无

代码示例

代码示例来源:origin: Red5/red5-server

/**
 * Return current thread's context classloader
 * 
 * @return Classloder context of current thread
 */
public ClassLoader getClassLoader() {
  return applicationContext.getClassLoader();
}

代码示例来源:origin: org.springframework.boot/spring-boot

public static boolean isJsr303Present(ApplicationContext applicationContext) {
  ClassLoader classLoader = applicationContext.getClassLoader();
  for (String validatorClass : VALIDATOR_CLASSES) {
    if (!ClassUtils.isPresent(validatorClass, classLoader)) {
      return false;
    }
  }
  return true;
}

代码示例来源:origin: spring-projects/spring-security

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;
  }
}

代码示例来源:origin: spring-projects/spring-framework

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;
}

代码示例来源:origin: spring-projects/spring-framework

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;
}

代码示例来源:origin: spring-projects/spring-framework

/**
 * 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);
}

代码示例来源:origin: org.springframework/spring-webmvc

/**
 * 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);
}

代码示例来源:origin: org.springframework/spring-webmvc

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;
}

代码示例来源:origin: spring-projects/spring-security

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;
}

代码示例来源:origin: Red5/red5-server

ClassLoader loader = common.getClassLoader();
Class<?> pluginClass;
String pluginMainMethod = null;

代码示例来源:origin: spring-projects/spring-data-mongodb

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());
}

代码示例来源:origin: spring-projects/spring-data-mongodb

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());
}

代码示例来源:origin: spring-projects/spring-framework

try {
  Method eclMethod = configuration.getClass().getMethod("externalClassLoader", ClassLoader.class);
  ReflectionUtils.invokeMethod(eclMethod, configuration, this.applicationContext.getClassLoader());

代码示例来源:origin: org.springframework/spring-context

try {
  Method eclMethod = configuration.getClass().getMethod("externalClassLoader", ClassLoader.class);
  ReflectionUtils.invokeMethod(eclMethod, configuration, this.applicationContext.getClassLoader());

代码示例来源:origin: org.springframework.security/spring-security-config

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;
  }
}

代码示例来源:origin: spring-projects/spring-security

.logout();
ClassLoader classLoader = this.context.getClassLoader();
List<AbstractHttpConfigurer> defaultHttpConfigurers =
    SpringFactoriesLoader.loadFactories(AbstractHttpConfigurer.class, classLoader);

代码示例来源:origin: spring-projects/spring-integration

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);
  }
}

代码示例来源:origin: spring-projects/spring-integration

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;
}

代码示例来源:origin: org.springframework.data/spring-data-mongodb

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());
}

代码示例来源:origin: org.springframework.data/spring-data-mongodb

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());
}

相关文章