com.geese.plugin.excel.ExcelOperationsProxyFactory Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of easy-excel Show documentation
Show all versions of easy-excel Show documentation
像SQL一样操作Excel,简化Excel的读写操作
The newest version!
package com.geese.plugin.excel;
import java.lang.reflect.Proxy;
/**
* Excel操作接口代理工厂(单例模式)
*/
public class ExcelOperationsProxyFactory {
private static ExcelOperations proxy;
public static ExcelOperations getProxy() {
if (null != proxy) {
return proxy;
}
synchronized (ExcelOperationsProxyFactory.class) {
if (null == proxy) {
synchronized (ExcelOperations.class) {
ExcelTemplate excelTemplate = new ExcelTemplate();
ExcelOperationsProxy handler = new ExcelOperationsProxy(excelTemplate);
Class extends ExcelTemplate> targetClass = excelTemplate.getClass();
ClassLoader loader = targetClass.getClassLoader();
Class>[] interfaces = targetClass.getInterfaces();
proxy = (ExcelOperations) Proxy.newProxyInstance(loader, interfaces, handler);
}
}
return proxy;
}
}
}