1 5 6 package com.raptus.owxv3; 7 8 import java.util.Hashtable ; 9 10 import javax.servlet.*; 11 12 import org.apache.struts.action.ActionServlet; 13 import org.apache.struts.config.ModuleConfig; 14 15 44 public class StrutsOWXPlugIn implements org.apache.struts.action.PlugIn 45 { 46 49 public boolean isInitialized() { return (webinfdir != null && servlet != null); } 50 51 54 protected String webinfdir = null; 55 public String getWEBINFDir() { return webinfdir; } 56 public void setWEBINFDir(String wid) { this.webinfdir = wid; } 57 58 61 protected ActionServlet servlet = null; 62 public ActionServlet getServlet() { return servlet; } 63 public void setServlet(ActionServlet s) { this.servlet = s; } 64 65 68 protected ModuleConfig config = null; 69 public ModuleConfig getConfig() { return config; } 70 public void setConfig(ModuleConfig c) { this.config = c; } 71 72 75 protected VModuleManager vmm = null; 76 77 80 public void init(ActionServlet servlet, ModuleConfig config) 81 throws javax.servlet.ServletException 82 { 83 if(!isInitialized()) 84 { 85 setServlet(servlet); 87 setConfig(config); 88 89 ServletContext ctx = servlet.getServletContext(); 90 webinfdir = ctx.getRealPath("/WEB-INF/") + "/"; 91 92 String logFile = ctx.getInitParameter("owxlogfile"); 93 if(logFile == null) 94 throw new ServletException("Servlet context param <owxlogfile> is NULL."); 95 96 Hashtable initParams = new Hashtable (); 97 initParams.put("ConfigManager.HandlerClass", "com.raptus.owxv3.XMLConfigManager"); 102 103 initParams.put("ConfigManager.XMLConfigManager.FileName", getWEBINFDir() + 104 "owx-config.xml"); 105 106 initParams.put("LoggingManager.LogHandler", "com.raptus.owxv3.PlainLoggingManager"); 107 initParams.put("LoggingManager.PlainLoggingManager.LogFile", logFile); 108 109 LoggingManager logMgr = LoggingManager.getInstance(initParams); 110 if(logMgr == null) 111 throw new ServletException("LoggingManager cannot be initialized."); 112 113 ConfigManager cfgMgr = ConfigManager.getInstance(initParams); 114 117 LoggingManager.log("Preparing virtualhost ...", (Object ) this); 118 119 vmm = VModuleManager.getInstance(); 120 if(!vmm.initialize(this)) 121 throw new ServletException("VModuleManager cannot be initialized."); 122 123 LoggingManager.log("Virtualhost is now ready for requests", (Object ) this); 124 125 } 129 else 130 throw new ServletException("StrutsOWXPlugin is already initialized! Is this an error?"); 131 } 132 133 136 public void destroy() 137 { 138 webinfdir = null; 139 servlet = null; 140 } 141 142 } 143 144 | Popular Tags |