1 23 24 package com.sun.enterprise.deployment.node; 25 26 import java.util.Vector ; 27 import java.util.Iterator ; 28 import java.util.Map ; 29 import org.w3c.dom.Node ; 30 31 import com.sun.enterprise.deployment.Descriptor; 32 import com.sun.enterprise.deployment.EjbBundleDescriptor; 33 import com.sun.enterprise.deployment.EjbDescriptor; 34 import com.sun.enterprise.deployment.MethodDescriptor; 35 import com.sun.enterprise.deployment.ContainerTransaction; 36 import com.sun.enterprise.deployment.xml.EjbTagNames; 37 43 public class ContainerTransactionNode extends DeploymentDescriptorNode { 44 45 private String trans_attribute; 46 private String description; 47 private Vector methods = new Vector (); 48 49 50 public ContainerTransactionNode() { 51 registerElementHandler(new XMLElement(EjbTagNames.METHOD), MethodNode.class); 52 } 53 54 60 public void addDescriptor(Object newDescriptor) { 61 if (newDescriptor instanceof MethodDescriptor) { 62 methods.add(newDescriptor); 63 } 64 } 65 66 70 public Object getDescriptor() { 71 return null; 72 } 73 74 80 public boolean endElement(XMLElement element) { 81 boolean doneWithNode = super.endElement(element); 82 83 if (doneWithNode) { 84 ContainerTransaction ct = new ContainerTransaction(trans_attribute, description); 85 for (Iterator methodsIterator = methods.iterator();methodsIterator.hasNext();) { 86 MethodDescriptor md = (MethodDescriptor) methodsIterator.next(); 87 EjbBundleDescriptor bundle = (EjbBundleDescriptor) getParentNode().getDescriptor(); 88 EjbDescriptor ejb = bundle.getEjbByName(md.getEjbName()); 89 ejb.getMethodContainerTransactions().put(md, ct); 90 } 91 } 92 return doneWithNode; 93 } 94 95 101 public void setElementValue(XMLElement element, String value) { 102 if (EjbTagNames.DESCRIPTION.equals(element.getQName())) { 103 description = value; 104 } 105 if (EjbTagNames.TRANSACTION_ATTRIBUTE.equals(element.getQName())) { 106 trans_attribute = value; 107 } 108 } 109 110 118 public Node writeDescriptor(Node parent, String nodeName, EjbDescriptor ejb) { 119 120 Map methodToTransactions = ejb.getMethodContainerTransactions(); 121 MethodNode mn = new MethodNode(); 122 for (Iterator e=methodToTransactions.keySet().iterator();e.hasNext();) { 123 MethodDescriptor md = (MethodDescriptor) e.next(); 124 Node ctNode = super.writeDescriptor(parent, nodeName, ejb); 125 ContainerTransaction ct = (ContainerTransaction) methodToTransactions.get(md); 126 appendTextChild(ctNode, EjbTagNames.DESCRIPTION, ct.getDescription()); 127 mn.writeDescriptor(ctNode, EjbTagNames.METHOD, md, ejb.getName()); 128 appendTextChild(ctNode, EjbTagNames.TRANSACTION_ATTRIBUTE, ct.getTransactionAttribute()); 129 } 130 return null; 131 } 132 } 133 | Popular Tags |