FileDocCategorySizeDatePackage
WSDDDeployableItem.javaAPI DocApache Axis 1.49841Sat Apr 22 18:57:28 BST 2006org.apache.axis.deployment.wsdd

WSDDDeployableItem

public abstract class WSDDDeployableItem extends WSDDElement
WSDD DeployableItem complexType

Fields Summary
public static final int
SCOPE_PER_ACCESS
public static final int
SCOPE_PER_REQUEST
public static final int
SCOPE_SINGLETON
public static String[]
scopeStrings
protected static Log
log
protected org.apache.axis.utils.LockableHashtable
parameters
Our parameters
protected QName
qname
Our name
protected QName
type
Our type
protected int
scope
Scope for this item (default is singleton)
protected org.apache.axis.Handler
singletonInstance
Placeholder for hanging on to singleton object
Constructors Summary
public WSDDDeployableItem()
Default constructor


            
     
    
    
public WSDDDeployableItem(Element e)

param
e (Element) XXX
throws
WSDDException XXX

        super(e);
        
        String name = e.getAttribute(ATTR_NAME);
        if (name != null && !name.equals("")) {
//            qname = XMLUtils.getQNameFromString(name, e);
            qname = new QName("", name);
        }
        
        String typeStr = e.getAttribute(ATTR_TYPE);
        if (typeStr != null && !typeStr.equals("")) {
            type = XMLUtils.getQNameFromString(typeStr, e);
        }

        // Figure out our scope - right now if a non-recognized scope
        // attribute appears, we will ignore it and use the default
        // scope.  Is this right, or should we throw an error?
        String scopeStr = e.getAttribute(JavaProvider.OPTION_SCOPE);
        if (scopeStr != null) {
            for (int i = 0; i < scopeStrings.length; i++) {
                if (scopeStr.equals(scopeStrings[i])) {
                    scope = i;
                    break;
                }
            }
        }

        parameters = new LockableHashtable();
        
        // Load up our params
        Element [] paramElements = getChildElements(e, ELEM_WSDD_PARAM);
        for (int i = 0; i < paramElements.length; i++) {
            Element param = paramElements[i];
            String pname = param.getAttribute(ATTR_NAME);
            String value = param.getAttribute(ATTR_VALUE);
            String locked = param.getAttribute(ATTR_LOCKED);
            parameters.put(pname, value, JavaUtils.isTrueExplicitly(locked));
        }
    
Methods Summary
java.lang.ObjectcreateInstance(java.lang.Class _class)

param
_class XXX
return
XXX

        return _class.newInstance();
    
public final org.apache.axis.HandlergetInstance(org.apache.axis.EngineConfiguration registry)

param
registry XXX
return
XXX
throws
ConfigurationException XXX

        if (scope == SCOPE_SINGLETON) {
             synchronized (this) {
                if (singletonInstance == null)
                    singletonInstance = getNewInstance(registry);
            }
            return singletonInstance;
        }
        
        return getNewInstance(registry);
    
public java.lang.ClassgetJavaClass()

return
XXX
throws
ClassNotFoundException XXX

        QName type = getType();
        if (type != null &&
                URI_WSDD_JAVA.equals(type.getNamespaceURI())) {
            return ClassUtils.forName(type.getLocalPart());
        }
        return null;
    
private org.apache.axis.HandlergetNewInstance(org.apache.axis.EngineConfiguration registry)

        QName type = getType();
        if (type == null ||
            WSDDConstants.URI_WSDD_JAVA.equals(type.getNamespaceURI())) {
            return makeNewInstance(registry);
        } else {
            return registry.getHandler(type);
        }
    
public java.lang.StringgetParameter(java.lang.String name)
Get the value of one of our parameters

        if (name == null || parameters == null) {
            return null;
        }
        
        return (String)parameters.get(name);
    
public org.apache.axis.utils.LockableHashtablegetParametersTable()
Returns the config parameters as a hashtable (lockable)

return
XXX

        return parameters;
    
public javax.xml.namespace.QNamegetQName()

return
XXX

        return qname;
    
public javax.xml.namespace.QNamegetType()

return
XXX

        return type;
    
protected org.apache.axis.HandlermakeNewInstance(org.apache.axis.EngineConfiguration registry)
Creates a new instance of this deployable. if the java class is not found, the registry is queried to find a suitable item

param
registry XXX
return
XXX
throws
ConfigurationException XXX

        Class   c = null;
        Handler h = null;

        try {
            c = getJavaClass();
        } catch (ClassNotFoundException e) {
            throw new ConfigurationException(e);
        }

        if (c != null) {
            try {
                h = (Handler)createInstance(c);
            } catch (Exception e) {
                throw new ConfigurationException(e);
            }

            if (h != null) {
                if ( qname != null )
                  h.setName(qname.getLocalPart()); 
                h.setOptions(getParametersTable());
                try{
                  h.init();
                }catch(Exception e){
                    String msg=e + JavaUtils.LS + JavaUtils.stackToString(e);
                    log.debug(msg);
                    throw new ConfigurationException(e);
                }catch(Error e){
                    String msg=e + JavaUtils.LS + JavaUtils.stackToString(e);
                    log.debug(msg);
                    throw new ConfigurationException(msg);
                }
            }
        } else {
            // !!! Should never get here!
            h = registry.getHandler(getType());
        }
        
        return h;
    
public voidremoveParameter(java.lang.String name)

param
name XXX

        if (parameters != null) {
            parameters.remove(name);
        }
    
public voidsetName(java.lang.String name)

param
name XXX

        qname = new QName(null, name);
    
public voidsetOptionsHashtable(java.util.Hashtable hashtable)
Convenience method for using old deployment XML with WSDD. This allows us to set the options directly after the Admin class has parsed them out of the old format.

        if (hashtable == null)
            return;
        
        parameters = new LockableHashtable(hashtable);
    
public voidsetParameter(java.lang.String name, java.lang.String value)
Set a parameter

        if (parameters == null) {
            parameters = new LockableHashtable();
        }
        parameters.put(name, value);
    
public voidsetQName(javax.xml.namespace.QName qname)

        this.qname = qname;
    
public voidsetType(javax.xml.namespace.QName type)

param
type XXX

        this.type = type;
    
public voidwriteParamsToContext(org.apache.axis.encoding.SerializationContext context)

        if (parameters == null)
            return;

        Set entries = parameters.entrySet();
        Iterator i = entries.iterator();
        while (i.hasNext()) {
            Map.Entry entry = (Map.Entry) i.next();
            String name = (String) entry.getKey();
            AttributesImpl attrs = new AttributesImpl();
            
            attrs.addAttribute("", ATTR_NAME, ATTR_NAME, "CDATA", name);
            attrs.addAttribute("", ATTR_VALUE, ATTR_VALUE, "CDATA", 
                                   entry.getValue().toString());
            if (parameters.isKeyLocked(name)) {
                attrs.addAttribute("", ATTR_LOCKED, ATTR_LOCKED, "CDATA", "true");
            }

            context.startElement(QNAME_PARAM, attrs);
            context.endElement();
        }