Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
05c995cf
S
spring-framework
项目概览
爱吃血肠
/
spring-framework
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
spring-framework
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
05c995cf
编写于
10月 02, 2014
作者:
J
Juergen Hoeller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
DecoratingClassLoader and its subclasses register themselves as parallel capable on Java 7+
Issue: SPR-12285
上级
25d13ac4
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
67 addition
and
19 deletion
+67
-19
spring-context/src/main/java/org/springframework/context/support/ContextTypeMatchClassLoader.java
...ramework/context/support/ContextTypeMatchClassLoader.java
+13
-4
spring-context/src/main/java/org/springframework/instrument/classloading/SimpleInstrumentableClassLoader.java
...trument/classloading/SimpleInstrumentableClassLoader.java
+14
-8
spring-context/src/main/java/org/springframework/instrument/classloading/SimpleThrowawayClassLoader.java
...k/instrument/classloading/SimpleThrowawayClassLoader.java
+11
-2
spring-core/src/main/java/org/springframework/core/DecoratingClassLoader.java
.../java/org/springframework/core/DecoratingClassLoader.java
+18
-1
spring-core/src/main/java/org/springframework/core/OverridingClassLoader.java
.../java/org/springframework/core/OverridingClassLoader.java
+11
-4
未找到文件。
spring-context/src/main/java/org/springframework/context/support/ContextTypeMatchClassLoader.java
浏览文件 @
05c995cf
/*
* Copyright 2002-201
2
the original author or authors.
* Copyright 2002-201
4
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.
...
...
@@ -17,12 +17,13 @@
package
org.springframework.context.support
;
import
java.lang.reflect.Method
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.concurrent.ConcurrentHashMap
;
import
org.springframework.core.DecoratingClassLoader
;
import
org.springframework.core.OverridingClassLoader
;
import
org.springframework.core.SmartClassLoader
;
import
org.springframework.lang.UsesJava7
;
import
org.springframework.util.ReflectionUtils
;
/**
...
...
@@ -36,13 +37,21 @@ import org.springframework.util.ReflectionUtils;
* @see AbstractApplicationContext
* @see org.springframework.beans.factory.config.ConfigurableBeanFactory#setTempClassLoader
*/
@UsesJava7
class
ContextTypeMatchClassLoader
extends
DecoratingClassLoader
implements
SmartClassLoader
{
static
{
if
(
parallelCapableClassLoaderAvailable
)
{
ClassLoader
.
registerAsParallelCapable
();
}
}
private
static
Method
findLoadedClassMethod
;
static
{
try
{
findLoadedClassMethod
=
ClassLoader
.
class
.
getDeclaredMethod
(
"findLoadedClass"
,
new
Class
<?>[]
{
String
.
class
}
);
findLoadedClassMethod
=
ClassLoader
.
class
.
getDeclaredMethod
(
"findLoadedClass"
,
String
.
class
);
}
catch
(
NoSuchMethodException
ex
)
{
throw
new
IllegalStateException
(
"Invalid [java.lang.ClassLoader] class: no 'findLoadedClass' method defined!"
);
...
...
@@ -51,7 +60,7 @@ class ContextTypeMatchClassLoader extends DecoratingClassLoader implements Smart
/** Cache for byte array per class name */
private
final
Map
<
String
,
byte
[]>
bytesCache
=
new
HashMap
<
String
,
byte
[]>(
);
private
final
Map
<
String
,
byte
[]>
bytesCache
=
new
ConcurrentHashMap
<
String
,
byte
[]>(
256
);
public
ContextTypeMatchClassLoader
(
ClassLoader
parent
)
{
...
...
spring-context/src/main/java/org/springframework/instrument/classloading/SimpleInstrumentableClassLoader.java
浏览文件 @
05c995cf
/*
* Copyright 2002-201
2
the original author or authors.
* Copyright 2002-201
4
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.
...
...
@@ -19,6 +19,7 @@ package org.springframework.instrument.classloading;
import
java.lang.instrument.ClassFileTransformer
;
import
org.springframework.core.OverridingClassLoader
;
import
org.springframework.lang.UsesJava7
;
/**
* Simplistic implementation of an instrumentable {@code ClassLoader}.
...
...
@@ -29,16 +30,22 @@ import org.springframework.core.OverridingClassLoader;
* @author Costin Leau
* @since 2.0
*/
@UsesJava7
public
class
SimpleInstrumentableClassLoader
extends
OverridingClassLoader
{
static
{
if
(
parallelCapableClassLoaderAvailable
)
{
ClassLoader
.
registerAsParallelCapable
();
}
}
private
final
WeavingTransformer
weavingTransformer
;
/**
* Create a new {@code SimpleLoadTimeWeaver} for the given
* {@code ClassLoader}.
* @param parent the {@code ClassLoader} to build a simple
* instrumentable {@code ClassLoader} for
* Create a new SimpleInstrumentableClassLoader for the given ClassLoader.
* @param parent the ClassLoader to build an instrumentable ClassLoader for
*/
public
SimpleInstrumentableClassLoader
(
ClassLoader
parent
)
{
super
(
parent
);
...
...
@@ -47,9 +54,8 @@ public class SimpleInstrumentableClassLoader extends OverridingClassLoader {
/**
* Add a {@code ClassFileTransformer} to be applied by this
* {@code ClassLoader}.
* @param transformer the {@code ClassFileTransformer} to register
* Add a {@link ClassFileTransformer} to be applied by this ClassLoader.
* @param transformer the {@link ClassFileTransformer} to register
*/
public
void
addTransformer
(
ClassFileTransformer
transformer
)
{
this
.
weavingTransformer
.
addTransformer
(
transformer
);
...
...
spring-context/src/main/java/org/springframework/instrument/classloading/SimpleThrowawayClassLoader.java
浏览文件 @
05c995cf
/*
* Copyright 2002-20
06
the original author or authors.
* Copyright 2002-20
14
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.
...
...
@@ -17,6 +17,7 @@
package
org.springframework.instrument.classloading
;
import
org.springframework.core.OverridingClassLoader
;
import
org.springframework.lang.UsesJava7
;
/**
* ClassLoader that can be used to load classes without bringing them
...
...
@@ -26,10 +27,18 @@ import org.springframework.core.OverridingClassLoader;
* @author Rod Johnson
* @since 2.0
*/
@UsesJava7
public
class
SimpleThrowawayClassLoader
extends
OverridingClassLoader
{
static
{
if
(
parallelCapableClassLoaderAvailable
)
{
ClassLoader
.
registerAsParallelCapable
();
}
}
/**
* Create a new SimpleThrowawayClassLoader for the given
class l
oader.
* Create a new SimpleThrowawayClassLoader for the given
ClassL
oader.
* @param parent the ClassLoader to build a throwaway ClassLoader for
*/
public
SimpleThrowawayClassLoader
(
ClassLoader
parent
)
{
...
...
spring-core/src/main/java/org/springframework/core/DecoratingClassLoader.java
浏览文件 @
05c995cf
/*
* Copyright 2002-20
08
the original author or authors.
* Copyright 2002-20
14
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.
...
...
@@ -19,7 +19,9 @@ package org.springframework.core;
import
java.util.HashSet
;
import
java.util.Set
;
import
org.springframework.lang.UsesJava7
;
import
org.springframework.util.Assert
;
import
org.springframework.util.ClassUtils
;
/**
* Base class for decorating ClassLoaders such as {@link OverridingClassLoader}
...
...
@@ -30,8 +32,23 @@ import org.springframework.util.Assert;
* @author Rod Johnson
* @since 2.5.2
*/
@UsesJava7
public
abstract
class
DecoratingClassLoader
extends
ClassLoader
{
/**
* Java 7+ {@code ClassLoader.registerAsParallelCapable()} available?
* @since 4.1.2
*/
protected
static
final
boolean
parallelCapableClassLoaderAvailable
=
ClassUtils
.
hasMethod
(
ClassLoader
.
class
,
"registerAsParallelCapable"
);
static
{
if
(
parallelCapableClassLoaderAvailable
)
{
ClassLoader
.
registerAsParallelCapable
();
}
}
private
final
Set
<
String
>
excludedPackages
=
new
HashSet
<
String
>();
private
final
Set
<
String
>
excludedClasses
=
new
HashSet
<
String
>();
...
...
spring-core/src/main/java/org/springframework/core/OverridingClassLoader.java
浏览文件 @
05c995cf
/*
* Copyright 2002-201
2
the original author or authors.
* Copyright 2002-201
4
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.
...
...
@@ -19,6 +19,7 @@ package org.springframework.core;
import
java.io.IOException
;
import
java.io.InputStream
;
import
org.springframework.lang.UsesJava7
;
import
org.springframework.util.FileCopyUtils
;
/**
...
...
@@ -33,17 +34,23 @@ import org.springframework.util.FileCopyUtils;
* @author Juergen Hoeller
* @since 2.0.1
*/
@UsesJava7
public
class
OverridingClassLoader
extends
DecoratingClassLoader
{
/** Packages that are excluded by default */
public
static
final
String
[]
DEFAULT_EXCLUDED_PACKAGES
=
new
String
[]
{
"java."
,
"javax."
,
"sun."
,
"oracle."
};
public
static
final
String
[]
DEFAULT_EXCLUDED_PACKAGES
=
new
String
[]
{
"java."
,
"javax."
,
"sun."
,
"oracle."
};
private
static
final
String
CLASS_FILE_SUFFIX
=
".class"
;
static
{
if
(
parallelCapableClassLoaderAvailable
)
{
ClassLoader
.
registerAsParallelCapable
();
}
}
/**
* Create a new OverridingClassLoader for the given
class l
oader.
* Create a new OverridingClassLoader for the given
ClassL
oader.
* @param parent the ClassLoader to build an overriding ClassLoader for
*/
public
OverridingClassLoader
(
ClassLoader
parent
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录