FileDocCategorySizeDatePackage
DeploymentDescriptorNode.javaAPI DocGlassfish v2 API43057Fri May 04 22:31:38 BST 2007com.sun.enterprise.deployment.node

DeploymentDescriptorNode

public abstract class DeploymentDescriptorNode extends Object implements XMLNode
Superclass of all Nodes implementation XMLNode implementation represents all the DOL classes responsible for handling the XML deployment descriptors. These nodes are called by the SAX parser when reading and are constructed to build the DOM tree for saving the XML files. XMLNode are orgnalized like a tree with one root XMLNode (which implement the RootXMLNode interface) and sub XMLNodes responsible for handling subparts of the XML documents. Sub XMLNodes register themselfves to their parent XMLNode as handlers for a particular XML subtag of the tag handled by the parent XMLNode Each XMLNode is therefore associated with a xml tag (located anywhere in the tree of tags as defined by the DTD). It owns the responsibility for reading and writing the tag, its attributes and all subtags (by using delegation to sub XMLNode if necessary).
author
Jerome Dochez
version

Fields Summary
private static final String
QNAME_SEPARATOR
protected Hashtable
handlers
private Hashtable
addMethods
private XMLElement
xmlTag
protected XMLNode
parentNode
protected Object
abstractDescriptor
protected static final com.sun.enterprise.util.LocalStringManagerImpl
localStrings
Constructors Summary
public DeploymentDescriptorNode()
Creates new DeploymentDescriptorNode

        
    
        
      
        registerElementHandler(new XMLElement(TagNames.DESCRIPTION), LocalizedInfoNode.class);        
    
Methods Summary
public voidaddDescriptor(java.lang.Object descriptor)
Adds a new DOL descriptor instance to the descriptor instance associated with this XMLNode

param
descriptor the new descriptor

        if (getParentNode()==null) {
            DOLUtils.getDefaultLogger().log(Level.SEVERE, "enterprise.deployment.backend.addDescriptorFailure",
                new Object[] {descriptor , toString()});
            throw new RuntimeException("Cannot add " + descriptor + " to " + toString());
        } else {
            getParentNode().addDescriptor(descriptor);
        }
    
protected voidaddNamespaceDeclaration(org.w3c.dom.Element node, com.sun.enterprise.deployment.Descriptor descriptor)
Any node can now declare its own namespace. this apply to DDs only when dealing with deployment extensions. Write any declared namespace declaration

param
node from which this namespace is declared
param
descriptor containing the namespace declaration if any


        // declare now all remaining namepace...
        Map prefixMapping = (descriptor != null ) ?
            descriptor.getPrefixMapping() : null;
        if (prefixMapping!=null) {
            for (Iterator itr =prefixMapping.keySet().iterator();itr.hasNext();) {
                String prefix = (String) itr.next();
                String namespaceURI = (String) prefixMapping.get(prefix);
                setAttributeNS(node, prefix, namespaceURI);
            }
        }
    
protected voidaddNodeDescriptor(com.sun.enterprise.deployment.node.DeploymentDescriptorNode node)
Adds a new DOL descriptor instance to the descriptor associated with this XMLNode

param
XMLNode the sub-node adding the descriptor;
param
descriptor the new descriptor

        
        // if there is no descriptor associated with this class, the addDescriptor should implement 
        // the fate of this new descriptor.
        if (getDescriptor()==null) {
            addDescriptor(node.getDescriptor());
            return;
        }
        String xmlRootTag = node.getXMLRootTag().getQName();
        if (addMethods!=null && addMethods.containsKey(xmlRootTag)) {
            try {
                Method toInvoke = getDescriptor().getClass().getMethod(
                                                                (String) addMethods.get(xmlRootTag), 
                                                                new Class[] { node.getDescriptor().getClass() });
                toInvoke.invoke(getDescriptor(), new Object[] {node.getDescriptor()});
            } catch (InvocationTargetException e) {
		    Throwable t = e.getTargetException();
                    if (t instanceof IllegalArgumentException) {
                        // We report the error but we continue loading, this will allow the verifier to catch these errors or to register
                        // an error handler for notification
                        DOLUtils.getDefaultLogger().log(Level.SEVERE, "enterprise.deployment.backend.addDescriptorFailure",
                            new Object[]{node.getDescriptor().getClass() , getDescriptor().getClass()});
                    } else {
                        t.printStackTrace();
                        DOLUtils.getDefaultLogger().log(Level.SEVERE, "enterprise.deployment.backend.addDescriptorFailure",
                                new Object[]{t.toString(), null});
                    }
            } catch(Throwable t) {
                DOLUtils.getDefaultLogger().log(Level.SEVERE, "enterprise.deployment.backend.addDescriptorFailure",
                    new Object[] {node.getDescriptor().getClass() , getDescriptor().getClass() });
                t.printStackTrace();
                DOLUtils.getDefaultLogger().log(Level.SEVERE, "enterprise.deployment.backend.addDescriptorFailure",
                        new Object[]{t.toString(), null});
            }
        } else {
            addDescriptor(node.getDescriptor());
        }
    
