1 22 package org.jboss.metadata; 23 24 import org.jboss.webservice.metadata.serviceref.ServiceRefMetaData; 25 import org.jboss.xb.binding.ObjectModelFactory; 26 import org.jboss.xb.binding.UnmarshallingContext; 27 28 import org.jboss.logging.Logger; 29 import org.xml.sax.Attributes ; 30 31 import javax.persistence.PersistenceContextType; 32 import javax.xml.namespace.QName ; 33 34 39 public abstract class DDObjectFactory implements ObjectModelFactory 40 { 41 private static final Logger log = Logger 42 .getLogger(DDObjectFactory.class); 43 44 public Object newChild(PersistenceUnitRef ref, 45 UnmarshallingContext navigator, String namespaceURI, String localName, 46 Attributes attrs) 47 { 48 return newRefChild(ref, localName); 49 } 50 51 public Object newChild(PersistenceContextRef ref, 52 UnmarshallingContext navigator, String namespaceURI, String localName, 53 Attributes attrs) 54 { 55 return newRefChild(ref, localName); 56 } 57 58 public Object newChild(EnvEntryMetaData ref, 59 UnmarshallingContext navigator, String namespaceURI, String localName, 60 Attributes attrs) 61 { 62 return newRefChild(ref, localName); 63 } 64 65 public Object newChild(EjbRefMetaData ref, 66 UnmarshallingContext navigator, String namespaceURI, String localName, 67 Attributes attrs) 68 { 69 return newRefChild(ref, localName); 70 } 71 72 public Object newChild(EjbLocalRefMetaData ref, 73 UnmarshallingContext navigator, String namespaceURI, String localName, 74 Attributes attrs) 75 { 76 return newRefChild(ref, localName); 77 } 78 79 public Object newChild(ResourceRefMetaData ref, 80 UnmarshallingContext navigator, String namespaceURI, String localName, 81 Attributes attrs) 82 { 83 return newRefChild(ref, localName); 84 } 85 86 public Object newChild(ResourceEnvRefMetaData ref, 87 UnmarshallingContext navigator, String namespaceURI, String localName, 88 Attributes attrs) 89 { 90 return newRefChild(ref, localName); 91 } 92 93 public Object newChild(MessageDestinationRefMetaData ref, 94 UnmarshallingContext navigator, String namespaceURI, String localName, 95 Attributes attrs) 96 { 97 return newRefChild(ref, localName); 98 } 99 100 public Object newChild(ServiceRefMetaData ref, 101 UnmarshallingContext navigator, String namespaceURI, String localName, 102 Attributes attrs) 103 { 104 return newRefChild(ref, localName); 105 107 } 108 109 public Object newChild(JndiRef ref, 110 UnmarshallingContext navigator, String namespaceURI, String localName, 111 Attributes attrs) 112 { 113 return newRefChild(ref, localName); 114 } 115 116 public void addChild(PersistenceUnitRef parent, InjectionTarget target, 117 UnmarshallingContext navigator, String namespaceURI, String localName) 118 { 119 parent.setInjectionTarget(target); 120 } 121 122 public void addChild(PersistenceContextRef parent, InjectionTarget target, 123 UnmarshallingContext navigator, String namespaceURI, String localName) 124 { 125 parent.setInjectionTarget(target); 126 } 127 128 public void addChild(EnvEntryMetaData parent, InjectionTarget target, 129 UnmarshallingContext navigator, String namespaceURI, String localName) 130 { 131 parent.setInjectionTarget(target); 132 } 133 134 public void addChild(EjbRefMetaData parent, InjectionTarget target, 135 UnmarshallingContext navigator, String namespaceURI, String localName) 136 { 137 parent.setInjectionTarget(target); 138 } 139 140 public void addChild(EjbLocalRefMetaData parent, InjectionTarget target, 141 UnmarshallingContext navigator, String namespaceURI, String localName) 142 { 143 parent.setInjectionTarget(target); 144 } 145 146 public void addChild(ResourceRefMetaData parent, InjectionTarget target, 147 UnmarshallingContext navigator, String namespaceURI, String localName) 148 { 149 parent.setInjectionTarget(target); 150 } 151 152 public void addChild(ResourceEnvRefMetaData parent, InjectionTarget target, 153 UnmarshallingContext navigator, String namespaceURI, String localName) 154 { 155 parent.setInjectionTarget(target); 156 } 157 158 public void addChild(MessageDestinationRefMetaData parent, InjectionTarget target, 159 UnmarshallingContext navigator, String namespaceURI, String localName) 160 { 161 parent.setInjectionTarget(target); 162 } 163 164 public void addChild(ServiceRefMetaData parent, InjectionTarget target, 165 UnmarshallingContext navigator, String namespaceURI, String localName) 166 { 167 parent.setInjectionTarget(target); 168 } 169 170 public void addChild(JndiRef parent, InjectionTarget target, 171 UnmarshallingContext navigator, String namespaceURI, String localName) 172 { 173 parent.setInjectionTarget(target); 174 } 175 176 public void setValue(EjbLocalRefMetaData ref, UnmarshallingContext navigator, 177 String namespaceURI, String localName, String value) 178 { 179 if (localName.equals("ejb-ref-name")) 180 { 181 ref.setName(getValue(localName, value)); 182 } 183 else if (localName.equals("ejb-ref-type")) 184 { 185 ref.setType(getValue(localName, value)); 186 } 187 else if (localName.equals("local-home")) 188 { 189 ref.setLocalHome(getValue(localName, value)); 190 } 191 else if (localName.equals("local")) 192 { 193 ref.setLocal(getValue(localName, value)); 194 } 195 else if (localName.equals("ejb-link")) 196 { 197 ref.setLink(getValue(localName, value)); 198 } 199 else if (localName.equals("mapped-name") || localName.equals("local-jndi-name") || localName.equals("jndi-name")) 200 { 201 ref.setJndiName(getValue(localName, value)); 202 } 203 else if (localName.equals("ignore-dependency")) 204 { 205 ref.setIgnoreDependency(true); 206 } 207 } 208 209 public void setValue(EjbRefMetaData ref, UnmarshallingContext navigator, 210 String namespaceURI, String localName, String value) 211 { 212 if (localName.equals("ejb-ref-name")) 213 { 214 ref.setName(getValue(localName, value)); 215 } 216 else if (localName.equals("ejb-ref-type")) 217 { 218 ref.setType(getValue(localName, value)); 219 } 220 else if (localName.equals("home")) 221 { 222 ref.setHome(getValue(localName, value)); 223 } 224 else if (localName.equals("remote")) 225 { 226 ref.setRemote(getValue(localName, value)); 227 } 228 else if (localName.equals("ejb-link")) 229 { 230 ref.setLink(getValue(localName, value)); 231 } 232 else if (localName.equals("mapped-name") || localName.equals("jndi-name")) 233 { 234 ref.setJndiName(getValue(localName, value)); 235 } 236 else if (localName.equals("ignore-dependency")) 237 { 238 ref.setIgnoreDependency(true); 239 } 240 } 241 242 245 public void setValue(InjectionTarget target, UnmarshallingContext navigator, 246 String namespaceURI, String localName, String value) 247 { 248 if (localName.equals("injection-target-class")) 249 { 250 target.setTargetClass(getValue(localName, value)); 251 } 252 else if (localName.equals("injection-target-name")) 253 { 254 target.setTargetName(getValue(localName, value)); 255 } 256 } 257 258 261 public void setValue(MessageDestinationRefMetaData ref, UnmarshallingContext navigator, 262 String namespaceURI, String localName, String value) 263 { 264 if (localName.equals("description")) 265 { 266 ref.setDescription(getValue(localName, value)); 267 } 268 else if (localName.equals("message-destination-ref-name")) 269 { 270 ref.setRefName(getValue(localName, value)); 271 } 272 else if (localName.equals("message-destination-type")) 273 { 274 ref.setType(getValue(localName, value)); 275 } 276 else if (localName.equals("message-destination-usage")) 277 { 278 ref.setUsage(getValue(localName, value)); 279 } 280 else if (localName.equals("message-destination-link")) 281 { 282 ref.setLink(getValue(localName, value)); 283 } 284 else if (localName.equals("mapped-name") || localName.equals("jndi-name")) 285 { 286 ref.setJndiName(getValue(localName, value)); 287 } 288 } 289 290 public void setValue(EnvEntryMetaData entry, UnmarshallingContext navigator, 291 String namespaceURI, String localName, String value) 292 { 293 if (localName.equals("description")) 294 { 295 entry.setDescription(getValue(localName, value)); 296 } 297 else if (localName.equals("env-entry-name")) 298 { 299 entry.setName(getValue(localName, value)); 300 } 301 else if (localName.equals("env-entry-type")) 302 { 303 entry.setType(getValue(localName, value)); 304 } 305 else if (localName.equals("env-entry-value")) 306 { 307 entry.setValue(getValue(localName, value)); 308 } 309 } 310 311 public void setValue(ResourceEnvRefMetaData envRef, UnmarshallingContext navigator, 312 String namespaceURI, String localName, String value) 313 { 314 if (localName.equals("res-ref-name") 315 || localName.equals("resource-env-ref-name")) 316 { 317 envRef.setRefName(getValue(localName, value)); 318 } 319 else if (localName.equals("res-type") 320 || localName.equals("resource-env-ref-type")) 321 { 322 envRef.setType(getValue(localName, value)); 323 } 324 else if (localName.equals("res-auth")) 325 { 326 envRef.setContainerAuth(getValue(localName, value)); 327 } 328 else if (localName.equals("res-sharing-scope")) 329 { 330 envRef.setSharable(getValue(localName, value)); 331 } 332 else if (localName.equals("mapped-name") || localName.equals("jndi-name")) 333 { 334 envRef.setJndiName(getValue(localName, value)); 335 } 336 } 337 338 public void setValue(ResourceRefMetaData ref, UnmarshallingContext navigator, 339 String namespaceURI, String localName, String value) 340 { 341 if (localName.equals("res-ref-name") 342 || localName.equals("resource-env-ref-name")) 343 { 344 ref.setRefName(getValue(localName, value)); 345 } 346 else if (localName.equals("res-type") 347 || localName.equals("resource-env-ref-type")) 348 { 349 ref.setType(getValue(localName, value)); 350 } 351 else if (localName.equals("res-auth")) 352 { 353 ref.setContainerAuth(getValue(localName, value)); 354 } 355 else if (localName.equals("res-sharing-scope")) 356 { 357 ref.setSharable(getValue(localName, value)); 358 } 359 else if (localName.equals("mapped-name") || localName.equals("jndi-name")) 360 { 361 ref.setJndiName(getValue(localName, value)); 362 } 363 else if (localName.equals("res-url")) 364 { 365 ref.setResURL(getValue(localName, value)); 366 } 367 else if (localName.equals("resource-name")) 368 { 369 ref.setResourceName(getValue(localName, value)); 370 } 371 } 372 373 public void setValue(ServiceRefMetaData ref, UnmarshallingContext navigator, 374 String namespaceURI, String localName, String value) 375 { 376 if (localName.equals("service-ref-name")) 377 { 378 ref.setServiceRefName(getValue(localName, value)); 379 } 380 else if (localName.equals("service-res-type")) 381 { 382 ref.setServiceResType(getValue(localName, value)); 383 } 384 else if (localName.equals("service-interface")) 385 { 386 ref.setServiceInterface(getValue(localName, value)); 387 } 388 else if (localName.equals("service-qname")) 389 { 390 QName serviceQName = new QName (namespaceURI, value); 391 ref.setServiceQName(serviceQName); 392 } 393 else if (localName.equals("wsdl-file")) 394 { 395 ref.setWsdlFile(getValue(localName, value)); 396 } 397 else if (localName.equals("jaxrpc-mapping-file")) 398 { 399 ref.setJaxrpcMappingFile(getValue(localName, value)); 400 } 401 else if (localName.equals("mapped-name")) 402 { 403 ref.setMappedName(getValue(localName, value)); 404 } 405 } 406 407 public void setValue(SecurityRoleMetaData role, UnmarshallingContext navigator, 408 String namespaceURI, String localName, String value) 409 { 410 if (localName.equals("role-name")) 411 { 412 role.setRoleName(getValue(localName, value)); 413 } 414 } 415 416 public void setValue(JndiRef ref, UnmarshallingContext navigator, 417 String namespaceURI, String localName, String value) 418 { 419 if (localName.equals("mapped-name")) 420 { 421 ref.setMappedName(getValue(localName, value)); 422 } 423 else if (localName.equals("jndi-ref-name")) 424 { 425 ref.setJndiRefName(getValue(localName, value)); 426 } 427 } 428 429 public void setValue(RunAs runAs, UnmarshallingContext navigator, 430 String namespaceURI, String localName, String value) 431 { 432 if (localName.equals("role-name")) 433 { 434 runAs.setRoleName(getValue(localName, value)); 435 } 436 } 437 438 public void setValue(SecurityRoleRefMetaData ref, UnmarshallingContext navigator, 439 String namespaceURI, String localName, String value) 440 { 441 if (localName.equals("role-name")) 442 { 443 ref.setName(getValue(localName, value)); 444 } 445 else if (localName.equals("role-link")) 446 { 447 ref.setLink(getValue(localName, value)); 448 } 449 } 450 451 public void setValue(Listener listener, UnmarshallingContext navigator, 452 String namespaceURI, String localName, String value) 453 { 454 if (localName.equals("listener-class")) 455 { 456 listener.setListenerClass(getValue(localName, value)); 457 } 458 } 459 460 public void setValue(MessageDestinationMetaData destination, UnmarshallingContext navigator, 461 String namespaceURI, String localName, String value) 462 { 463 if (localName.equals("message-destination-name")) 464 { 465 destination.setName(getValue(localName, value)); 466 } 467 else if (localName.equals("mapped-name") || localName.equals("jndi-name")) 468 { 469 destination.setJNDIName(getValue(localName, value)); 470 } 471 } 472 473 public void setValue(PersistenceUnitRef ref, UnmarshallingContext navigator, 474 String namespaceURI, String localName, String value) 475 { 476 if (localName.equals("persistence-unit-ref-name")) 477 { 478 ref.setRefName(getValue(localName, value)); 479 } 480 else if (localName.equals("persistence-unit-name")) 481 { 482 ref.setUnitName(getValue(localName, value)); 483 } 484 else 485 { 486 throw new RuntimeException ("INVALID element<" + localName + "> in <persistence-unit-ref>"); 487 } 488 } 489 490 protected Object newEnvRefGroupChild(String localName) 491 { 492 Object child = null; 493 494 if (localName.equals("ejb-local-ref")) 495 { 496 child = new EjbLocalRefMetaData(); 497 } 498 else if (localName.equals("ejb-ref")) 499 { 500 child = new EjbRefMetaData(); 501 } 502 else if (localName.equals("resource-ref")) 503 { 504 child = new ResourceRefMetaData(); 505 } 506 else if (localName.equals("resource-env-ref")) 507 { 508 child = new ResourceEnvRefMetaData(); 509 } 510 else if (localName.equals("env-entry")) 511 { 512 child = new EnvEntryMetaData(); 513 } 514 else if (localName.equals("message-destination-ref")) 515 { 516 child = new MessageDestinationRefMetaData(); 517 } 518 else if (localName.equals("service-ref")) 519 { 520 child = new ServiceRefMetaData(); 521 } 522 else if (localName.equals("jndi-ref")) 523 { 524 child = new JndiRef(); 525 } 526 else if (localName.equals("persistence-unit-ref")) 527 { 528 child = new PersistenceUnitRef(); 529 } 530 else if (localName.equals("persistence-context-ref")) 531 { 532 child = new PersistenceContextRef(); 533 } 534 535 return child; 536 } 537 538 protected Object newRefChild(Ref ref, String localName) 539 { 540 Object child = null; 541 542 if (localName.equals("ignore-dependency")) 543 { 544 ref.setIgnoreDependency(true); 545 } 546 else if (localName.equals("injection-target")) 547 { 548 InjectionTarget target = new InjectionTarget(); 549 child = target; 550 } 551 552 return child; 553 } 554 555 public void setValue(PersistenceContextRef ref, UnmarshallingContext navigator, 556 String namespaceURI, String localName, String value) 557 { 558 if (localName.equals("persistence-context-ref-name")) 559 { 560 ref.setRefName(getValue(localName, value)); 561 } 562 else if (localName.equals("persistence-unit-name")) 563 { 564 ref.setUnitName(getValue(localName, value)); 565 } 566 else if(localName.equals("persistence-context-type")) 567 { 568 if (value.toLowerCase().equals("transaction")) 569 { 570 ref.setPersistenceContextType(PersistenceContextType.TRANSACTION); 571 } 572 else 573 { 574 ref.setPersistenceContextType(PersistenceContextType.EXTENDED); 575 } 576 } 577 } 578 579 protected String getValue(String name, String value) 580 { 581 return value; 582 } 583 } 584 | Popular Tags |