1 22 package org.jboss.metadata; 23 24 26 import org.jboss.logging.Logger; 27 import org.jboss.deployment.DeploymentException; 28 import org.jboss.webservice.metadata.serviceref.ServiceRefMetaData; 29 import org.w3c.dom.Element ; 30 31 import java.util.ArrayList ; 32 import java.util.HashMap ; 33 import java.util.Iterator ; 34 import java.net.URLClassLoader ; 35 36 42 public class ClientMetaData 43 { 44 private static Logger log = Logger.getLogger(ClientMetaData.class); 46 47 48 private String displayName; 49 50 private String jndiName; 51 52 private ArrayList environmentEntries = new ArrayList (); 53 54 private HashMap ejbReferences = new HashMap (); 55 56 private HashMap serviceReferences = new HashMap (); 57 58 private HashMap resourceReferences = new HashMap (); 59 60 private HashMap resourceEnvReferences = new HashMap (); 61 65 private HashMap resourceEnvReferenceLinks = new HashMap (); 66 67 private String callbackHandler; 68 69 70 private URLClassLoader resourceCl; 71 72 73 public void setResourceClassLoader(URLClassLoader resourceCl) 74 { 75 this.resourceCl = resourceCl; 76 } 77 78 81 public String getDisplayName() 82 { 83 return displayName; 84 } 85 86 91 public String getJndiName() 92 { 93 String name = jndiName; 94 if( name == null ) 95 name = displayName; 96 return name; 97 } 98 99 102 public ArrayList getEnvironmentEntries() 103 { 104 return environmentEntries; 105 } 106 109 public HashMap getEjbReferences() 110 { 111 return ejbReferences; 112 } 113 116 public HashMap getResourceReferences() 117 { 118 return resourceReferences; 119 } 120 123 public HashMap getResourceEnvReferences() 124 { 125 return resourceEnvReferences; 126 } 127 130 public String getCallbackHandler() 131 { 132 return callbackHandler; 133 } 134 137 public HashMap getServiceReferences() 138 { 139 return serviceReferences; 140 } 141 142 public void importClientXml(Element element) 143 throws DeploymentException 144 { 145 displayName = MetaData.getOptionalChildContent(element, "display-name"); 146 147 Iterator iterator = MetaData.getChildrenByTagName(element, "env-entry"); 149 150 while (iterator.hasNext()) 151 { 152 Element envEntry = (Element ) iterator.next(); 153 154 EnvEntryMetaData envEntryMetaData = new EnvEntryMetaData(); 155 envEntryMetaData.importEjbJarXml(envEntry); 156 157 environmentEntries.add(envEntryMetaData); 158 } 159 160 iterator = MetaData.getChildrenByTagName(element, "ejb-ref"); 162 163 while (iterator.hasNext()) 164 { 165 Element ejbRef = (Element ) iterator.next(); 166 167 EjbRefMetaData ejbRefMetaData = new EjbRefMetaData(); 168 ejbRefMetaData.importEjbJarXml(ejbRef); 169 170 ejbReferences.put(ejbRefMetaData.getName(), ejbRefMetaData); 171 } 172 173 iterator = MetaData.getChildrenByTagName(element, "service-ref"); 175 while (iterator.hasNext()) 176 { 177 Element serviceRef = (Element ) iterator.next(); 178 if (ServiceRefMetaData.isValidDoctype(serviceRef)) 179 { 180 ServiceRefMetaData refMetaData = new ServiceRefMetaData(resourceCl); 181 refMetaData.importStandardXml(serviceRef); 182 serviceReferences.put(refMetaData.getServiceRefName(), refMetaData); 183 } 184 } 185 186 Element callbackElement = MetaData.getOptionalChild(element, 188 "callback-handler"); 189 if (callbackElement != null) 190 { 191 callbackHandler = MetaData.getElementContent(callbackElement); 192 } 193 194 iterator = MetaData.getChildrenByTagName(element, "resource-ref"); 196 while (iterator.hasNext()) 197 { 198 Element resourceRef = (Element ) iterator.next(); 199 200 ResourceRefMetaData resourceRefMetaData = new ResourceRefMetaData(); 201 resourceRefMetaData.importEjbJarXml(resourceRef); 202 203 resourceReferences.put(resourceRefMetaData.getRefName(), 204 resourceRefMetaData); 205 } 206 207 iterator = MetaData.getChildrenByTagName(element, "resource-env-ref"); 209 while (iterator.hasNext()) 210 { 211 Element resourceRef = (Element ) iterator.next(); 212 ResourceEnvRefMetaData refMetaData = new ResourceEnvRefMetaData(); 213 refMetaData.importEjbJarXml(resourceRef); 214 resourceEnvReferences.put(refMetaData.getRefName(), refMetaData); 215 } 216 217 iterator = MetaData.getChildrenByTagName(element, "message-destination-ref"); 219 while (iterator.hasNext()) 220 { 221 Element resourceRef = (Element ) iterator.next(); 222 ResourceEnvRefMetaData refMetaData = new ResourceEnvRefMetaData(); 223 refMetaData.importEjbJarXml(resourceRef); 224 231 String refName = refMetaData.getRefName(); 232 String link = refMetaData.getLink(); 233 if( link != null ) 234 { 235 ArrayList linkedRefs = (ArrayList ) resourceEnvReferenceLinks.get(link); 236 if( linkedRefs == null ) 237 { 238 linkedRefs = new ArrayList (); 239 resourceEnvReferenceLinks.put(link, linkedRefs); 240 } 241 linkedRefs.add(refMetaData); 242 } 243 resourceEnvReferences.put(refName, refMetaData); 244 } 245 } 246 247 public void importJbossClientXml(Element element) throws DeploymentException 248 { 249 jndiName = MetaData.getOptionalChildContent(element, "jndi-name"); 250 251 Iterator iterator = MetaData.getChildrenByTagName(element, "ejb-ref"); 253 while (iterator.hasNext()) 254 { 255 Element ejbRef = (Element ) iterator.next(); 256 String ejbRefName = MetaData.getElementContent( 257 MetaData.getUniqueChild(ejbRef, "ejb-ref-name")); 258 EjbRefMetaData ejbRefMetaData = (EjbRefMetaData) ejbReferences.get(ejbRefName); 259 if (ejbRefMetaData == null) 260 { 261 throw new DeploymentException("ejb-ref " + ejbRefName 262 + " found in jboss-client.xml but not in application-client.xml"); 263 } 264 ejbRefMetaData.importJbossXml(ejbRef); 265 } 266 267 iterator = MetaData.getChildrenByTagName(element, "service-ref"); 269 while (iterator.hasNext()) 270 { 271 Element serviceRef = (Element ) iterator.next(); 272 String serviceRefName = MetaData.getUniqueChildContent(serviceRef, "service-ref-name"); 273 ServiceRefMetaData refMetaData = (ServiceRefMetaData)serviceReferences.get(serviceRefName); 274 if (refMetaData == null && ServiceRefMetaData.isValidDoctype(serviceRef)) 275 { 276 throw new DeploymentException("service-ref " + serviceRefName + " found in jboss-client.xml but not in application-client.xml"); 277 } 278 if (refMetaData != null) 279 refMetaData.importJBossXml(serviceRef); 280 } 281 282 iterator = MetaData.getChildrenByTagName(element, "resource-ref"); 284 while (iterator.hasNext()) 285 { 286 Element resourceRef = (Element ) iterator.next(); 287 String resRefName = MetaData.getElementContent( 288 MetaData.getUniqueChild(resourceRef, "res-ref-name")); 289 ResourceRefMetaData resourceRefMetaData = 290 (ResourceRefMetaData) resourceReferences.get(resRefName); 291 if (resourceRefMetaData == null) 292 { 293 throw new DeploymentException("resource-ref " + resRefName 294 + " found in jboss-client.xml but not in application-client.xml"); 295 } 296 resourceRefMetaData.importJbossXml(resourceRef); 297 } 298 299 iterator = MetaData.getChildrenByTagName(element, "resource-env-ref"); 301 while (iterator.hasNext()) 302 { 303 Element resourceRef = (Element ) iterator.next(); 304 String resRefName = MetaData.getElementContent( 305 MetaData.getUniqueChild(resourceRef, "resource-env-ref-name")); 306 ResourceEnvRefMetaData refMetaData = 307 (ResourceEnvRefMetaData) resourceEnvReferences.get(resRefName); 308 if (refMetaData == null) 309 { 310 ArrayList linkedRefs = (ArrayList ) resourceEnvReferenceLinks.get(resRefName); 312 if( linkedRefs != null ) 313 { 314 for(int n = 0; n < linkedRefs.size(); n ++) 315 { 316 refMetaData = (ResourceEnvRefMetaData) linkedRefs.get(n); 317 refMetaData.importJbossXml(resourceRef); 318 } 319 } 320 else 321 { 322 throw new DeploymentException("resource-env-ref " + resRefName 323 + " found in jboss-client.xml but not in application-client.xml"); 324 } 325 } 326 else 327 { 328 refMetaData.importJbossXml(resourceRef); 329 } 330 } 331 } 332 } 333 | Popular Tags |