public voidaddPrefixMapping(java.lang.String prefix, java.lang.String uri)
notify of a new prefix mapping used in this document

        Object o = getDescriptor();
        if (o instanceof Descriptor) {
            Descriptor descriptor = (Descriptor) o;
            descriptor.addPrefixMapping(prefix, uri);
        }
    
public static org.w3c.dom.ElementappendChild(org.w3c.dom.Node parent, java.lang.String elementName)

Append a new element child to the current node

param
parentNode is the parent node for the new child element
param
elementName is new element tag name
return
the newly created child node

        Element child = getOwnerDocument(parent).createElement(elementName);          
        parent.appendChild(child);
        return child;
    
public voidappendQNameChild(java.lang.String elementName, org.w3c.dom.Node parent, java.lang.String namespaceUri, java.lang.String localPart, java.lang.String prefix)

        if( prefix == null ) {
            // @@@ make configurable??
            prefix = elementName + "_ns__";
        } 

        String elementValue = composeQNameValue(prefix, localPart);
        Element element = (Element) appendTextChild
            (parent, elementName, elementValue);

        // Always set prefix mapping on leaf node.  If the DOL was
        // populated from an existing deployment descriptor it does
        // not preserve the original node structure of the XML document,
        // so we can't reliably know what level to place mapping.
        // Alternatively, if we're writing out a descriptor that was created
        // by the deploytool, there is no prefix->namespace information in
        // the first place.
        setAttributeNS(element, prefix, namespaceUri); 
        
    
public static org.w3c.dom.NodeappendTextChild(org.w3c.dom.Node parent, java.lang.String elementName, java.lang.String text)

Append a new text child

param
parent for the new child element
param
elementName is the new element tag name
param
text the text for the new element
result
the newly create child node

        
        if (text == null || text.length()==0) 
            return null;
        
        Node child = appendChild(parent, elementName);
        child.appendChild(getOwnerDocument(child).createTextNode(text));        
        return child;
    
public static org.w3c.dom.NodeappendTextChild(org.w3c.dom.Node parent, java.lang.String elementName, int value)

Append a new text child

param
parent for the new child element
param
elementName is the new element tag name
param
value the int value for the new element
result
the newly create child node

	return appendTextChild(parent, elementName, String.valueOf(value));
    
public java.lang.StringcomposeQNameValue(java.lang.String prefix, java.lang.String localPart)

        return ( (prefix != null) && !(prefix.equals("")) ) ?
            prefix + QNAME_SEPARATOR + localPart : localPart;
    
public booleanendElement(XMLElement element)
receives notification of the end of an XML element by the Parser

param
element the xml tag identification
return
true if this node is done processing the XML sub tree

	//DOLUtils.getDefaultLogger().finer("ENDELEMENT : " + "in " + getXMLRootTag() + "  Node, endElement " + element.getQName());
        boolean allDone = element.equals(getXMLRootTag());
        if (allDone) {
            postParsing();
            if (getParentNode()!=null && getDescriptor()!=null) {
                ((DeploymentDescriptorNode) getParentNode()).addNodeDescriptor(this);
            }      
        } 
        return allDone;
    
public static org.w3c.dom.NodeforceAppendTextChild(org.w3c.dom.Node parent, java.lang.String elementName, java.lang.String text)

Append a new text child even if text is empty

param
parent for the new child element
param
elementName is the new element tag name
param
text the text for the new element
result
the newly create child node

                
        Node child = appendChild(parent, elementName);
        if (text != null && text.length()!=0) {
            child.appendChild(getOwnerDocument(child).createTextNode(text));        
        }
        return child;
    
