1 23 24 package com.sun.enterprise.deployment.node; 25 26 import java.util.Iterator ; 27 import java.util.Map ; 28 import java.util.logging.Level ; 29 import org.w3c.dom.Node ; 30 import org.xml.sax.Attributes ; 31 32 import javax.enterprise.deploy.shared.ModuleType ; 33 34 import com.sun.enterprise.deployment.Application; 35 import com.sun.enterprise.deployment.Descriptor; 36 import com.sun.enterprise.deployment.DeploymentExtensionDescriptor; 37 import com.sun.enterprise.deployment.util.ModuleDescriptor; 38 import com.sun.enterprise.deployment.xml.ApplicationTagNames; 39 40 import com.sun.enterprise.deployment.util.DOLUtils; 41 42 49 public class ModuleNode extends DeploymentDescriptorNode { 50 51 57 protected Map getDispatchTable() { 58 Map table = super.getDispatchTable(); 59 table.put(ApplicationTagNames.ALTERNATIVE_DD, "setAlternateDescriptor"); 60 table.put(ApplicationTagNames.CONTEXT_ROOT, "setContextRoot"); 61 return table; 62 } 63 64 70 public void setElementValue(XMLElement element, String value) { 71 ModuleDescriptor descriptor = (ModuleDescriptor) getDescriptor(); 72 if (element.getQName().equals(ApplicationTagNames.WEB_URI)) { 73 descriptor.setModuleType(ModuleType.WAR); 74 descriptor.setArchiveUri(value); 75 } else if (element.getQName().equals(ApplicationTagNames.EJB)) { 76 descriptor.setModuleType(ModuleType.EJB); 77 descriptor.setArchiveUri(value); 78 } else if (element.getQName().equals(ApplicationTagNames.CONNECTOR)) { 79 descriptor.setModuleType(ModuleType.RAR); 80 descriptor.setArchiveUri(value); 81 } else if (element.getQName().equals(ApplicationTagNames.APPLICATION_CLIENT)) { 82 descriptor.setModuleType(ModuleType.CAR); 83 descriptor.setArchiveUri(value); 84 } else if (element.getQName().equals(ApplicationTagNames.WEB)) { 85 descriptor.setModuleType(ModuleType.WAR); 86 } else super.setElementValue(element, value); 87 } 88 89 97 public Node writeDescriptor(Node parent, String nodeName, ModuleDescriptor descriptor) { 98 99 Node module = appendChild(parent, nodeName); 100 if (ModuleType.WAR.equals(descriptor.getModuleType())) { 101 Node modType = appendChild(module, ApplicationTagNames.WEB); 102 appendTextChild(modType, ApplicationTagNames.WEB_URI, descriptor.getArchiveUri()); 103 forceAppendTextChild(modType, ApplicationTagNames.CONTEXT_ROOT, descriptor.getContextRoot()); 104 105 } else { 106 String type = ApplicationTagNames.EJB; 108 if (ModuleType.CAR.equals(descriptor.getModuleType())) { 109 type = ApplicationTagNames.APPLICATION_CLIENT; 110 } else if (ModuleType.RAR.equals(descriptor.getModuleType())) { 111 type = ApplicationTagNames.CONNECTOR; 112 } 113 appendTextChild(module, type, descriptor.getArchiveUri()); 114 } 115 appendTextChild(module,ApplicationTagNames.ALTERNATIVE_DD, descriptor.getAlternateDescriptor()); 116 return module; 117 } 118 } 119 | Popular Tags |