下面列出了org.springframework.util.ClassUtils#getDefaultClassLoader ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* Factory method for compiler instances. The returned SpelCompiler will
* attach a class loader as the child of the given class loader and this
* child will be used to load compiled expressions.
* @param classLoader the ClassLoader to use as the basis for compilation
* @return a corresponding SpelCompiler instance
*/
public static SpelCompiler getCompiler(@Nullable ClassLoader classLoader) {
ClassLoader clToUse = (classLoader != null ? classLoader : ClassUtils.getDefaultClassLoader());
synchronized (compilers) {
SpelCompiler compiler = compilers.get(clToUse);
if (compiler == null) {
compiler = new SpelCompiler(clToUse);
compilers.put(clToUse, compiler);
}
return compiler;
}
}
/**
* Create a new {@code ClassPathResource} for {@code ClassLoader} usage.
* A leading slash will be removed, as the ClassLoader resource access
* methods will not accept it.
* @param path the absolute path within the classpath
* @param classLoader the class loader to load the resource with,
* or {@code null} for the thread context class loader
* @see ClassLoader#getResourceAsStream(String)
*/
public ClassPathResource(String path, @Nullable ClassLoader classLoader) {
Assert.notNull(path, "Path must not be null");
String pathToUse = StringUtils.cleanPath(path);
if (pathToUse.startsWith("/")) {
pathToUse = pathToUse.substring(1);
}
this.path = pathToUse;
this.classLoader = (classLoader != null ? classLoader : ClassUtils.getDefaultClassLoader());
}
/**
* Create a new InstrumentationLoadTimeWeaver for the default ClassLoader.
*/
public InstrumentationLoadTimeWeaver() {
this(ClassUtils.getDefaultClassLoader());
}
@Override
public ClassLoader getClassLoader() {
return ClassUtils.getDefaultClassLoader();
}
public ServerTraceMetadataLoaderService(CommonLoggerFactory commonLoggerFactory) {
this(ClassUtils.getDefaultClassLoader(), Collections.singletonList(DEFAULT_TYPE_PROVIDER_PATH), commonLoggerFactory);
}
/**
* Create a new InstrumentationLoadTimeWeaver for the default ClassLoader.
*/
public InstrumentationLoadTimeWeaver() {
this(ClassUtils.getDefaultClassLoader());
}
/**
* This implementation returns the default ClassLoader.
* @see org.springframework.util.ClassUtils#getDefaultClassLoader()
*/
@Override
public ClassLoader getClassLoader() {
return ClassUtils.getDefaultClassLoader();
}
@Override
@Nullable
public ClassLoader getClassLoader() {
return ClassUtils.getDefaultClassLoader();
}
@Override
public ClassLoader getClassLoader() {
return ClassUtils.getDefaultClassLoader();
}
@Override
public ClassLoader getClassLoader() {
return ClassUtils.getDefaultClassLoader();
}
@Override
public void setBeanClassLoader(@Nullable ClassLoader beanClassLoader) {
this.beanClassLoader = (beanClassLoader != null ? beanClassLoader : ClassUtils.getDefaultClassLoader());
}
/**
* Create a StandardTypeLocator for the default ClassLoader
* (typically, the thread context ClassLoader).
*/
public StandardTypeLocator() {
this(ClassUtils.getDefaultClassLoader());
}
/**
* Create a new URIEditor, using the given ClassLoader to resolve
* "classpath:" locations into physical resource URLs.
* @param classLoader the ClassLoader to use for resolving "classpath:" locations
* (may be {@code null} to indicate the default ClassLoader)
* @param encode indicates whether Strings will be encoded or not
*/
public URIEditor(ClassLoader classLoader, boolean encode) {
this.classLoader = (classLoader != null ? classLoader : ClassUtils.getDefaultClassLoader());
this.encode = encode;
}
/**
* Create a StandardTypeLocator for the default ClassLoader
* (typically, the thread context ClassLoader).
*/
public StandardTypeLocator() {
this(ClassUtils.getDefaultClassLoader());
}
/**
* Create a new ReflectiveLoadTimeWeaver for the current context class
* loader, <i>which needs to support the required weaving methods</i>.
*/
public ReflectiveLoadTimeWeaver() {
this(ClassUtils.getDefaultClassLoader());
}
/**
* Create a default ClassEditor, using the given ClassLoader.
* @param classLoader the ClassLoader to use
* (or {@code null} for the thread context ClassLoader)
*/
public ClassEditor(ClassLoader classLoader) {
this.classLoader = (classLoader != null ? classLoader : ClassUtils.getDefaultClassLoader());
}
/**
* Create a new {@code SimpleLoadTimeWeaver} for the current context
* {@code ClassLoader}.
* @see SimpleInstrumentableClassLoader
*/
public SimpleLoadTimeWeaver() {
this.classLoader = new SimpleInstrumentableClassLoader(ClassUtils.getDefaultClassLoader());
}
/**
* Create a new URIEditor, using the given ClassLoader to resolve
* "classpath:" locations into physical resource URLs.
* @param classLoader the ClassLoader to use for resolving "classpath:" locations
* (may be {@code null} to indicate the default ClassLoader)
*/
public URIEditor(ClassLoader classLoader) {
this.classLoader = (classLoader != null ? classLoader : ClassUtils.getDefaultClassLoader());
this.encode = true;
}
/**
* Create a new instance of the {@link WebSphereLoadTimeWeaver} class using
* the default {@link ClassLoader class loader}.
* @see org.springframework.util.ClassUtils#getDefaultClassLoader()
*/
public WebSphereLoadTimeWeaver() {
this(ClassUtils.getDefaultClassLoader());
}
/**
* Create a new {@code DefaultNamespaceHandlerResolver} using the
* supplied mapping file location.
* @param classLoader the {@link ClassLoader} instance used to load mapping resources
* may be {@code null}, in which case the thread context ClassLoader will be used)
* @param handlerMappingsLocation the mapping file location
*/
public DefaultNamespaceHandlerResolver(ClassLoader classLoader, String handlerMappingsLocation) {
Assert.notNull(handlerMappingsLocation, "Handler mappings location must not be null");
this.classLoader = (classLoader != null ? classLoader : ClassUtils.getDefaultClassLoader());
this.handlerMappingsLocation = handlerMappingsLocation;
}