public java.lang.ObjectgetDescriptor()

return
the descriptor instance to associate with this XMLNode

        
        if (abstractDescriptor==null) {
	    abstractDescriptor = DescriptorFactory.getDescriptor(getXMLPath());
        }
        return abstractDescriptor;
    
protected java.util.MapgetDispatchTable()
all sub-implementation of this class can use a dispatch table to map xml element to method name on the descriptor class for setting the element value.

return
the map with the element name as a key, the setter method as a value

        // no need to be synchronized for now
        Map table =  new HashMap();
        table.put(TagNames.DESCRIPTION, "setDescription");
        return table;
    
public XMLNodegetHandlerFor(XMLElement element)

return
the handler registered for the subtag element of the curent XMLNode

        if (handlers==null) {
            DOLUtils.getDefaultLogger().log(Level.SEVERE, "enterprise.deployment.backend.invalidDescriptorMappingFailure",
                    new Object[] {this , "No handler registered"});            
            return null;
        } else {
            Class c = (Class)  handlers.get(element.getQName());
            if (c==null) {
                DOLUtils.getDefaultLogger().log(Level.SEVERE, "enterprise.deployment.backend.invalidDescriptorMappingFailure",
                    new Object[] {element.getQName(), "No handler registered"});
                return null;
            } 
            if (DOLUtils.getDefaultLogger().isLoggable(Level.FINER)) {        
                DOLUtils.getDefaultLogger().finer("New Handler requested for " + c);
            }
            DeploymentDescriptorNode node;
            try {
                node = (DeploymentDescriptorNode) c.newInstance(); 
                node.setParentNode(this);
		node.setXMLRootTag(element);
                node.getDescriptor();
            } catch(Exception e) {
                e.printStackTrace();
                return null;
            }
	    return node;
        }
    
public java.lang.StringgetLocalPartFromQName(java.lang.String qname)
Return local part from qname, where qname is an xsd:QName. QName ::= (Prefix ':')? LocalPart

        StringTokenizer tokenizer = new StringTokenizer(qname, QNAME_SEPARATOR);
        String localPart = qname;
        if( tokenizer.countTokens() == 2 ) {
            // skip namespace prefix.
            tokenizer.nextToken();
            localPart = tokenizer.nextToken();
        } 
        return localPart;
    
protected static org.w3c.dom.DocumentgetOwnerDocument(org.w3c.dom.Node node)

return
the Document for the given node


        if (node instanceof Document) {
            return (Document) node;
        }
        return node.getOwnerDocument();
    
public XMLNodegetParentNode()

return
the parent node of the current instance

        return parentNode;
    
public java.lang.StringgetPrefixFromQName(java.lang.String qname)

return
namespace URI prefix from qname, where qname is an xsd:QName, or the empty string if there is no prefix. QName ::= (Prefix ':')? LocalPart

        StringTokenizer tokenizer = new StringTokenizer(qname, QNAME_SEPARATOR);
        return (tokenizer.countTokens() == 2) ?
            tokenizer.nextToken() : "";
    
public java.lang.StringgetXMLPath()

return
the XPath this XML Node is handling

        if (getParentNode()!=null) {
            return getParentNode().getXMLPath() + "/" + getXMLRootTag().getQName();
        } else {
            return getXMLRootTag().getQName();
        }
    
protected XMLElementgetXMLRootTag()

return
the XML tag associated with this XMLNode

        return xmlTag;
    
public booleanhandlesElement(XMLElement element)

return
true if the element tag can be handled by any registered sub nodes of the current XMLNode

        // If we have no handlers for sub-nodes, it means we handle this XML tag
        if (handlers==null) 
            return true;
        
        // Let's iterator over all registered handlers to find one which is responsible 
        // for handling the XML tag.
        for (Enumeration handlersIterator = handlers.keys();handlersIterator.hasMoreElements();) {
            String subElement  = (String) handlersIterator.nextElement();  
            if (element.getQName().equals(subElement)) {
                return false;
            }
        }
        return true;
    
public voidpostParsing()
notification of the end of XML parsing for this node

    
protected voidregisterElementHandler(XMLElement element, java.lang.Class handler)
register a new XMLNode handler for a particular XML tag.

param
XMLElement is the XML tag this XMLNode will handle
param
handler the class implemenenting the XMLNode interface

        if (handlers==null) {
            handlers = new Hashtable();
        }
        handlers.put(element.getQName(), handler);        
    
