1 23 24 package com.sun.enterprise.deployment.node; 25 26 import java.util.Map ; 27 import java.util.Iterator ; 28 import org.w3c.dom.Node ; 29 import org.w3c.dom.Element ; 30 import com.sun.enterprise.deployment.xml.TagNames; 31 import com.sun.enterprise.deployment.DeploymentExtensionDescriptor; 32 import com.sun.enterprise.deployment.ExtensionElementDescriptor; 33 34 39 public class DeploymentExtensionNode extends DeploymentDescriptorNode { 40 41 47 protected Map getDispatchTable() { 48 Map table = super.getDispatchTable(); 49 table.put(TagNames.NAMESPACE, "setNameSpace"); 50 return table; 51 } 52 53 59 public void setElementValue(XMLElement element, String value) { 60 if (TagNames.MUST_UNDERSTAND.equals(element.getQName())) { 61 if ("true".equals(value)) { 62 throw new RuntimeException ("a deployment-extension tagged with mustUnderstand attribute is not understood"); 63 } 64 } else 65 super.setElementValue(element, value); 66 } 67 68 72 public boolean handlesElement(XMLElement element) { 73 if (TagNames.EXTENSION_ELEMENT.equals(element.getQName())) { 74 return false; 75 } 76 return true; 77 } 78 79 82 public XMLNode getHandlerFor(XMLElement element) { 83 ExtensionElementNode subNode = new ExtensionElementNode(); 84 DeploymentExtensionDescriptor o = (DeploymentExtensionDescriptor) getDescriptor(); 85 o.addElement((ExtensionElementDescriptor) subNode.getDescriptor()); 86 subNode.setXMLRootTag(new XMLElement(TagNames.EXTENSION_ELEMENT)); 87 subNode.setParentNode(this); 88 return subNode; 89 } 90 91 97 public void addDescriptor(Object descriptor) { 98 } 100 101 107 protected void writeDescriptor(Node parentNode, Iterator itr) { 108 109 ExtensionElementNode subNode = new ExtensionElementNode(); 110 do { 111 DeploymentExtensionDescriptor descriptor = (DeploymentExtensionDescriptor) itr.next(); 112 Element extensionNode = appendChild(parentNode, TagNames.DEPLOYMENT_EXTENSION); 113 setAttribute(extensionNode, TagNames.NAMESPACE, descriptor.getNameSpace()); 114 if (descriptor.getMustUnderstand()) { 115 setAttribute(extensionNode, TagNames.MUST_UNDERSTAND, "true"); 116 } 117 for (Iterator elements = descriptor.elements();elements.hasNext();) { 118 ExtensionElementDescriptor element = (ExtensionElementDescriptor) elements.next(); 119 subNode.writeDescriptor(extensionNode, TagNames.EXTENSION_ELEMENT, element ); 120 } 121 } while(itr.hasNext()); 122 } 123 } 124 | Popular Tags |