1 23 24 package com.sun.enterprise.deployment.node.ejb; 25 26 import java.util.Map ; 27 import java.util.Map.Entry; 28 import org.w3c.dom.Node ; 29 30 import java.util.Set ; 31 import java.util.HashSet ; 32 import java.util.Iterator ; 33 34 import com.sun.enterprise.deployment.node.XMLElement; 35 import com.sun.enterprise.deployment.node.DeploymentDescriptorNode; 36 37 import com.sun.enterprise.deployment.EnvironmentProperty; 38 import com.sun.enterprise.deployment.Descriptor; 39 import com.sun.enterprise.deployment.ActivationConfigDescriptor; 40 import com.sun.enterprise.deployment.xml.EjbTagNames; 41 import com.sun.enterprise.deployment.util.DOLUtils; 42 43 49 public class ActivationConfigNode extends DeploymentDescriptorNode { 50 51 private ActivationConfigDescriptor descriptor = null; 52 private String propertyName = null; 53 54 public ActivationConfigNode() { 55 super(); 56 registerElementHandler(new XMLElement(EjbTagNames.ACTIVATION_CONFIG), 57 ActivationConfigNode.class, 58 "setActivationConfigDescriptor"); 59 } 60 61 65 public Object getDescriptor() { 66 if (descriptor == null) { 67 descriptor = (ActivationConfigDescriptor) super.getDescriptor(); 68 } 69 return descriptor; 70 } 71 72 78 public void setElementValue(XMLElement element, String value) { 79 if (EjbTagNames.ACTIVATION_CONFIG_PROPERTY_NAME.equals 80 (element.getQName())) { 81 propertyName = value; 82 } else if(EjbTagNames.ACTIVATION_CONFIG_PROPERTY_VALUE.equals 83 (element.getQName())) { 84 EnvironmentProperty prop = 85 new EnvironmentProperty(propertyName, value, ""); 86 descriptor.getActivationConfig().add(prop); 87 propertyName = null; 88 } 89 } 90 91 99 public Node writeDescriptor(Node parent, String nodeName, 100 ActivationConfigDescriptor descriptor) { 101 102 Node activationConfigNode = null; 103 Set activationConfig = descriptor.getActivationConfig(); 104 105 Set activationConfig2 = new HashSet (); 109 for(Iterator iter = activationConfig.iterator(); iter.hasNext();) { 110 EnvironmentProperty next = (EnvironmentProperty) iter.next(); 111 if ( ! next.getName().trim().equals("") && 112 ! next.getValue().trim().equals("")) { 113 activationConfig2.add(next); 114 } 115 } 116 117 if( activationConfig2.size() > 0 ) { 118 activationConfigNode = 119 appendChild(parent, nodeName); 120 writeLocalizedDescriptions(activationConfigNode, descriptor); 121 122 for(Iterator iter = activationConfig2.iterator(); iter.hasNext();) { 123 Node activationConfigPropertyNode = 124 appendChild(activationConfigNode, 125 EjbTagNames.ACTIVATION_CONFIG_PROPERTY); 126 EnvironmentProperty next = (EnvironmentProperty) iter.next(); 127 appendTextChild(activationConfigPropertyNode, 128 EjbTagNames.ACTIVATION_CONFIG_PROPERTY_NAME, 129 (String ) next.getName()); 130 appendTextChild(activationConfigPropertyNode, 131 EjbTagNames.ACTIVATION_CONFIG_PROPERTY_VALUE, 132 (String ) next.getValue()); 133 } 134 } 135 return activationConfigNode; 136 } 137 } 138 | Popular Tags |