protected voidregisterElementHandler(XMLElement element, java.lang.Class handler, java.lang.String addMethodName)
register a new XMLNode handler for a particular XML tag.

param
XMLElement is the XML tag this XMLNode will handle
param
handler the class implemenenting the XMLNode interface
param
addMethodName is the method name for adding the descriptor extracted by the handler node to the current descriptor

                                                                                             
       registerElementHandler(element, handler);       
       if (addMethods==null) {
           addMethods = new Hashtable();
       }
       addMethods.put(element.getQName(), addMethodName);       
    
public java.lang.StringresolvePrefix(XMLElement element, java.lang.String prefix)
Resolve a QName prefix to its corresponding Namespace URI by searching up node chain starting with child.

        // If prefix is empty string, returned namespace URI 
        // is the default namespace.
        return element.getPrefixURIMapping(prefix);
    
public static voidsetAttribute(org.w3c.dom.Element parent, java.lang.String elementName, java.lang.String text)

Append a new attribute to an element

param
parent for the new child element
param
elementName is the new element tag name
param
text the text for the new element
result
the newly create child node

        
        if (text == null || text.length()==0) 
            return;
        parent.setAttribute(elementName, text);
    
public static voidsetAttributeNS(org.w3c.dom.Element element, java.lang.String prefix, java.lang.String namespaceURI)
Set a namespace attribute on an element.

param
element on which to set attribute
param
prefix raw prefix (without "xmlns:")
param
namespaceURI namespace URI to which prefix is mapped.


        String nsPrefix = prefix.equals("") ? "xmlns" :
            "xmlns" + QNAME_SEPARATOR + prefix;

        element.setAttributeNS("http://www.w3.org/2000/xmlns/", nsPrefix,
                               namespaceURI);
    
protected booleansetAttributeValue(XMLElement elementName, XMLElement attributeName, java.lang.String value)
parsed an attribute of an element

param
the element name
param
the attribute name
param
the attribute value
return
true if the attribute was processed

        // we do not support id attribute for the moment
        if (attributeName.getQName().equals(TagNames.ID)) {
            return true;
        }

	return false;
    
protected voidsetDescriptorInfo(java.lang.Object target, java.lang.String methodName, java.lang.String value)
call a setter method on a descriptor with a new value

param
target the descriptor to use
param
methodName the setter method to invoke
param
value the new value for the field in the descriptor


        if (DOLUtils.getDefaultLogger().isLoggable(Level.FINE)) {
            DOLUtils.getDefaultLogger().fine("in " + target.getClass() + "  method  " + methodName +  " with  " + value );   
        }
   	
	try {
	    Method toInvoke = target.getClass().getMethod(methodName, new Class[] { String.class });
	    toInvoke.invoke(target, new Object[] {value});
	} catch(NoSuchMethodException e1) {
            try {
                // try with int as a parameter
                Method toInvoke = target.getClass().getMethod(methodName, new Class[] { int.class });
                toInvoke.invoke(target, new Object[] {Integer.valueOf(value)});
            } catch (NumberFormatException nfe) {
                DOLUtils.getDefaultLogger().log(Level.SEVERE, "enterprise.deployment.backend.invalidDescriptorMappingFailure",
			new Object []{ getXMLPath().toString() , nfe.toString()});
	    } catch(NoSuchMethodException e2) {
                // try with boolean as a parameter
                Method toInvoke = target.getClass().getMethod(methodName, new Class[] { boolean.class });
                toInvoke.invoke(target, new Object[] {Boolean.valueOf(value)});                
            } 
	}
    
public voidsetElementValue(XMLElement element, java.lang.String value)
receives notification of the value for a particular tag

