本文整理汇总了Java中com.alibaba.dubbo.common.utils.ClassHelper类的典型用法代码示例。如果您正苦于以下问题:Java ClassHelper类的具体用法?Java ClassHelper怎么用?Java ClassHelper使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ClassHelper类属于com.alibaba.dubbo.common.utils包,在下文中一共展示了ClassHelper类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkDuplicate
import com.alibaba.dubbo.common.utils.ClassHelper; //导入依赖的package包/类
public static void checkDuplicate(String path, boolean failOnError) {
try {
// 在ClassPath搜文件
Enumeration<URL> urls = ClassHelper.getCallerClassLoader(Version.class).getResources(path);
Set<String> files = new HashSet<String>();
while (urls.hasMoreElements()) {
URL url = urls.nextElement();
if (url != null) {
String file = url.getFile();
if (file != null && file.length() > 0) {
files.add(file);
}
}
}
// 如果有多个,就表示重复
if (files.size() > 1) {
String error = "Duplicate class " + path + " in " + files.size() + " jar " + files;
if (failOnError) {
throw new IllegalStateException(error);
} else {
logger.error(error);
}
}
} catch (Throwable e) { // 防御性容错
logger.error(e.getMessage(), e);
}
}
示例2: findClass
import com.alibaba.dubbo.common.utils.ClassHelper; //导入依赖的package包/类
@Override
protected Class<?> findClass(final String qualifiedClassName) throws ClassNotFoundException {
JavaFileObject file = classes.get(qualifiedClassName);
if (file != null) {
byte[] bytes = ((JavaFileObjectImpl) file).getByteCode();
return defineClass(qualifiedClassName, bytes, 0, bytes.length);
}
try {
return ClassHelper.forNameWithCallerClassLoader(qualifiedClassName, getClass());
} catch (ClassNotFoundException nf) {
return super.findClass(qualifiedClassName);
}
}
示例3: getProxy
import com.alibaba.dubbo.common.utils.ClassHelper; //导入依赖的package包/类
/**
* Get proxy.
*
* @param ics interface class array.
* @return Proxy instance.
*/
public static Proxy getProxy(Class<?>... ics)
{
//Override
//return getProxy(ClassHelper.getCallerClassLoader(Proxy.class), ics);
return getProxy(ClassHelper.getCallerClassLoader(ics[0]), ics);
}
示例4: checkDuplicate
import com.alibaba.dubbo.common.utils.ClassHelper; //导入依赖的package包/类
public static void checkDuplicate(String path, boolean failOnError) {
try {
// 在ClassPath搜文件
Enumeration<URL> urls = ClassHelper.getCallerClassLoader(Version.class).getResources(path);
Set<String> files = new HashSet<String>();
while (urls.hasMoreElements()) {
URL url = urls.nextElement();
if (url != null) {
String file = url.getFile();
if (file != null && file.length() > 0) {
files.add(file);
}
}
}
// 如果有多个,就表示重复
if (files.size() > 1) {
String error = "Duplicate class " + path + " in " + files.size() + " jar " + files;
if (failOnError) {
throw new IllegalStateException(error);
} else {
logger.error(error);
}
}
} catch (Throwable e) { // 防御性容错
logger.error(e.getMessage(), e);
}
}
示例5: checkDuplicate
import com.alibaba.dubbo.common.utils.ClassHelper; //导入依赖的package包/类
public static void checkDuplicate(String path, boolean failOnError) {
try {
// 在ClassPath搜文件
Enumeration<URL> urls = ClassHelper.getCallerClassLoader(Version.class).getResources(path);
Set<String> files = new HashSet<String>();
while (urls.hasMoreElements()) {
URL url = urls.nextElement();
if (url != null) {
String file = url.getFile();
if (file != null && file.length() > 0) {
files.add(file);
}
}
}
// 如果有多个,就表示重复
if (files.size() > 1) {
String error = "Duplicate class " + path + " in " + files.size() + " jar " + files;
if (failOnError) {
throw new IllegalStateException(error);
} else {
log.error(error);
}
}
} catch (Throwable e) { // 防御性容错
log.error(e.getMessage(), e);
}
}
示例6: CompactedObjectInputStream
import com.alibaba.dubbo.common.utils.ClassHelper; //导入依赖的package包/类
public CompactedObjectInputStream(InputStream in, ClassLoader cl) throws IOException
{
super(in);
mClassLoader = cl == null ? ClassHelper.getClassLoader() : cl;
}