日期:2014-05-18 浏览次数:20599 次
import java.io.File;
import javax.servlet.ServletException;
import org.apache.struts.action.ActionServlet;
import org.apache.struts.action.PlugIn;
import org.apache.struts.config.ModuleConfig;
import org.ds.util.XMLHandler;
public class GenXMLPlugin implements PlugIn {
private static XMLHandler xmlhandler;
public XMLHandler getXmlhandler() {
return xmlhandler;
}
public void setXmlhandler(XMLHandler xmlhandler) {
GenXMLPlugin.xmlhandler = xmlhandler;
}
public void destroy() {
System.out.println("in genXMlPlugin destory method");
}
public void init(ActionServlet arg0, ModuleConfig arg1) throws ServletException {
System.out.println("in genXMlPlugin init method");
File f1 = new File(arg0.getServletContext().getRealPath("js" + "/tree1.xml"));
File f2 = new File(arg0.getServletContext().getRealPath("js" + "/tree2.xml"));
File f3 = new File(arg0.getServletContext().getRealPath("js" + "/tree3.xml"));
File menu = new File(arg0.getServletContext().getRealPath("js" + "/menu.xml"));
if(xmlhandler!=null)
{
System.err.println("生成 3 棵树。。。。");
f1 = xmlhandler.createXMLFile(f1,new Long(1));
f2 = xmlhandler.createXMLFile(f2,new Long(2));
f3= xmlhandler.createXMLFile(f3,new Long(3));
menu = xmlhandler.createMenuFile(menu);
}
}
}
public class DelegatingSrvServletProxy extends GenericServlet {
private static final long serialVersionUID = 9175652453628779862L;
private String targetBean;
private Servlet proxy;
@Override
public void service(ServletRequest req, ServletResponse res) throws ServletException, IOException {
proxy.service(req, res);
}
@Override
public void init() throws ServletException {
this.targetBean = getServletName();
getServletBean(