1 22 package org.jboss.metadata; 23 24 import java.util.ArrayList ; 25 import java.util.Iterator ; 26 27 import org.w3c.dom.Element ; 28 29 import org.jboss.deployment.DeploymentException; 30 31 37 public class QueryMetaData extends MetaData { 38 public final static String REMOTE = "Remote"; 39 public final static String LOCAL = "Local"; 40 41 private String description; 42 private String methodName; 43 private ArrayList methodParams; 44 private String resultTypeMapping; 45 private String ejbQl; 46 47 public QueryMetaData () { 48 methodParams = new ArrayList (); 49 resultTypeMapping = LOCAL; 50 } 51 52 56 public String getDescription() { 57 return description; 58 } 59 60 64 public String getMethodName() { 65 return methodName; 66 } 67 68 public void setMethodName(String methodName) 69 { 70 this.methodName = methodName; 71 } 72 73 77 public Iterator getMethodParams() { 78 return methodParams.iterator(); 79 } 80 81 public void addMethodParam(String param) 82 { 83 methodParams.add(param); 84 } 85 86 91 public String getResultTypeMapping() { 92 return resultTypeMapping; 93 } 94 95 public void setResultTypeMapping(String resultTypeMapping) 96 { 97 if(!LOCAL.equals(resultTypeMapping) && !REMOTE.equals(resultTypeMapping)) 98 { 99 throw new IllegalArgumentException ("Expected " + LOCAL + " or " + REMOTE + " but was " + resultTypeMapping); 100 } 101 this.resultTypeMapping = resultTypeMapping; 102 } 103 104 108 public String getEjbQl() { 109 return ejbQl; 110 } 111 112 public void setEjbQl(String ejbQl) 113 { 114 this.ejbQl = ejbQl; 115 } 116 117 public boolean isResultTypeLocal() 118 { 119 return LOCAL.equals(resultTypeMapping); 120 } 121 122 127 public void importEjbJarXml(Element element) throws DeploymentException { 128 description = getOptionalChildContent(element, "description"); 130 131 Element queryMethod = getUniqueChild(element, "query-method"); 133 134 methodName = getUniqueChildContent(queryMethod, "method-name"); 136 137 Element methodParamsElement = 139 getUniqueChild(queryMethod, "method-params"); 140 Iterator iterator = 141 getChildrenByTagName(methodParamsElement, "method-param"); 142 while (iterator.hasNext()) { 143 final String param = getElementContent((Element )iterator.next()); 144 if(param == null || param.trim().length() == 0) 145 { 146 throw new DeploymentException("method-param tag has no value for method: " + methodName); 147 } 148 methodParams.add(param); 149 } 150 151 resultTypeMapping = 153 getOptionalChildContent(element, "result-type-mapping"); 154 if(resultTypeMapping == null || LOCAL.equals(resultTypeMapping)) { 155 resultTypeMapping = LOCAL; 156 } else if(REMOTE.equals(resultTypeMapping)) { 157 resultTypeMapping = REMOTE; 158 } else { 159 throw new DeploymentException("result-type-mapping must be '" + 160 REMOTE + "' or '" + LOCAL + "', if specified"); 161 } 162 163 ejbQl = getElementContent(getUniqueChild(element, "ejb-ql")); 164 } 165 } 166 169 | Popular Tags |