1 16 17 package org.apache.axis.server; 18 19 import org.apache.axis.AxisEngine; 20 import org.apache.axis.AxisFault; 21 import org.apache.axis.AxisProperties; 22 import org.apache.axis.EngineConfiguration; 23 import org.apache.axis.components.logger.LogFactory; 24 import org.apache.axis.utils.ClassUtils; 25 import org.apache.axis.utils.Messages; 26 import org.apache.commons.logging.Log; 27 28 import java.io.File ; 29 import java.util.Map ; 30 31 36 37 public class DefaultAxisServerFactory implements AxisServerFactory { 38 protected static Log log = 39 LogFactory.getLog(DefaultAxisServerFactory.class.getName()); 40 41 70 public AxisServer getServer(Map environment) throws AxisFault { 71 log.debug("Enter: DefaultAxisServerFactory::getServer"); 72 73 AxisServer ret = createServer(environment); 74 75 if (ret != null) { 76 if (environment != null) { 77 ret.setOptionDefault(AxisEngine.PROP_ATTACHMENT_DIR, 78 (String )environment.get(AxisEngine.ENV_ATTACHMENT_DIR)); 79 80 ret.setOptionDefault(AxisEngine.PROP_ATTACHMENT_DIR, 81 (String )environment.get(AxisEngine.ENV_SERVLET_REALPATH)); 82 } 83 84 String attachmentsdir = (String )ret.getOption(AxisEngine.PROP_ATTACHMENT_DIR); 85 86 if (attachmentsdir != null) { 87 File attdirFile = new File (attachmentsdir); 88 if (!attdirFile.isDirectory()) { 89 attdirFile.mkdirs(); 90 } 91 } 92 } 93 94 log.debug("Exit: DefaultAxisServerFactory::getServer"); 95 96 return ret; 97 } 98 99 105 private static AxisServer createServer(Map environment) { 106 EngineConfiguration config = getEngineConfiguration(environment); 107 108 return (config == null) ? new AxisServer() : new AxisServer(config); 110 } 111 112 120 private static EngineConfiguration getEngineConfiguration(Map environment) 121 { 122 log.debug("Enter: DefaultAxisServerFactory::getEngineConfiguration"); 123 124 EngineConfiguration config = null; 125 126 if (environment != null) { 127 try { 128 config = (EngineConfiguration)environment.get(EngineConfiguration.PROPERTY_NAME); 129 } catch (ClassCastException e) { 130 log.warn(Messages.getMessage("engineConfigWrongClass00"), e); 131 } 133 } 134 135 if (config == null) { 136 String configClass = AxisProperties.getProperty(AxisEngine.PROP_DEFAULT_CONFIG_CLASS); 139 if (configClass != null) { 140 try { 141 Class cls = ClassUtils.forName(configClass); 145 config = (EngineConfiguration)cls.newInstance(); 146 } catch (ClassNotFoundException e) { 147 log.warn(Messages.getMessage("engineConfigNoClass00", configClass), e); 148 } catch (InstantiationException e) { 150 log.warn(Messages.getMessage("engineConfigNoInstance00", configClass), e); 151 } catch (IllegalAccessException e) { 153 log.warn(Messages.getMessage("engineConfigIllegalAccess00", configClass), e); 154 } catch (ClassCastException e) { 156 log.warn(Messages.getMessage("engineConfigWrongClass01", configClass), e); 157 } 159 } 160 } 161 162 log.debug("Exit: DefaultAxisServerFactory::getEngineConfiguration"); 163 164 return config; 165 } 166 } 167 | Popular Tags |