FileDocCategorySizeDatePackage
DefaultAxisServerFactory.javaAPI DocApache Axis 1.46648Sat Apr 22 18:57:28 BST 2006org.apache.axis.server

DefaultAxisServerFactory

public class DefaultAxisServerFactory extends Object implements AxisServerFactory
Helper class for obtaining AxisServers. Default implementation.
author
Glen Daniels (gdaniels@apache.org)

Fields Summary
protected static Log
log
Constructors Summary
Methods Summary
private static AxisServercreateServer(java.util.Map environment)
Do the actual work of creating a new AxisServer, using the configuration, or using the default constructor if null is passed.

return
a shiny new AxisServer, ready for use.

        EngineConfiguration config = getEngineConfiguration(environment);

        // Return new AxisServer using the appropriate config
        return (config == null) ? new AxisServer() : new AxisServer(config);
    
private static org.apache.axis.EngineConfigurationgetEngineConfiguration(java.util.Map environment)
Look for EngineConfiguration, it is first of: a) EngineConfiguration instance, keyed to EngineConfiguration.PROPERTY_NAME in 'environment', or b) EngineConfiguration class name, keyed to AxisEngine.PROP_DEFAULT_CONFIG_CLASS in AxisProperties. Class is instantiated if found.

        log.debug("Enter: DefaultAxisServerFactory::getEngineConfiguration");

        EngineConfiguration config = null;

        if (environment != null) {
            try {
                config = (EngineConfiguration)environment.get(EngineConfiguration.PROPERTY_NAME);
            } catch (ClassCastException e) {
                log.warn(Messages.getMessage("engineConfigWrongClass00"), e);
                // Fall through
            }
        }

        if (config == null) {
            // A default engine configuration class may be set in a system
            // property. If so, try creating an engine configuration.
            String configClass = AxisProperties.getProperty(AxisEngine.PROP_DEFAULT_CONFIG_CLASS);
            if (configClass != null) {
                try {
                    // Got one - so try to make it (which means it had better have
                    // a default constructor - may make it possible later to pass
                    // in some kind of environmental parameters...)
                    Class cls = ClassUtils.forName(configClass);
                    config = (EngineConfiguration)cls.newInstance();
                } catch (ClassNotFoundException e) {
                    log.warn(Messages.getMessage("engineConfigNoClass00", configClass), e);
                    // Fall through
                } catch (InstantiationException e) {
                    log.warn(Messages.getMessage("engineConfigNoInstance00", configClass), e);
                    // Fall through
                } catch (IllegalAccessException e) {
                    log.warn(Messages.getMessage("engineConfigIllegalAccess00", configClass), e);
                    // Fall through
                } catch (ClassCastException e) {
                    log.warn(Messages.getMessage("engineConfigWrongClass01", configClass), e);
                    // Fall through
                }
            }
        }

        log.debug("Exit: DefaultAxisServerFactory::getEngineConfiguration");

        return config;
    
public AxisServergetServer(java.util.Map environment)
Get an AxisServer.

Factory obtains EngineConfiguration as first found of the following: a) EngineConfiguration instance, keyed to EngineConfiguration.PROPERTY_NAME in 'environment', or b) EngineConfiguration class name, keyed to AxisEngine.PROP_DEFAULT_CONFIG_CLASS in AxisProperties. Class is instantiated if found.

If an EngineConfiguration cannot be located, the default AxisServer constructor is used.

The AxisServer's option AxisEngine.PROP_ATTACHMENT_DIR is set to the (first found) value of either AxisEngine.ENV_ATTACHMENT_DIR or AxisEngine.ENV_SERVLET_REALPATH.

param
environment The following keys are used: AxisEngine.ENV_ATTACHMENT_DIR - Set as default value for Axis option AxisEngine.PROP_ATTACHMENT_DIR AxisEngine.ENV_SERVLET_REALPATH - Set as alternate default value for Axis option AxisEngine.PROP_ATTACHMENT_DIR EngineConfiguration.PROPERTY_NAME - Instance of EngineConfiguration, if not set then an attempt is made to retreive a class name from AxisEngine.PROP_CONFIG_CLASS


                                                                                                                                                                                                                                                                                               
          
        log.debug("Enter: DefaultAxisServerFactory::getServer");

        AxisServer ret = createServer(environment);

        if (ret != null) {
            if (environment != null) {
                ret.setOptionDefault(AxisEngine.PROP_ATTACHMENT_DIR,
                    (String)environment.get(AxisEngine.ENV_ATTACHMENT_DIR));

                ret.setOptionDefault(AxisEngine.PROP_ATTACHMENT_DIR,
                    (String)environment.get(AxisEngine.ENV_SERVLET_REALPATH));
            }

            String attachmentsdir = (String)ret.getOption(AxisEngine.PROP_ATTACHMENT_DIR);

            if (attachmentsdir != null) {
                File attdirFile = new File(attachmentsdir);
                if (!attdirFile.isDirectory()) {
                    attdirFile.mkdirs();
                }
            }
        }

        log.debug("Exit: DefaultAxisServerFactory::getServer");

        return ret;