1 23 package com.sun.enterprise.deployment.node.runtime; 24 25 import java.util.Map ; 26 import java.util.Iterator ; 27 import org.w3c.dom.Node ; 28 29 import com.sun.enterprise.deployment.node.XMLElement; 30 import com.sun.enterprise.deployment.node.DeploymentDescriptorNode; 31 import com.sun.enterprise.deployment.IASEjbCMPEntityDescriptor; 32 import com.sun.enterprise.deployment.runtime.IASEjbCMPFinder; 33 import com.sun.enterprise.deployment.runtime.PrefetchDisabledDescriptor; 34 import com.sun.enterprise.deployment.ResourceReferenceDescriptor; 35 import com.sun.enterprise.deployment.PersistenceDescriptor; 36 import com.sun.enterprise.deployment.xml.RuntimeTagNames; 37 import com.sun.enterprise.deployment.ResourcePrincipal; 38 39 45 public class CmpNode extends DeploymentDescriptorNode { 46 47 protected IASEjbCMPEntityDescriptor descriptor=null; 48 49 50 public CmpNode() { 51 registerElementHandler(new XMLElement(RuntimeTagNames.FINDER), FinderNode.class); 52 registerElementHandler(new XMLElement(RuntimeTagNames.PREFETCH_DISABLED), PrefetchDisabledNode.class); 53 } 54 55 58 public Object getDescriptor() { 59 if (descriptor == null) { 60 Object desc = getParentNode().getDescriptor(); 61 if (desc instanceof IASEjbCMPEntityDescriptor) { 62 descriptor = (IASEjbCMPEntityDescriptor) desc; 63 } 64 } 65 return descriptor; 66 } 67 68 74 protected Map getDispatchTable() { 75 Map dispatchTable = super.getDispatchTable(); 76 dispatchTable.put(RuntimeTagNames.MAPPING_PROPERTIES, "setMappingProperties"); 77 dispatchTable.put(RuntimeTagNames.IS_ONE_ONE_CMP, null); 79 return dispatchTable; 80 } 81 82 88 public void addDescriptor(Object newDescriptor) { 89 getDescriptor(); 90 if (newDescriptor instanceof IASEjbCMPFinder ) { 91 descriptor.addOneOneFinder((IASEjbCMPFinder ) newDescriptor); 92 } 93 else if (newDescriptor instanceof PrefetchDisabledDescriptor) { 94 descriptor.setPrefetchDisabledDescriptor((PrefetchDisabledDescriptor)newDescriptor); 95 } else super.addDescriptor(descriptor); 96 } 97 98 106 public Node writeDescriptor(Node parent, String nodeName, IASEjbCMPEntityDescriptor ejbDescriptor) { 107 Node cmpNode = super.writeDescriptor(parent, nodeName, ejbDescriptor); 108 appendTextChild(cmpNode, RuntimeTagNames.MAPPING_PROPERTIES, ejbDescriptor.getMappingProperties()); 109 Map finders = ejbDescriptor.getOneOneFinders(); 110 if (!finders.isEmpty()) { 111 Node findersNode = appendChild(cmpNode, RuntimeTagNames.ONE_ONE_FINDERS); 112 FinderNode fn = new FinderNode(); 113 for (Iterator finderIterator = finders.values().iterator();finderIterator.hasNext();) { 114 IASEjbCMPFinder aFinder = (IASEjbCMPFinder) finderIterator.next(); 115 fn.writeDescriptor(findersNode, RuntimeTagNames.FINDER, aFinder); 116 } 117 } 118 119 PrefetchDisabledDescriptor prefetchDisabledDesc = 121 ejbDescriptor.getPrefetchDisabledDescriptor(); 122 if (prefetchDisabledDesc != null) { 123 PrefetchDisabledNode prefetchDisabledNode = 124 new PrefetchDisabledNode(); 125 prefetchDisabledNode.writeDescriptor(cmpNode, 126 RuntimeTagNames.PREFETCH_DISABLED, prefetchDisabledDesc); 127 } 128 129 return cmpNode; 130 } 131 } 132 | Popular Tags |