-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #275 from z529192557/develop-for-20200115-issue-260
Develop for 20200115 issue 260
- Loading branch information
Showing
6 changed files
with
76 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
...ore/src/main/java/com/alibaba/jvm/sandbox/core/classloader/BusinessClassLoaderHolder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package com.alibaba.jvm.sandbox.core.classloader; | ||
|
||
/** | ||
* @author zhuangpeng | ||
* @since 2020/1/15 | ||
*/ | ||
public class BusinessClassLoaderHolder { | ||
|
||
private static final ThreadLocal<DelegateBizClassLoader> holder = new ThreadLocal<DelegateBizClassLoader>(); | ||
|
||
public static void setBussinessClassLoader(ClassLoader classLoader){ | ||
if(null == classLoader){ | ||
return; | ||
} | ||
DelegateBizClassLoader delegateBizClassLoader = new DelegateBizClassLoader(classLoader); | ||
holder.set(delegateBizClassLoader); | ||
} | ||
|
||
|
||
public static void removeBussinessClassLoader(){ | ||
holder.remove(); | ||
} | ||
|
||
public static DelegateBizClassLoader getBussinessClassLoader(){ | ||
|
||
return holder.get(); | ||
} | ||
|
||
public static class DelegateBizClassLoader extends ClassLoader{ | ||
public DelegateBizClassLoader(ClassLoader parent){ | ||
super(parent); | ||
} | ||
|
||
@Override | ||
public Class<?> loadClass(final String javaClassName, final boolean resolve) throws ClassNotFoundException { | ||
return super.loadClass(javaClassName,resolve); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters