FileDocCategorySizeDatePackage
AxisEngine.javaAPI DocApache Axis 1.417659Sat Apr 22 18:57:28 BST 2006org.apache.axis

AxisEngine

public abstract class AxisEngine extends org.apache.axis.handlers.BasicHandler
An AxisEngine is the base class for AxisClient and AxisServer. Handles common functionality like dealing with the handler/service registries and loading properties.
author
Glen Daniels (gdaniels@apache.org)
author
Glyn Normington (glyn@apache.org)

Fields Summary
protected static Log
log
The Log for all message logging.
public static final String
PROP_XML_DECL
public static final String
PROP_DEBUG_LEVEL
public static final String
PROP_DEBUG_FILE
public static final String
PROP_DOMULTIREFS
public static final String
PROP_DISABLE_PRETTY_XML
public static final String
PROP_ENABLE_NAMESPACE_PREFIX_OPTIMIZATION
public static final String
PROP_PASSWORD
public static final String
PROP_SYNC_CONFIG
public static final String
PROP_SEND_XSI
public static final String
PROP_ATTACHMENT_DIR
public static final String
PROP_ATTACHMENT_IMPLEMENTATION
public static final String
PROP_ATTACHMENT_CLEANUP
public static final String
PROP_DEFAULT_CONFIG_CLASS
public static final String
PROP_SOAP_VERSION
public static final String
PROP_SOAP_ALLOWED_VERSION
public static final String
PROP_TWOD_ARRAY_ENCODING
public static final String
PROP_XML_ENCODING
public static final String
PROP_XML_REUSE_SAX_PARSERS
public static final String
PROP_BYTE_BUFFER_BACKING
public static final String
PROP_BYTE_BUFFER_CACHE_INCREMENT
public static final String
PROP_BYTE_BUFFER_RESIDENT_MAX_SIZE
public static final String
PROP_BYTE_BUFFER_WORK_BUFFER_SIZE
public static final String
PROP_EMIT_ALL_TYPES
public static final String
PROP_DOTNET_SOAPENC_FIX
Set this property to 'true' when you want Axis to avoid soap encoded types to work around a .NET problem where it wont accept soap encoded types for a (soap encoded!) array.
public static final String
PROP_BP10_COMPLIANCE
Compliance with WS-I Basic Profile.
public static final String
DEFAULT_ATTACHMENT_IMPL
public static final String
ENV_ATTACHMENT_DIR
public static final String
ENV_SERVLET_REALPATH
public static final String
ENV_SERVLET_CONTEXT
private static final String
DEFAULT_ADMIN_PASSWORD
protected EngineConfiguration
config
Our go-to guy for configuration...
protected boolean
_hasSafePassword
Has the user changed the password yet? True if they have.
protected boolean
shouldSaveConfig
Should we save the engine config each time we modify it? True if we should.
protected transient org.apache.axis.utils.cache.ClassCache
classCache
Java class cache.
private org.apache.axis.session.Session
session
This engine's Session. This Session supports "application scope" in the Apache SOAP sense... if you have a service with "application scope", have it store things in this Session.
private ArrayList
actorURIs
What actor URIs hold for the entire engine? Find them here.
private static ThreadLocal
currentMessageContext
Thread local storage used for locating the active message context. This information is only valid for the lifetime of this request.
private static final String[]
BOOLEAN_OPTIONS
List of options which should be converted from Strings to Booleans automatically. Note that these options are common to all XML web services.
Constructors Summary
public AxisEngine(EngineConfiguration config)
Construct an AxisEngine using the specified engine configuration.

param
config the EngineConfiguration for this engine

        this.config = config;
        init();
    
Methods Summary
public voidaddActorURI(java.lang.String uri)
Add an actor by uri that will hold for the entire engine.

param
uri a String giving the uri of the actor to add

        actorURIs.add(uri);
    
