1.ExcelManagerFactory
package com.factory;
public class ExcelManagerFactory {
private static String key = "key";
private ExcelManagerFactory() {
}
private static ExcelManagerIf instance = null;
public static ExcelManagerIf getInstance(){
if(instance == null){
synchronized(key){
if(instance == null){
instance = new ExcelManagerImpl();
}
}
}
return instance;
}
}
2.声明一个接口
package com.factory;
import java.io.InputStream;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.gpdi.orm.object.ScoreRecordDetail;
public interface ExcelManagerIf {
public boolean export(HttpServletResponse response, List<ScoreRecordDetail> list,LinkedHashMap hashMap);
/********************************************************************************************************/
public boolean export1(HttpServletResponse response,List list,LinkedHashMap hashMap);
/********************************************************************************************************/
}
3.实现接口的类
package com.factory;
import java.io.IOException;
public class ExcelManagerImpl implements ExcelManagerIf
{
public boolean export1(HttpServletResponse response, List list,LinkedHashMap hashMap)
{
//实现具体功能的代码实现
}
}
4.调用
HttpServletResponse response=null;
LinkedHashMap hm = new LinkedHashMap();
List list = Object.getList();
ExcelManagerIf eem = ExcelManagerFactory.getInstance();
/******************************************************************/
eem.export(response, list,hm);