1 23 24 29 30 package com.sun.enterprise.deployment.node.ejb; 31 32 import java.util.Map ; 33 import org.w3c.dom.Node ; 34 35 import com.sun.enterprise.deployment.node.XMLElement; 36 import com.sun.enterprise.deployment.node.DeploymentDescriptorNode; 37 import com.sun.enterprise.deployment.node.LocalizedInfoNode; 38 import com.sun.enterprise.deployment.node.DescriptorFactory; 39 40 import com.sun.enterprise.deployment.Descriptor; 41 import com.sun.enterprise.deployment.RelationRoleDescriptor; 42 import com.sun.enterprise.deployment.RelationshipDescriptor; 43 import com.sun.enterprise.deployment.xml.EjbTagNames; 44 45 50 public class EjbRelationNode extends DeploymentDescriptorNode { 51 52 RelationRoleDescriptor source = null; 53 RelationRoleDescriptor sink = null; 54 RelationshipDescriptor descriptor = null; 55 56 public EjbRelationNode() { 57 super(); 58 registerElementHandler(new XMLElement(EjbTagNames.EJB_RELATIONSHIP_ROLE), 59 EjbRelationshipRoleNode.class); 60 } 61 62 65 public Object getDescriptor() { 66 if (descriptor==null) { 67 descriptor = (RelationshipDescriptor) DescriptorFactory.getDescriptor(getXMLPath()); 68 } 69 return descriptor; 70 } 71 72 78 public void addDescriptor(Object newDescriptor) { 79 if (newDescriptor instanceof RelationRoleDescriptor) { 80 if (source==null) { 81 source = (RelationRoleDescriptor) newDescriptor; 82 } else { 83 sink = (RelationRoleDescriptor) newDescriptor; 84 85 descriptor.setSource(source); 86 source.setPartner(sink); 87 source.setRelationshipDescriptor(descriptor); 88 descriptor.setSink(sink); 89 sink.setPartner(source); 90 sink.setRelationshipDescriptor(descriptor); 91 92 if ( source.getCMRField() != null && sink.getCMRField() != null ) 93 descriptor.setIsBidirectional(true); 94 else 95 descriptor.setIsBidirectional(false); 96 } 97 } 98 } 99 100 106 protected Map getDispatchTable() { 107 Map table = super.getDispatchTable(); 109 table.put(EjbTagNames.EJB_RELATION_NAME, "setName"); 110 return table; 111 } 112 113 121 public Node writeDescriptor(Node parent, String nodeName, RelationshipDescriptor descriptor) { 122 Node ejbRelationNode = super.writeDescriptor(parent, nodeName, descriptor); 123 writeLocalizedDescriptions(ejbRelationNode, descriptor); 124 appendTextChild(ejbRelationNode, EjbTagNames.EJB_RELATION_NAME, descriptor.getName()); 125 EjbRelationshipRoleNode roleNode = new EjbRelationshipRoleNode(); 126 roleNode.writeDescriptor(ejbRelationNode, EjbTagNames.EJB_RELATIONSHIP_ROLE, descriptor.getSource()); 127 roleNode.writeDescriptor(ejbRelationNode, EjbTagNames.EJB_RELATIONSHIP_ROLE, descriptor.getSink()); 128 return ejbRelationNode; 129 } 130 } 131 | Popular Tags |