param
element the xml element
param
value it's associated value

	//DOLUtils.getDefaultLogger().finer("SETELEMENTVALUE : " + "in " + getXMLRootTag() + "  Node, startElement " + element.getQName());
        Map dispatchTable = getDispatchTable();
        
        if (dispatchTable != null) {        
            if (dispatchTable.containsKey(element.getQName())) {
                if (dispatchTable.get(element.getQName())==null) {
                    // we just ignore these values from the DDs
                    if (DOLUtils.getDefaultLogger().isLoggable(Level.FINER)) {
                        DOLUtils.getDefaultLogger().finer("Deprecated element " + element.getQName() + " with value " + value + " is ignored");
                    }
                    return;
                }
                try {
                    Object descriptor = getDescriptor();
                    if (descriptor!=null) {
                        setDescriptorInfo(descriptor, (String) dispatchTable.get(element.getQName()), (String) value);
                    } else {
                        DOLUtils.getDefaultLogger().log(Level.SEVERE, "enterprise.deployment.backend.invalidDescriptorMappingFailure",
                            new Object[] {element.getQName() , value });
                    }
                    
                    return;
                } catch (InvocationTargetException e) {
                    DOLUtils.getDefaultLogger().log(Level.SEVERE, "enterprise.deployment.backend.invalidDescriptorMappingFailure",
                        new Object[] {dispatchTable.get(element.getQName()) , getDescriptor().getClass()});
		    Throwable t = e.getTargetException();
                    if (t instanceof IllegalArgumentException) {
                        // We report the error but we continue loading, this will allow the verifier to catch these errors or to register
                        // an error handler for notification
                        DOLUtils.getDefaultLogger().log(Level.SEVERE, "enterprise.deployment.backend.invalidDescriptorMappingFailure",
                            new Object[] {element , value});
                    } else {
                        t.printStackTrace();
                        DOLUtils.getDefaultLogger().log(Level.SEVERE, "enterprise.deployment.backend.invalidDescriptorMappingFailure",
                                new Object[] {t.toString(), null});
                    }
                } catch(Throwable t) {
                    t.printStackTrace();
                        DOLUtils.getDefaultLogger().log(Level.SEVERE, "enterprise.deployment.backend.invalidDescriptorMappingFailure",
                                new Object[] {t.toString(), null});
                }
            }            
        }
        if (value.trim().length()!=0) {
            DOLUtils.getDefaultLogger().log(Level.SEVERE, "enterprise.deployment.backend.invalidDescriptorMappingFailure",
                new Object[] {element.getQName() , value });                
        }
        return;
    
public voidsetParentNode(XMLNode parentNode)
set the parent node for the current instance.

        this.parentNode = parentNode;
    
protected voidsetXMLRootTag(XMLElement element)
sets the XML tag associated with this XMLNode

        xmlTag = element;
    
public voidstartElement(XMLElement element, org.xml.sax.Attributes attributes)
SAX Parser API implementation, we don't really care for now.

        //DOLUtils.getDefaultLogger().finer("STARTELEMENT : " + "in " + getXMLRootTag() + "  Node, startElement " + element.getQName());
        if (!this.getXMLRootTag().equals(element))
            return;
        
        if (attributes.getLength()>0) {
            for (int i=0;i<attributes.getLength();i++) {
                if (DOLUtils.getDefaultLogger().isLoggable(Level.FINER)) {                
                    DOLUtils.getDefaultLogger().finer("With attribute " + attributes.getQName(i));
                    DOLUtils.getDefaultLogger().finer("With value " + attributes.getValue(i));
                }
		// we try the setAttributeValue first, if not processed then the setElement
		if (!setAttributeValue(element, new XMLElement(attributes.getQName(i)), attributes.getValue(i))) {
		    setElementValue(new XMLElement(attributes.getQName(i)), attributes.getValue(i));
		}
	                
            } 
        }
    
protected voidwriteAroundInvokeDescriptors(org.w3c.dom.Node parentNode, java.util.Iterator aroundInvokeDescs)

        if (aroundInvokeDescs == null || !aroundInvokeDescs.hasNext())
            return;

        AroundInvokeNode subNode = new AroundInvokeNode();
        for(; aroundInvokeDescs.hasNext();) {
            LifecycleCallbackDescriptor next =
                (LifecycleCallbackDescriptor) aroundInvokeDescs.next();
            subNode.writeDescriptor(parentNode, 
                                    EjbTagNames.AROUND_INVOKE_METHOD, next);
        }

    
private voidwriteDeploymentExtensionDescriptor(org.w3c.dom.Node parentNode, com.sun.enterprise.deployment.Descriptor descriptor)
write the deployment extension nodes associated with this node

param
parent node for the DOM tree
param
the deployment extension descriptor
note
this was an iterim feature of the J2EE 1.4 platform, I leave it here for now because it may reappear in a later platform release, I put it private so that it is not misused in the meantime.

                    
        Iterator itr = descriptor.getDeploymentExtensions();
        if (itr==null) {
            return;
        } 
        DeploymentExtensionNode subNode = new DeploymentExtensionNode();
        subNode.writeDescriptor(parentNode, itr);        
    
