1 23 package com.sun.enterprise.deployment.node.runtime; 24 25 import java.util.Map ; 26 import java.util.Iterator ; 27 import java.util.logging.Level ; 28 import org.w3c.dom.Node ; 29 30 import com.sun.enterprise.deployment.types.EjbReferenceContainer; 31 import com.sun.enterprise.deployment.types.EjbReference; 32 import com.sun.enterprise.deployment.Descriptor; 33 import com.sun.enterprise.deployment.node.XMLElement; 34 import com.sun.enterprise.deployment.node.DeploymentDescriptorNode; 35 import com.sun.enterprise.deployment.xml.RuntimeTagNames; 36 import com.sun.enterprise.deployment.util.DOLUtils; 37 38 45 public class EjbRefNode extends DeploymentDescriptorNode { 46 47 EjbReference descriptor=null; 48 49 52 public Object getDescriptor() { 53 return descriptor; 54 } 55 56 62 protected Map getDispatchTable() { 63 Map table = super.getDispatchTable(); 64 table.put(RuntimeTagNames.JNDI_NAME, "setJndiName"); 65 return table; 66 } 67 68 74 public void setElementValue(XMLElement element, String value) { 75 if (RuntimeTagNames.EJB_REFERENCE_NAME.equals(element.getQName())) { 76 Object parentDesc = getParentNode().getDescriptor(); 77 if (parentDesc instanceof EjbReferenceContainer) { 78 descriptor = ((EjbReferenceContainer) parentDesc).getEjbReference(value); 79 DOLUtils.getDefaultLogger().finer("Applying ref runtime to " + descriptor); 80 } 81 if (descriptor==null) { 82 DOLUtils.getDefaultLogger().log(Level.SEVERE, "enterprise.deployment.backend.addDescriptorFailure", 83 new Object []{"ejb-ref" , value }); 84 } 85 } else super.setElementValue(element, value); 86 } 87 88 96 public Node writeDescriptor(Node parent, String nodeName, EjbReference ejbRef) { 97 Node ejbRefNode = appendChild(parent, nodeName); 98 appendTextChild(ejbRefNode, RuntimeTagNames.EJB_REFERENCE_NAME, ejbRef.getName()); 99 appendTextChild(ejbRefNode, RuntimeTagNames.JNDI_NAME, ejbRef.getJndiName()); 100 return ejbRefNode; 101 } 102 103 109 public static void writeEjbReferences(Node parent, EjbReferenceContainer descriptor) { 110 111 Iterator ejbRefs = descriptor.getEjbReferenceDescriptors().iterator(); 113 if (ejbRefs.hasNext()) { 114 EjbRefNode refNode = new EjbRefNode(); 115 while (ejbRefs.hasNext()) { 116 EjbReference ejbRef = (EjbReference) ejbRefs.next(); 117 if (!ejbRef.isLocal()) { 118 refNode.writeDescriptor(parent, RuntimeTagNames.EJB_REFERENCE, ejbRef ); 119 } 120 } 121 } 122 } 123 } 124 | Popular Tags |