1 23 24 package com.sun.enterprise.deployment.node; 25 26 import java.util.Map ; 27 28 import org.w3c.dom.Node ; 29 30 import com.sun.enterprise.deployment.Descriptor; 31 import com.sun.enterprise.deployment.EnvironmentProperty; 32 import com.sun.enterprise.deployment.InjectionTarget; 33 import com.sun.enterprise.deployment.types.EjbReference; 34 import com.sun.enterprise.deployment.xml.EjbTagNames; 35 import com.sun.enterprise.deployment.xml.TagNames; 36 37 43 public class EjbReferenceNode extends DeploymentDescriptorNode { 44 45 protected EjbReference descriptor; 46 47 public EjbReferenceNode() { 48 super(); 49 registerElementHandler(new XMLElement(TagNames.INJECTION_TARGET), 50 InjectionTargetNode.class, "addInjectionTarget"); 51 } 52 53 56 public Object getDescriptor() { 57 if (descriptor==null) { 58 descriptor = (EjbReference) DescriptorFactory.getDescriptor(getXMLPath()); 59 descriptor.setLocal(false); 60 } 61 return descriptor; 62 } 63 64 70 protected Map getDispatchTable() { 71 Map table = super.getDispatchTable(); 72 table.put(EjbTagNames.EJB_REFERENCE_NAME, "setName"); 73 table.put(EjbTagNames.EJB_REFERENCE_TYPE, "setType"); 74 table.put(EjbTagNames.HOME, "setEjbHomeInterface"); 75 table.put(EjbTagNames.REMOTE, "setEjbInterface"); 76 table.put(EjbTagNames.LOCAL_HOME, "setEjbHomeInterface"); 77 table.put(EjbTagNames.LOCAL, "setEjbInterface"); 78 table.put(EjbTagNames.EJB_LINK, "setLinkName"); 79 table.put(TagNames.MAPPED_NAME, "setMappedName"); 80 return table; 81 } 82 83 91 public Node writeDescriptor(Node parent, String nodeName, EjbReference descriptor) { 92 Node ejbRefNode = appendChild(parent, nodeName); 93 if (descriptor instanceof Descriptor) { 94 Descriptor ejbRefDesc = (Descriptor)descriptor; 95 writeLocalizedDescriptions(ejbRefNode, ejbRefDesc); 96 } 97 appendTextChild(ejbRefNode, EjbTagNames.EJB_REFERENCE_NAME, descriptor.getName()); 98 appendTextChild(ejbRefNode, EjbTagNames.EJB_REFERENCE_TYPE, descriptor.getType()); 99 if (descriptor.isLocal()) { 100 appendTextChild(ejbRefNode, EjbTagNames.LOCAL_HOME, descriptor.getEjbHomeInterface()); 101 appendTextChild(ejbRefNode, EjbTagNames.LOCAL, descriptor.getEjbInterface()); 102 } else { 103 appendTextChild(ejbRefNode, EjbTagNames.HOME, descriptor.getEjbHomeInterface()); 104 appendTextChild(ejbRefNode, EjbTagNames.REMOTE, descriptor.getEjbInterface()); 105 } 106 appendTextChild(ejbRefNode, EjbTagNames.EJB_LINK, descriptor.getLinkName()); 107 108 if( descriptor instanceof EnvironmentProperty) { 109 EnvironmentProperty envProp = (EnvironmentProperty)descriptor; 110 appendTextChild(ejbRefNode, TagNames.MAPPED_NAME, envProp.getMappedName()); 111 } 112 if( descriptor.isInjectable() ) { 113 InjectionTargetNode ijNode = new InjectionTargetNode(); 114 for (InjectionTarget target : descriptor.getInjectionTargets()) { 115 ijNode.writeDescriptor(ejbRefNode, TagNames.INJECTION_TARGET, target); 116 } 117 } 118 119 return ejbRefNode; 120 } 121 122 } 123 | Popular Tags |