public org.w3c.dom.NodewriteDescriptor(org.w3c.dom.Node parent, com.sun.enterprise.deployment.Descriptor descriptor)
write the descriptor class to a DOM tree and return it

param
parent node in the DOM tree
param
the descriptor to write
return
the DOM tree top node

       return writeDescriptor(parent, getXMLRootTag().getQName(), descriptor);
    
public org.w3c.dom.NodewriteDescriptor(org.w3c.dom.Node parent, java.lang.String nodeName, com.sun.enterprise.deployment.Descriptor descriptor)
write the descriptor class to a DOM tree and return it

param
parent node in the DOM tree
param
node name for the root element for this DOM tree fragment
param
the descriptor to write
return
the DOM tree top node

        Node node = appendChild(parent, nodeName);
        return node; 
    
protected voidwriteEjbReferenceDescriptors(org.w3c.dom.Node parentNode, java.util.Iterator refs)
write the ejb references (local or remote) to the DOM tree

param
parent node for the DOM tree
param
the set of EjbReferenceDescriptor to write

        
        
        if (refs==null || !refs.hasNext()) 
            return;
        
        EjbReferenceNode subNode = new EjbReferenceNode();    
        // ejb-ref*        
        Set localRefDescs = new HashSet();
        for (;refs.hasNext();) {
            EjbReference ejbRef = (EjbReference) refs.next();
            if (ejbRef.isLocal()) {
                localRefDescs.add(ejbRef);
            } else {
                subNode.writeDescriptor(parentNode, TagNames.EJB_REFERENCE, ejbRef);           
            }
        }
        // ejb-local-ref*
        for (Iterator e=localRefDescs.iterator(); e.hasNext();) {
            EjbReference ejbRef = (EjbReference) e.next();
            subNode.writeDescriptor(parentNode, TagNames.EJB_LOCAL_REFERENCE,ejbRef);
        }    
    
protected voidwriteEntityManagerFactoryReferenceDescriptors(org.w3c.dom.Node parentNode, java.util.Iterator entityMgrFactoryRefs)
write a list of entity manager factory reference descriptors to a DOM Tree

param
parent node for the DOM tree
param
the iterator over the descriptors to write

                
        
        if (entityMgrFactoryRefs==null || !entityMgrFactoryRefs.hasNext()) 
            return;
        
        EntityManagerFactoryReferenceNode subNode =
                new EntityManagerFactoryReferenceNode();
        for (;entityMgrFactoryRefs.hasNext();) {
            EntityManagerFactoryReferenceDescriptor aEntityMgrFactoryRef =
                (EntityManagerFactoryReferenceDescriptor)entityMgrFactoryRefs.next();
            subNode.writeDescriptor(parentNode, TagNames.PERSISTENCE_UNIT_REF, aEntityMgrFactoryRef);
        }        
    
protected voidwriteEntityManagerReferenceDescriptors(org.w3c.dom.Node parentNode, java.util.Iterator entityMgrRefs)
write a list of entity manager reference descriptors to a DOM Tree

param
parent node for the DOM tree
param
the iterator over the descriptors to write

                
        
        if (entityMgrRefs==null || !entityMgrRefs.hasNext()) 
            return;
        
        EntityManagerReferenceNode subNode = new EntityManagerReferenceNode();
        for (;entityMgrRefs.hasNext();) {
            EntityManagerReferenceDescriptor aEntityMgrRef = (EntityManagerReferenceDescriptor)entityMgrRefs.next();
            subNode.writeDescriptor(parentNode, TagNames.PERSISTENCE_CONTEXT_REF, aEntityMgrRef);
        }        
    
protected voidwriteEnvEntryDescriptors(org.w3c.dom.Node parentNode, java.util.Iterator envEntries)
write a list of env entry descriptors to a DOM Tree

param
parent node for the DOM tree
param
the iterator over the descriptors to write

            
        
        if (envEntries==null || !envEntries.hasNext())
            return;
        
        EnvEntryNode subNode = new EnvEntryNode();
        for (;envEntries.hasNext();) {            
            EnvironmentProperty envProp = (EnvironmentProperty) envEntries.next();
            subNode.writeDescriptor(parentNode, TagNames.ENVIRONMENT_PROPERTY, envProp);
        }
    
