1 16 17 package org.apache.axis.configuration; 18 19 import org.apache.axis.AxisProperties; 20 import org.apache.axis.ConfigurationException; 21 import org.apache.axis.EngineConfiguration; 22 import org.apache.axis.EngineConfigurationFactory; 23 import org.apache.axis.components.logger.LogFactory; 24 import org.apache.axis.server.AxisServer; 25 import org.apache.axis.utils.ClassUtils; 26 import org.apache.axis.utils.Messages; 27 import org.apache.commons.logging.Log; 28 29 import javax.servlet.ServletConfig ; 30 import javax.servlet.ServletContext ; 31 import java.io.File ; 32 import java.io.InputStream ; 33 34 48 public class EngineConfigurationFactoryServlet 49 extends EngineConfigurationFactoryDefault 50 { 51 protected static Log log = 52 LogFactory.getLog(EngineConfigurationFactoryServlet.class.getName()); 53 54 private ServletConfig cfg; 55 56 66 public static EngineConfigurationFactory newFactory(Object param) { 67 79 return (param instanceof ServletConfig ) 80 ? new EngineConfigurationFactoryServlet((ServletConfig )param) 81 : null; 82 } 83 84 88 protected EngineConfigurationFactoryServlet(ServletConfig conf) { 89 super(); 90 this.cfg = conf; 91 } 92 93 98 public EngineConfiguration getServerEngineConfig() { 99 return getServerEngineConfig(cfg); 100 } 101 102 108 private static 109 EngineConfiguration getServerEngineConfig(ServletConfig cfg) { 110 111 ServletContext ctx = cfg.getServletContext(); 112 113 String configFile = cfg.getInitParameter(OPTION_SERVER_CONFIG_FILE); 115 if (configFile == null) 116 configFile = 117 AxisProperties.getProperty(OPTION_SERVER_CONFIG_FILE); 118 if (configFile == null) { 119 configFile = SERVER_CONFIG_FILE; 120 } 121 122 134 135 139 String appWebInfPath = "/WEB-INF"; 140 141 FileProvider config = null; 142 143 String realWebInfPath = ctx.getRealPath(appWebInfPath); 144 145 150 if (realWebInfPath == null || 151 !(new File (realWebInfPath, configFile)).exists()) 152 { 153 String name = appWebInfPath + "/" + configFile; 154 InputStream is = ctx.getResourceAsStream(name); 155 if (is != null) { 156 config = new FileProvider(is); 159 } 160 161 if (config == null) { 162 log.error(Messages.getMessage("servletEngineWebInfError03", 163 name)); 164 } 165 } 166 167 172 if (config == null && realWebInfPath != null) { 173 try { 174 config = new FileProvider(realWebInfPath, configFile); 175 } catch (ConfigurationException e) { 176 log.error(Messages.getMessage("servletEngineWebInfError00"), e); 177 } 178 } 179 180 183 if (config == null) { 184 log.warn(Messages.getMessage("servletEngineWebInfWarn00")); 185 try { 186 InputStream is = 187 ClassUtils.getResourceAsStream(AxisServer.class, 188 SERVER_CONFIG_FILE); 189 config = new FileProvider(is); 190 } catch (Exception e) { 191 log.error(Messages.getMessage("servletEngineWebInfError02"), e); 192 } 193 } 194 195 return config; 196 } 197 } 198 | Popular Tags |