1 55 56 package org.jboss.axis.server; 57 58 import org.jboss.axis.AxisEngine; 59 import org.jboss.axis.AxisFault; 60 import org.jboss.axis.AxisProperties; 61 import org.jboss.axis.EngineConfiguration; 62 import org.jboss.axis.utils.ClassUtils; 63 import org.jboss.axis.utils.Messages; 64 import org.jboss.logging.Logger; 65 66 import java.io.File ; 67 import java.util.Map ; 68 69 74 75 public class DefaultAxisServerFactory implements AxisServerFactory 76 { 77 private static Logger log = Logger.getLogger(DefaultAxisServerFactory.class.getName()); 78 79 108 public AxisServer getServer(Map environment) throws AxisFault 109 { 110 log.debug("Enter: DefaultAxisServerFactory::getServer"); 111 112 AxisServer ret = createServer(environment); 113 114 if (ret != null) 115 { 116 if (environment != null) 117 { 118 ret.setOptionDefault(AxisEngine.PROP_ATTACHMENT_DIR, 119 (String )environment.get(AxisEngine.ENV_ATTACHMENT_DIR)); 120 121 ret.setOptionDefault(AxisEngine.PROP_ATTACHMENT_DIR, 122 (String )environment.get(AxisEngine.ENV_SERVLET_REALPATH)); 123 } 124 125 String attachmentsdir = (String )ret.getOption(AxisEngine.PROP_ATTACHMENT_DIR); 126 127 if (attachmentsdir != null) 128 { 129 File attdirFile = new File (attachmentsdir); 130 if (!attdirFile.isDirectory()) 131 { 132 attdirFile.mkdirs(); 133 } 134 } 135 } 136 137 log.debug("Exit: DefaultAxisServerFactory::getServer"); 138 139 return ret; 140 } 141 142 148 private static AxisServer createServer(Map environment) 149 { 150 EngineConfiguration config = getEngineConfiguration(environment); 151 152 return (config == null) ? new AxisServer() : new AxisServer(config); 154 } 155 156 164 private static EngineConfiguration getEngineConfiguration(Map environment) 165 { 166 log.debug("Enter: DefaultAxisServerFactory::getEngineConfiguration"); 167 168 EngineConfiguration config = null; 169 170 if (environment != null) 171 { 172 try 173 { 174 config = (EngineConfiguration)environment.get(EngineConfiguration.PROPERTY_NAME); 175 } 176 catch (ClassCastException e) 177 { 178 log.warn(Messages.getMessage("engineConfigWrongClass00"), e); 179 } 181 } 182 183 if (config == null) 184 { 185 String configClass = AxisProperties.getProperty(AxisEngine.PROP_DEFAULT_CONFIG_CLASS); 188 if (configClass != null) 189 { 190 try 191 { 192 Class cls = ClassUtils.forName(configClass); 196 config = (EngineConfiguration)cls.newInstance(); 197 } 198 catch (ClassNotFoundException e) 199 { 200 log.warn(Messages.getMessage("engineConfigNoClass00", configClass), e); 201 } 203 catch (InstantiationException e) 204 { 205 log.warn(Messages.getMessage("engineConfigNoInstance00", configClass), e); 206 } 208 catch (IllegalAccessException e) 209 { 210 log.warn(Messages.getMessage("engineConfigIllegalAccess00", configClass), e); 211 } 213 catch (ClassCastException e) 214 { 215 log.warn(Messages.getMessage("engineConfigWrongClass01", configClass), e); 216 } 218 } 219 } 220 221 log.debug("Exit: DefaultAxisServerFactory::getEngineConfiguration"); 222 223 return config; 224 } 225 } 226 | Popular Tags |