Optimize class detection by sharing the ClassLoader
Issue: SPR-17083
This commit is contained in:
@@ -50,11 +50,15 @@ public class CachingConfigurationSelector extends AdviceModeImportSelector<Enabl
|
||||
"org.springframework.cache.aspectj.AspectJJCacheConfiguration";
|
||||
|
||||
|
||||
private static final boolean jsr107Present = ClassUtils.isPresent(
|
||||
"javax.cache.Cache", CachingConfigurationSelector.class.getClassLoader());
|
||||
private static final boolean jsr107Present;
|
||||
|
||||
private static final boolean jcacheImplPresent = ClassUtils.isPresent(
|
||||
PROXY_JCACHE_CONFIGURATION_CLASS, CachingConfigurationSelector.class.getClassLoader());
|
||||
private static final boolean jcacheImplPresent;
|
||||
|
||||
static {
|
||||
ClassLoader classLoader = CachingConfigurationSelector.class.getClassLoader();
|
||||
jsr107Present = ClassUtils.isPresent("javax.cache.Cache", classLoader);
|
||||
jcacheImplPresent = ClassUtils.isPresent(PROXY_JCACHE_CONFIGURATION_CLASS, classLoader);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -61,12 +61,16 @@ class AnnotationDrivenCacheBeanDefinitionParser implements BeanDefinitionParser
|
||||
private static final String JCACHE_ASPECT_CLASS_NAME =
|
||||
"org.springframework.cache.aspectj.JCacheCacheAspect";
|
||||
|
||||
private static final boolean jsr107Present = ClassUtils.isPresent(
|
||||
"javax.cache.Cache", AnnotationDrivenCacheBeanDefinitionParser.class.getClassLoader());
|
||||
private static final boolean jsr107Present;
|
||||
|
||||
private static final boolean jcacheImplPresent = ClassUtils.isPresent(
|
||||
"org.springframework.cache.jcache.interceptor.DefaultJCacheOperationSource",
|
||||
AnnotationDrivenCacheBeanDefinitionParser.class.getClassLoader());
|
||||
private static final boolean jcacheImplPresent;
|
||||
|
||||
static {
|
||||
ClassLoader classLoader = AnnotationDrivenCacheBeanDefinitionParser.class.getClassLoader();
|
||||
jsr107Present = ClassUtils.isPresent("javax.cache.Cache", classLoader);
|
||||
jcacheImplPresent = ClassUtils.isPresent(
|
||||
"org.springframework.cache.jcache.interceptor.DefaultJCacheOperationSource", classLoader);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -118,12 +118,16 @@ public abstract class AnnotationConfigUtils {
|
||||
public static final String EVENT_LISTENER_FACTORY_BEAN_NAME =
|
||||
"org.springframework.context.event.internalEventListenerFactory";
|
||||
|
||||
private static final boolean jsr250Present =
|
||||
ClassUtils.isPresent("javax.annotation.Resource", AnnotationConfigUtils.class.getClassLoader());
|
||||
private static final boolean jsr250Present;
|
||||
|
||||
private static final boolean jpaPresent =
|
||||
ClassUtils.isPresent("javax.persistence.EntityManagerFactory", AnnotationConfigUtils.class.getClassLoader()) &&
|
||||
ClassUtils.isPresent(PERSISTENCE_ANNOTATION_PROCESSOR_CLASS_NAME, AnnotationConfigUtils.class.getClassLoader());
|
||||
private static final boolean jpaPresent;
|
||||
|
||||
static {
|
||||
ClassLoader classLoader = AnnotationConfigUtils.class.getClassLoader();
|
||||
jsr250Present = ClassUtils.isPresent("javax.annotation.Resource", classLoader);
|
||||
jpaPresent = ClassUtils.isPresent("javax.persistence.EntityManagerFactory", classLoader) &&
|
||||
ClassUtils.isPresent(PERSISTENCE_ANNOTATION_PROCESSOR_CLASS_NAME, classLoader);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
* Copyright 2002-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -49,11 +49,15 @@ class MBeanServerBeanDefinitionParser extends AbstractBeanDefinitionParser {
|
||||
private static final String AGENT_ID_ATTRIBUTE = "agent-id";
|
||||
|
||||
|
||||
private static final boolean weblogicPresent = ClassUtils.isPresent(
|
||||
"weblogic.management.Helper", MBeanServerBeanDefinitionParser.class.getClassLoader());
|
||||
private static final boolean weblogicPresent;
|
||||
|
||||
private static final boolean webspherePresent = ClassUtils.isPresent(
|
||||
"com.ibm.websphere.management.AdminServiceFactory", MBeanServerBeanDefinitionParser.class.getClassLoader());
|
||||
private static final boolean webspherePresent;
|
||||
|
||||
static {
|
||||
ClassLoader classLoader = MBeanServerBeanDefinitionParser.class.getClassLoader();
|
||||
weblogicPresent = ClassUtils.isPresent("weblogic.management.Helper", classLoader);
|
||||
webspherePresent = ClassUtils.isPresent("com.ibm.websphere.management.AdminServiceFactory", classLoader);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
|
||||
@@ -47,11 +47,15 @@ import org.springframework.util.StringValueResolver;
|
||||
*/
|
||||
public class DefaultFormattingConversionService extends FormattingConversionService {
|
||||
|
||||
private static final boolean jsr354Present = ClassUtils.isPresent(
|
||||
"javax.money.MonetaryAmount", DefaultFormattingConversionService.class.getClassLoader());
|
||||
private static final boolean jsr354Present;
|
||||
|
||||
private static final boolean jodaTimePresent = ClassUtils.isPresent(
|
||||
"org.joda.time.LocalDate", DefaultFormattingConversionService.class.getClassLoader());
|
||||
private static final boolean jodaTimePresent;
|
||||
|
||||
static {
|
||||
ClassLoader classLoader = DefaultFormattingConversionService.class.getClassLoader();
|
||||
jsr354Present = ClassUtils.isPresent("javax.money.MonetaryAmount", classLoader);
|
||||
jodaTimePresent = ClassUtils.isPresent("org.joda.time.LocalDate", classLoader);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user