protected voidwriteJNDIEnvironmentRefs(org.w3c.dom.Node node, com.sun.enterprise.deployment.JndiNameEnvironment descriptor)
writes jndi environment references group nodes

        
        /*      <xsd:element name="env-entry"
		   type="javaee:env-entryType"
		   minOccurs="0" maxOccurs="unbounded"/>
         */
        writeEnvEntryDescriptors(node, descriptor.getEnvironmentProperties().iterator());

        /*      <xsd:element name="ejb-ref"
		   type="javaee:ejb-refType"
		   minOccurs="0" maxOccurs="unbounded"/>
        */
        /*      <xsd:element name="ejb-local-ref"
		   type="javaee:ejb-local-refType"
		   minOccurs="0" maxOccurs="unbounded"/>
         */        
        writeEjbReferenceDescriptors(node, 
                    descriptor.getEjbReferenceDescriptors().iterator());
    

        /*      <xsd:group ref="javaee:service-refGroup"/>
         */
        writeServiceReferenceDescriptors(node, descriptor.getServiceReferenceDescriptors().iterator());
         
        /*  <xsd:element name="resource-ref"
		   type="javaee:resource-refType"
		   minOccurs="0" maxOccurs="unbounded"/>
         */
         writeResourceRefDescriptors(node, descriptor.getResourceReferenceDescriptors().iterator());
         
        /*  <xsd:element name="resource-env-ref"
                   type="javaee:resource-env-refType"
                   minOccurs="0" maxOccurs="unbounded"/>
         */
         writeResourceEnvRefDescriptors(node, descriptor.getJmsDestinationReferenceDescriptors().iterator());
         
        /*      <xsd:element name="message-destination-ref"
                   type="javaee:message-destination-refType"
                   minOccurs="0" maxOccurs="unbounded"/>
         */
         writeMessageDestinationRefDescriptors(node, descriptor.getMessageDestinationReferenceDescriptors().iterator());
         
        /*      <xsd:element name="persistence-context-ref"
		   type="javaee:persistence-context-refType"
		   minOccurs="0" maxOccurs="unbounded"/>
         */
         writeEntityManagerReferenceDescriptors(node, descriptor.getEntityManagerReferenceDescriptors().iterator());
         
        /*      <xsd:element name="persistence-unit-ref"
		   type="javaee:persistence-unit-refType"
		   minOccurs="0" maxOccurs="unbounded"/>
         */
         writeEntityManagerFactoryReferenceDescriptors(node, descriptor.getEntityManagerFactoryReferenceDescriptors().iterator());
         
        /*      <xsd:element name="post-construct"
		   type="javaee:lifecycle-callbackType"
		   minOccurs="0"
		   maxOccurs="unbounded"/>
         */
         writePostConstructDescriptors(node, descriptor.getPostConstructDescriptors().iterator());
         

        /*      <xsd:element name="pre-destroy"
		   type="javaee:lifecycle-callbackType"
		   minOccurs="0"
		   maxOccurs="unbounded"/>
         */
         writePreDestroyDescriptors(node, descriptor.getPreDestroyDescriptors().iterator());
    
protected voidwriteLocalizedDescriptions(org.w3c.dom.Node node, com.sun.enterprise.deployment.Descriptor desc)
writes iocalized descriptions (if any) to the DOM node

        
        LocalizedInfoNode localizedNode = new LocalizedInfoNode();
        localizedNode.writeLocalizedMap(node, TagNames.DESCRIPTION, desc.getLocalizedDescriptions());    
    
protected voidwriteMessageDestinationRefDescriptors(org.w3c.dom.Node parentNode, java.util.Iterator msgDestRefs)
write a list of message destination reference descriptors to a DOM Tree

param
parent node for the DOM tree
param
the iterator over the descriptors to write

                
        
        if (msgDestRefs==null || !msgDestRefs.hasNext()) 
            return;
        
        MessageDestinationRefNode subNode = new MessageDestinationRefNode();
        for (;msgDestRefs.hasNext();) {
            MessageDestinationReferenceDescriptor next = 
                (MessageDestinationReferenceDescriptor) msgDestRefs.next();
            subNode.writeDescriptor(parentNode, 
                                    TagNames.MESSAGE_DESTINATION_REFERENCE, 
                                    next);
        }        
    
