1 23 24 package com.sun.enterprise.deployment.node.ejb; 25 26 import java.util.Map ; 27 import java.util.logging.Level ; 28 import org.w3c.dom.Node ; 29 30 import com.sun.enterprise.deployment.node.XMLElement; 31 import com.sun.enterprise.deployment.node.DeploymentDescriptorNode; 32 import com.sun.enterprise.deployment.node.MethodNode; 33 34 import com.sun.enterprise.deployment.Descriptor; 35 import com.sun.enterprise.deployment.QueryDescriptor; 36 import com.sun.enterprise.deployment.MethodDescriptor; 37 import com.sun.enterprise.deployment.xml.EjbTagNames; 38 import com.sun.enterprise.deployment.util.DOLUtils; 39 40 46 public class QueryNode extends DeploymentDescriptorNode { 47 48 private QueryDescriptor descriptor = null; 49 50 51 public QueryNode() { 52 super(); 53 registerElementHandler(new XMLElement(EjbTagNames.QUERY_METHOD), 54 MethodNode.class, "setQueryMethodDescriptor"); 55 } 56 57 61 public Object getDescriptor() { 62 if (descriptor == null) { 63 descriptor = (QueryDescriptor) super.getDescriptor(); 64 } 65 return descriptor; 66 } 67 68 74 protected Map getDispatchTable() { 75 Map table = super.getDispatchTable(); 77 table.put(EjbTagNames.EJB_QL, "setQuery"); 78 return table; 79 } 80 81 82 88 public void setElementValue(XMLElement element, String value) { 89 if (EjbTagNames.QUERY_RESULT_TYPE_MAPPING.equals(element.getQName())) { 90 if (EjbTagNames.QUERY_REMOTE_TYPE_MAPPING.equals(value)) { 91 descriptor.setHasRemoteReturnTypeMapping(); 92 } else if (EjbTagNames.QUERY_LOCAL_TYPE_MAPPING.equals(value)) { 93 descriptor.setHasLocalReturnTypeMapping(); 94 } else { 95 DOLUtils.getDefaultLogger().log(Level.SEVERE, "enterprise.deployment.backend.addDescriptorFailure", 96 new Object [] {((Descriptor) getParentNode().getDescriptor()).getName() , value}); 97 } 98 } else { 99 super.setElementValue(element, value); 100 } 101 } 102 103 111 public Node writeDescriptor(Node parent, String nodeName, QueryDescriptor descriptor) { 112 Node queryNode = super.writeDescriptor(parent, nodeName, descriptor); 113 114 writeLocalizedDescriptions(queryNode, descriptor); 115 116 MethodNode methodNode = new MethodNode(); 118 methodNode.writeQueryMethodDescriptor(queryNode, EjbTagNames.QUERY_METHOD, 119 descriptor.getQueryMethodDescriptor()); 120 121 if (descriptor.getHasRemoteReturnTypeMapping()) { 122 appendTextChild(queryNode, EjbTagNames.QUERY_RESULT_TYPE_MAPPING, 123 EjbTagNames.QUERY_REMOTE_TYPE_MAPPING); 124 } else { 125 if (descriptor.getHasLocalReturnTypeMapping()) { 126 appendTextChild(queryNode, EjbTagNames.QUERY_RESULT_TYPE_MAPPING, 127 EjbTagNames.QUERY_LOCAL_TYPE_MAPPING); 128 } 129 } 130 String ejbqlText = descriptor.getIsEjbQl() ? descriptor.getQuery() : ""; 133 Node child = appendChild(queryNode, EjbTagNames.EJB_QL); 134 child.appendChild(getOwnerDocument(child).createTextNode(ejbqlText)); 135 136 return queryNode; 137 } 138 } 139 | Popular Tags |