public voidcleanup()
Cleanup routine removes application scoped objects. There is a small risk of this being called more than once so the cleanup should be designed to resist that event.

        super.cleanup();

        // Let any application-scoped service objects know that we're going
        // away...
        Enumeration keys = session.getKeys();
        if (keys != null) {
            while (keys.hasMoreElements()) {
                String key = (String)keys.nextElement();
                Object obj = session.get(key);
                if (obj != null && obj instanceof ServiceLifecycle) {
                    ((ServiceLifecycle)obj).destroy();
                }
                session.remove(key);
            }
        }
    
public java.util.ArrayListgetActorURIs()
Get a list of actor URIs that hold for the entire engine.

return
an ArrayList of all actor URIs as Strings

        return (ArrayList)actorURIs.clone();
    
public org.apache.axis.session.SessiongetApplicationSession()
Get the Session object associated with the application session.

return
a Session scoped to the application

        return session;
    
public org.apache.axis.utils.cache.ClassCachegetClassCache()
Get the ClassCache associated with this engine.

return
the class cache

        return classCache;
    
public abstract org.apache.axis.AxisEnginegetClientEngine()
Client engine access.

An AxisEngine may define another specific AxisEngine to be used by newly created Clients. For instance, a server may create an AxisClient and allow deployment to it. Then the server's services may access the AxisClient's deployed handlers and transports.

return
an AxisEngine that is the client engine

public EngineConfigurationgetConfig()
Get the EngineConfiguration used throughout this AxisEngine instance.

return
the engine configuration instance

        return config;
    
public static MessageContextgetCurrentMessageContext()
Get the active message context.

return
the current active message context

        return (MessageContext) currentMessageContext.get();
    
public HandlergetGlobalRequest()
Get the global request Handler.

return
the Handler used for global requests
throws
ConfigurationException

        return config.getGlobalRequest();
    
public HandlergetGlobalResponse()
Get the global respones Handler.

return
the Handler used for global responses
throws
ConfigurationException

        return config.getGlobalResponse();
    
public HandlergetHandler(java.lang.String name)
Get the Handler for a particular local name.

param
name the local name of the request type
return
the Handler for this request type
throws
AxisFault

        try {
            return config.getHandler(new QName(null, name));
        } catch (ConfigurationException e) {
            throw new AxisFault(e);
        }
    
public org.apache.axis.handlers.soap.SOAPServicegetService(java.lang.String name)
Get the SOAPService for a particular local name.

param
name the local name of the request type
return
the SOAPService for this request type
throws
AxisFault

        try {
            return config.getService(new QName(null, name));
        } catch (ConfigurationException e) {
            try {
                return config.getServiceByNamespaceURI(name);
            } catch (ConfigurationException e1) {
                throw new AxisFault(e);
            }
        }
    
public HandlergetTransport(java.lang.String name)
Get the Handler that implements the transport for a local name.

param
name the local name to fetch the transport for
return
a Handler for this local name
throws
AxisFault

        try {
            return config.getTransport(new QName(null, name));
        } catch (ConfigurationException e) {
            throw new AxisFault(e);
        }
    
public org.apache.axis.encoding.TypeMappingRegistrygetTypeMappingRegistry()
Get the TypeMappingRegistry for this axis engine.

return
the TypeMappingRegistry if possible, or null if there is any error resolving it

        TypeMappingRegistry tmr = null;
        try {
            tmr = config.getTypeMappingRegistry();
        } catch (ConfigurationException e) {
            log.error(Messages.getMessage("axisConfigurationException00"), e);
        }

        return tmr;
    
public booleanhasSafePassword()
Discover if this AxisEngine has a safe password.

return
true if it is safe, false otherwise

        return _hasSafePassword;
    
