1 55 56 package org.jboss.axis.configuration; 57 58 import org.jboss.axis.AxisProperties; 59 import org.jboss.axis.ConfigurationException; 60 import org.jboss.axis.EngineConfiguration; 61 import org.jboss.axis.EngineConfigurationFactory; 62 import org.jboss.axis.server.AxisServer; 63 import org.jboss.axis.utils.ClassUtils; 64 import org.jboss.axis.utils.Messages; 65 import org.jboss.logging.Logger; 66 67 import javax.servlet.ServletContext ; 68 import java.io.File ; 69 import java.io.InputStream ; 70 71 85 public class EngineConfigurationFactoryServlet 86 extends EngineConfigurationFactoryDefault 87 { 88 private static Logger log = Logger.getLogger(EngineConfigurationFactoryServlet.class.getName()); 89 90 private ServletContext ctx; 91 92 102 public static EngineConfigurationFactory newFactory(Object param) 103 { 104 116 return (param instanceof ServletContext ) 117 ? new EngineConfigurationFactoryServlet((ServletContext )param) 118 : null; 119 } 120 121 125 protected EngineConfigurationFactoryServlet(ServletContext ctx) 126 { 127 super(); 128 this.ctx = ctx; 129 } 130 131 136 public EngineConfiguration getServerEngineConfig() 137 { 138 return getServerEngineConfig(ctx); 139 } 140 141 147 private static 148 EngineConfiguration getServerEngineConfig(ServletContext ctx) 149 { 150 String configFile = 152 AxisProperties.getProperty(OPTION_SERVER_CONFIG_FILE); 153 if (configFile == null) 154 { 155 configFile = SERVER_CONFIG_FILE; 156 } 157 158 170 171 175 String appWebInfPath = "/WEB-INF"; 176 177 FileProvider config = null; 178 179 String realWebInfPath = ctx.getRealPath(appWebInfPath); 180 181 186 if (realWebInfPath == null || 187 !(new File (realWebInfPath, configFile)).exists()) 188 { 189 String name = appWebInfPath + "/" + configFile; 190 InputStream is = ctx.getResourceAsStream(name); 191 if (is != null) 192 { 193 config = new FileProvider(is); 196 } 197 198 if (config == null) 199 { 200 log.error(Messages.getMessage("servletEngineWebInfError03", 201 name)); 202 } 203 } 204 205 210 if (config == null && realWebInfPath != null) 211 { 212 try 213 { 214 config = new FileProvider(realWebInfPath, configFile); 215 } 216 catch (ConfigurationException e) 217 { 218 log.error(Messages.getMessage("servletEngineWebInfError00"), e); 219 } 220 } 221 222 225 if (config == null) 226 { 227 log.warn(Messages.getMessage("servletEngineWebInfWarn00")); 228 try 229 { 230 InputStream is = 231 ClassUtils.getResourceAsStream(AxisServer.class, 232 SERVER_CONFIG_FILE); 233 config = new FileProvider(is); 234 } 235 catch (Exception e) 236 { 237 log.error(Messages.getMessage("servletEngineWebInfError02"), e); 238 } 239 } 240 241 return config; 242 } 243 } 244 | Popular Tags |