protected voidwritePostActivateDescriptors(org.w3c.dom.Node parentNode, java.util.Iterator postActivateDescs)

        if (postActivateDescs == null || !postActivateDescs.hasNext())
            return;

        LifecycleCallbackNode subNode = new LifecycleCallbackNode();
        for(; postActivateDescs.hasNext();) {
            LifecycleCallbackDescriptor next =
                (LifecycleCallbackDescriptor) postActivateDescs.next();
            subNode.writeDescriptor(parentNode, 
                                    EjbTagNames.POST_ACTIVATE_METHOD, next);
        }

    
protected voidwritePostConstructDescriptors(org.w3c.dom.Node parentNode, java.util.Iterator postConstructDescs)
write a list of post-construct descriptors to a DOM Tree

param
parent node for the DOM tree
param
the iterator over the descriptors to write

        if (postConstructDescs == null || !postConstructDescs.hasNext())
            return;

        LifecycleCallbackNode subNode = new LifecycleCallbackNode();
        for (; postConstructDescs.hasNext();) {
            LifecycleCallbackDescriptor next = postConstructDescs.next();
            subNode.writeDescriptor(parentNode, TagNames.POST_CONSTRUCT,
                                    next);
        }
    
protected voidwritePreDestroyDescriptors(org.w3c.dom.Node parentNode, java.util.Iterator preDestroyDescs)
write a list of pre-destroy descriptors to a DOM Tree

param
parent node for the DOM tree
param
the iterator over the descriptors to write

        if (preDestroyDescs == null || !preDestroyDescs.hasNext())
            return;

        LifecycleCallbackNode subNode = new LifecycleCallbackNode();
        for (; preDestroyDescs.hasNext();) {
            LifecycleCallbackDescriptor next = preDestroyDescs.next();
            subNode.writeDescriptor(parentNode, TagNames.PRE_DESTROY,
                                    next);
        }
    
protected voidwritePrePassivateDescriptors(org.w3c.dom.Node parentNode, java.util.Iterator prePassivateDescs)

        if (prePassivateDescs == null || !prePassivateDescs.hasNext())
            return;

        LifecycleCallbackNode subNode = new LifecycleCallbackNode();
        for(; prePassivateDescs.hasNext();) {
            LifecycleCallbackDescriptor next =
                (LifecycleCallbackDescriptor) prePassivateDescs.next();
            subNode.writeDescriptor(parentNode, 
                                    EjbTagNames.PRE_PASSIVATE_METHOD, next);
        }

    
protected voidwriteResourceEnvRefDescriptors(org.w3c.dom.Node parentNode, java.util.Iterator resRefs)
write a list of resource env reference descriptors to a DOM Tree

param
parent node for the DOM tree
param
the iterator over the descriptors to write

                
        
        if (resRefs==null || !resRefs.hasNext()) 
            return;
        
        ResourceEnvRefNode subNode = new ResourceEnvRefNode();
        for (;resRefs.hasNext();) {
            JmsDestinationReferenceDescriptor aResRef = (JmsDestinationReferenceDescriptor) resRefs.next();
            subNode.writeDescriptor(parentNode, TagNames.RESOURCE_ENV_REFERENCE, aResRef);
        }        
    
protected voidwriteResourceRefDescriptors(org.w3c.dom.Node parentNode, java.util.Iterator resRefs)
write a list of resource reference descriptors to a DOM Tree

param
parent node for the DOM tree
param
the iterator over the descriptors to write

                
        
        if (resRefs==null || !resRefs.hasNext()) 
            return;
        
        ResourceRefNode subNode = new ResourceRefNode();
        for (;resRefs.hasNext();) {
            ResourceReferenceDescriptor aResRef = (ResourceReferenceDescriptor) resRefs.next();
            subNode.writeDescriptor(parentNode, TagNames.RESOURCE_REFERENCE, aResRef);
        }        
    
protected voidwriteServiceReferenceDescriptors(org.w3c.dom.Node parentNode, java.util.Iterator refs)

        if( ( refs == null ) || !refs.hasNext() ) {
            return;
        }

        ServiceReferenceNode serviceRefNode = new ServiceReferenceNode();
        while(refs.hasNext()) {
            ServiceReferenceDescriptor next = (ServiceReferenceDescriptor)
                refs.next();
            serviceRefNode.writeDescriptor
                (parentNode, WebServicesTagNames.SERVICE_REF, next);
        }