public voidinit()
Initialize the engine. Multiple calls will (may?) return the engine to the intialized state.

        if (log.isDebugEnabled()) {
            log.debug("Enter: AxisEngine::init");
        }

        // The SOAP/XSD stuff is in the default TypeMapping of the TypeMappingRegistry.
        //getTypeMappingRegistry().setParent(SOAPTypeMappingRegistry.getSingletonDelegate());

        try {
            config.configureEngine(this);
        } catch (Exception e) {
            throw new InternalException(e);
        }

        /*Set the default attachment implementation */
        setOptionDefault(PROP_ATTACHMENT_IMPLEMENTATION,
                         AxisProperties.getProperty("axis." + PROP_ATTACHMENT_IMPLEMENTATION  ));

        setOptionDefault(PROP_ATTACHMENT_IMPLEMENTATION, DEFAULT_ATTACHMENT_IMPL);

        // Check for the property "dotnetsoapencfix" which will turn
        // off soap encoded types to work around a bug in .NET where
        // it wont accept soap encoded array types.
        final Object dotnet = getOption(PROP_DOTNET_SOAPENC_FIX);
        if (JavaUtils.isTrue(dotnet)) {
            // This is a static property of the type mapping
            // that will ignore SOAPENC types when looking up
            // QNames of java types.
            TypeMappingImpl.dotnet_soapenc_bugfix = true;
        }

        if (log.isDebugEnabled()) {
            log.debug("Exit: AxisEngine::init");
        }

    
public static voidnormaliseOptions(Handler handler)
Normalise the engine's options.

Convert boolean options from String to Boolean and default any ommitted boolean options to TRUE. Default the admin. password.

param
handler the Handler to normalise; instances of AxisEngine get extra data normalised


                                                            
         
        // Convert boolean options to Booleans so we don't need to use
        // string comparisons.  Default is "true".

        for (int i = 0; i < BOOLEAN_OPTIONS.length; i++) {
            Object val = handler.getOption(BOOLEAN_OPTIONS[i]);
            if (val != null) {
                if (val instanceof Boolean)
                    continue;
                if (JavaUtils.isFalse(val)) {
                    handler.setOption(BOOLEAN_OPTIONS[i], Boolean.FALSE);
                    continue;
                }
            } else {
                if (!(handler instanceof AxisEngine))
                    continue;
            }
            // If it was null or not "false"...
            handler.setOption(BOOLEAN_OPTIONS[i], Boolean.TRUE);
        }

        // Deal with admin password's default value.
        if (handler instanceof AxisEngine) {
            AxisEngine engine = (AxisEngine)handler;
            if (!engine.setOptionDefault(PROP_PASSWORD,
                                         DEFAULT_ADMIN_PASSWORD)) {
                engine.setAdminPassword(
                        (String)engine.getOption(PROP_PASSWORD));
            }
        }
    
public voidrefreshGlobalOptions()
(Re-)load the global options from the registry.

throws
ConfigurationException

        Hashtable globalOptions = config.getGlobalOptions();
        if (globalOptions != null)
            setOptions(globalOptions);

        normaliseOptions(this);

        // fixme: If we change actorURIs to List, this copy constructor can
        //        go away...
        actorURIs = new ArrayList(config.getRoles());
    
public voidremoveActorURI(java.lang.String uri)
Remove an actor by uri that will hold for the entire engine.

param
uri a String giving the uri of the actor to remove

        actorURIs.remove(uri);
    
public voidsaveConfiguration()
Write out our engine configuration.

        if (!shouldSaveConfig)
            return;

        try {
            config.writeEngineConfig(this);
        } catch (Exception e) {
            log.error(Messages.getMessage("saveConfigFail00"), e);
        }
    
public voidsetAdminPassword(java.lang.String pw)
Set the administration password.

param
pw the literal value of the password as a String

        setOption(PROP_PASSWORD, pw);
        _hasSafePassword = true;
        saveConfiguration();
    
protected static voidsetCurrentMessageContext(MessageContext mc)
Set the active message context.

param
mc - the new active message context.


                      
         
        currentMessageContext.set(mc);
    
public voidsetShouldSaveConfig(boolean shouldSaveConfig)
Set the flag that controls if the configuration should be saved.

param
shouldSaveConfig true if the configuration should be changed, false otherwise

        this.shouldSaveConfig = shouldSaveConfig;