1 22 package org.jboss.aop; 23 24 import java.util.ArrayList ; 25 import java.util.HashMap ; 26 import java.util.LinkedHashMap ; 27 import java.util.List ; 28 import java.util.Map ; 29 30 import org.jboss.aop.advice.AdviceStack; 31 import org.jboss.aop.advice.AspectDefinition; 32 import org.jboss.aop.advice.InterceptorFactory; 33 import org.jboss.aop.metadata.ClassMetaDataLoader; 34 import org.jboss.aop.pointcut.CFlowStack; 35 import org.jboss.aop.pointcut.DynamicCFlow; 36 import org.jboss.aop.pointcut.Pointcut; 37 import org.jboss.aop.pointcut.PointcutStats; 38 import org.jboss.aop.pointcut.Typedef; 39 import org.jboss.aop.pointcut.ast.ClassExpression; 40 41 47 public class Domain extends AspectManager 48 { 49 protected AspectManager parent; 50 protected boolean parentFirst; 51 protected boolean inheritsDeclarations = true; 52 protected boolean inheritsBindings = false; 53 54 55 public Domain(AspectManager manager, boolean parentFirst) 56 { 57 this.parent = manager; 58 this.parentFirst = parentFirst; 59 } 60 61 62 67 public void setInheritsDeclarations(boolean inheritsDeclarations) 68 { 69 this.inheritsDeclarations = inheritsDeclarations; 70 } 71 72 public void setInheritsBindings(boolean inheritBindings) 73 { 74 this.inheritsBindings = inheritBindings; 75 if (inheritsBindings) 76 { 77 parent.subscribeSubDomain(this); 78 } 79 else 80 { 81 parent.unsubscribeSubDomain(this); 82 } 83 } 84 85 86 public void removeBindings(ArrayList binds) 87 { 88 super.removeBindings(binds); 89 } 90 91 public LinkedHashMap getBindings() 92 { 93 if (inheritsBindings) 94 { 95 if (!parentFirst) 96 { 97 LinkedHashMap map = new LinkedHashMap (parent.getBindings()); 99 map.putAll(this.bindings); 100 return map; 101 } 102 else 103 { 104 LinkedHashMap map = new LinkedHashMap (this.bindings); 105 map.putAll(parent.getBindings()); 106 return map; 107 } 108 } 109 return super.getBindings(); 110 } 111 112 public LinkedHashMap getPointcuts() 113 { 114 if (inheritsBindings) 115 { 116 if (!parentFirst) 117 { 118 LinkedHashMap map = new LinkedHashMap (parent.getPointcuts()); 120 map.putAll(this.pointcuts); 121 return map; 122 } 123 else 124 { 125 LinkedHashMap map = new LinkedHashMap (this.pointcuts); 126 map.putAll(parent.getPointcuts()); 127 return map; 128 } 129 } 130 return super.getPointcuts(); 131 } 132 133 public LinkedHashMap getPointcutInfos() 134 { 135 if (inheritsBindings) 136 { 137 if (!parentFirst) 138 { 139 LinkedHashMap map = new LinkedHashMap (parent.getPointcutInfos()); 141 map.putAll(this.pointcutInfos); 142 return map; 143 } 144 else 145 { 146 LinkedHashMap map = new LinkedHashMap (this.pointcutInfos); 147 map.putAll(parent.getPointcutInfos()); 148 return map; 149 } 150 } 151 return super.getPointcutInfos(); 152 } 153 154 public List getAnnotationIntroductions() 155 { 156 157 if (inheritsBindings) 158 { 159 List result = new ArrayList (); 160 if (!parentFirst) 161 { 162 result.addAll(parent.getAnnotationIntroductions()); 164 synchronized (annotationIntroductions) 165 { 166 result = new ArrayList (annotationIntroductions.values()); 167 } 168 return result; 169 } 170 else 171 { 172 synchronized (annotationIntroductions) 173 { 174 result = new ArrayList (annotationIntroductions.values()); 175 } 176 result.addAll(parent.getAnnotationIntroductions()); 177 return result; 178 } 179 } 180 181 return super.getAnnotationIntroductions(); 182 183 } 184 185 public List getAnnotationOverrides() 186 { 187 if (inheritsBindings) 188 { 189 ArrayList list = new ArrayList (); 190 if (!parentFirst) 191 { 192 list.addAll(parent.getAnnotationOverrides()); 194 synchronized (annotationOverrides) 195 { 196 list.addAll(annotationOverrides.values()); 197 } 198 return list; 199 } 200 else 201 { 202 synchronized (annotationOverrides) 203 { 204 list.addAll(annotationOverrides.values()); 205 } 206 list.addAll(parent.getAnnotationOverrides()); 207 return list; 208 } 209 } 210 return super.getAnnotationOverrides(); 211 } 212 213 public Map getInterfaceIntroductions() 214 { 215 if (inheritsBindings) 216 { 217 HashMap map = new HashMap (); 218 if (!parentFirst) 219 { 220 map.putAll(parent.getInterfaceIntroductions()); 222 synchronized (interfaceIntroductions) 223 { 224 map.putAll(interfaceIntroductions); 225 } 226 return map; 227 } 228 else 229 { 230 synchronized (interfaceIntroductions) 231 { 232 map.putAll(interfaceIntroductions); 233 } 234 map.putAll(parent.getInterfaceIntroductions()); 235 return map; 236 } 237 } 238 return super.getInterfaceIntroductions(); 239 } 240 241 public Map getTypedefs() 242 { 243 if (inheritsBindings) 244 { 245 HashMap map = new HashMap (); 246 if (!parentFirst) 247 { 248 map.putAll(parent.getTypedefs()); 250 synchronized (typedefs) 251 { 252 map.putAll(typedefs); 253 } 254 return map; 255 } 256 else 257 { 258 synchronized (typedefs) 259 { 260 map.putAll(typedefs); 261 } 262 map.putAll(parent.getTypedefs()); 263 return map; 264 } 265 } 266 return super.getTypedefs(); 267 } 268 269 public Map getInterceptorStacks() 270 { 271 if (inheritsBindings) 272 { 273 HashMap map = new HashMap (); 274 if (!parentFirst) 275 { 276 map.putAll(parent.getInterceptorStacks()); 278 synchronized (interceptorStacks) 279 { 280 map.putAll(interceptorStacks); 281 } 282 return map; 283 } 284 else 285 { 286 synchronized (interceptorStacks) 287 { 288 map.putAll(interceptorStacks); 289 } 290 map.putAll(parent.getInterceptorStacks()); 291 return map; 292 } 293 } 294 return super.getInterceptorStacks(); 295 } 296 297 public Map getClassMetaDataLoaders() 298 { 299 if (inheritsBindings) 300 { 301 HashMap map = new HashMap (); 302 if (!parentFirst) 303 { 304 map.putAll(parent.getClassMetaDataLoaders()); 306 synchronized (classMetaDataLoaders) 307 { 308 map.putAll(classMetaDataLoaders); 309 } 310 return map; 311 } 312 else 313 { 314 synchronized (classMetaDataLoaders) 315 { 316 map.putAll(classMetaDataLoaders); 317 } 318 map.putAll(parent.getClassMetaDataLoaders()); 319 return map; 320 } 321 } 322 return super.getClassMetaDataLoaders(); 323 } 324 325 public Map getCflowStacks() 326 { 327 if (inheritsBindings) 328 { 329 HashMap map = new HashMap (); 330 if (!parentFirst) 331 { 332 map.putAll(parent.getCflowStacks()); 334 synchronized (cflowStacks) 335 { 336 map.putAll(cflowStacks); 337 } 338 return map; 339 } 340 else 341 { 342 synchronized (cflowStacks) 343 { 344 map.putAll(cflowStacks); 345 } 346 map.putAll(parent.getCflowStacks()); 347 return map; 348 } 349 } 350 return super.getCflowStacks(); 351 } 352 353 public Map getDynamicCFlows() 354 { 355 if (inheritsBindings) 356 { 357 HashMap map = new HashMap (); 358 if (!parentFirst) 359 { 360 map.putAll(parent.getDynamicCFlows()); 362 synchronized (dynamicCFlows) 363 { 364 map.putAll(dynamicCFlows); 365 } 366 return map; 367 } 368 else 369 { 370 synchronized (dynamicCFlows) 371 { 372 map.putAll(dynamicCFlows); 373 } 374 map.putAll(parent.getDynamicCFlows()); 375 return map; 376 } 377 } 378 return super.getDynamicCFlows(); 379 } 380 381 public Map getPerVMAspects() 382 { 383 if (inheritsBindings) 384 { 385 HashMap map = new HashMap (); 386 if (!parentFirst) 387 { 388 map.putAll(parent.getPerVMAspects()); 390 synchronized (perVMAspects) 391 { 392 map.putAll(perVMAspects); 393 } 394 return map; 395 } 396 else 397 { 398 synchronized (perVMAspects) 399 { 400 map.putAll(perVMAspects); 401 } 402 map.putAll(parent.getPerVMAspects()); 403 return map; 404 } 405 } 406 return super.getPerVMAspects(); 407 } 408 409 public LinkedHashMap getPrecedenceDefs() 410 { 411 if (inheritsDeclarations) 412 { 413 if (!parentFirst) 414 { 415 LinkedHashMap map = new LinkedHashMap (parent.getPrecedenceDefs()); 417 map.putAll(this.precedenceDefs); 418 return map; 419 } 420 else 421 { 422 LinkedHashMap map = new LinkedHashMap (this.precedenceDefs); 423 map.putAll(parent.getPrecedenceDefs()); 424 return map; 425 } 426 } 427 return super.getPrecedenceDefs(); 428 } 429 430 public Map getClassMetaData() 431 { 432 if (inheritsBindings) 433 { 434 HashMap map = new HashMap (); 435 if (!parentFirst) 436 { 437 map.putAll(parent.getClassMetaData()); 439 synchronized (classMetaData) 440 { 441 map.putAll(classMetaData); 442 } 443 return map; 444 } 445 else 446 { 447 synchronized (classMetaData) 448 { 449 map.putAll(classMetaData); 450 } 451 map.putAll(parent.getClassMetaData()); 452 return map; 453 } 454 } 455 return super.getClassMetaData(); 456 } 457 458 public InterceptorFactory getInterceptorFactory(String name) 459 { 460 InterceptorFactory factory = null; 461 if (parentFirst) 462 { 463 factory = parent.getInterceptorFactory(name); 464 if (factory != null) return factory; 465 } 466 factory = super.getInterceptorFactory(name); 467 468 if (factory != null) return factory; 469 return parent.getInterceptorFactory(name); 470 } 471 472 public AdviceStack getAdviceStack(String name) 473 { 474 AdviceStack factory = null; 475 if (parentFirst) 476 { 477 factory = parent.getAdviceStack(name); 478 if (factory != null) return factory; 479 } 480 factory = super.getAdviceStack(name); 481 482 if (factory != null) return factory; 483 return parent.getAdviceStack(name); 484 } 485 486 public Object getPerVMAspect(AspectDefinition def) 487 { 488 return getPerVMAspect(def.getName()); 489 } 490 491 public Object getPerVMAspect(String def) 492 { 493 Object factory = null; 494 if (parentFirst) 495 { 496 factory = parent.getPerVMAspect(def); 497 if (factory != null) return factory; 498 } 499 factory = super.getPerVMAspect(def); 500 501 if (factory != null) return factory; 502 return parent.getPerVMAspect(def); 503 } 504 505 public AspectDefinition getAspectDefinition(String name) 506 { 507 AspectDefinition factory = null; 508 if (parentFirst) 509 { 510 factory = parent.getAspectDefinition(name); 511 if (factory != null) return factory; 512 } 513 factory = super.getAspectDefinition(name); 514 515 if (factory != null) return factory; 516 return parent.getAspectDefinition(name); 517 } 518 519 public Typedef getTypedef(String name) 520 { 521 Typedef factory = null; 522 if (parentFirst) 523 { 524 factory = parent.getTypedef(name); 525 if (factory != null) return factory; 526 } 527 factory = super.getTypedef(name); 528 529 if (factory != null) return factory; 530 return parent.getTypedef(name); 531 } 532 533 public DomainDefinition getContainer(String name) 534 { 535 DomainDefinition container = null; 536 if (parentFirst) 537 { 538 container = parent.getContainer(name); 539 if (container != null) return container; 540 } 541 container = super.getContainer(name); 542 if (container != null) return container; 543 return parent.getContainer(name); 544 } 545 546 547 548 551 public Pointcut getPointcut(String name) 552 { 553 Pointcut pointcut = null; 554 555 if (parentFirst) 556 { 557 pointcut = parent.getPointcut(name); 558 if (pointcut != null) return pointcut; 559 } 560 pointcut = super.getPointcut(name); 561 if (pointcut != null) return pointcut; 562 return parent.getPointcut(name); 563 } 564 565 public void attachMetaData(ClassAdvisor advisor, Class clazz) 566 { 567 if (inheritsBindings) 568 { 569 if (!parentFirst) 570 { 571 parent.attachMetaData(advisor, clazz); 573 super.attachMetaData(advisor, clazz); 574 } 575 else 576 { 577 super.attachMetaData(advisor, clazz); 578 parent.attachMetaData(advisor, clazz); 579 } 580 } 581 else 582 { 583 super.attachMetaData(advisor, clazz); 584 } 585 } 586 587 public CFlowStack getCFlowStack(String name) 588 { 589 if (inheritsDeclarations) 590 { 591 if (!parentFirst) 592 { 593 CFlowStack cflow = super.getCFlowStack(name); 594 if (cflow == null) 595 { 596 cflow = parent.getCFlowStack(name); 597 } 598 return cflow; 599 } 600 else 601 { 602 CFlowStack cflow = parent.getCFlowStack(name); 603 if (cflow == null) 604 { 605 cflow = super.getCFlowStack(name); 606 } 607 return cflow; 608 } 609 } 610 else 611 { 612 return super.getCFlowStack(name); 613 } 614 } 615 616 617 public DynamicCFlow getDynamicCFlow(String name) 618 { 619 if (inheritsBindings) 620 { 621 if (!parentFirst) 622 { 623 DynamicCFlow cflow = super.getDynamicCFlow(name); 624 if (cflow == null) 625 { 626 cflow = parent.getDynamicCFlow(name); 627 } 628 return cflow; 629 } 630 else 631 { 632 DynamicCFlow cflow = parent.getDynamicCFlow(name); 633 if (cflow == null) 634 { 635 cflow = super.getDynamicCFlow(name); 636 } 637 return cflow; 638 } 639 } 640 else 641 { 642 return super.getDynamicCFlow(name); 643 } 644 } 645 646 public ClassMetaDataLoader findClassMetaDataLoader(String group) 647 { 648 if (inheritsDeclarations) 649 { 650 if (!parentFirst) 651 { 652 ClassMetaDataLoader loader = super.findClassMetaDataLoader(group); 653 if (loader == null) 654 { 655 loader = parent.findClassMetaDataLoader(group); 656 } 657 return loader; 658 } 659 else 660 { 661 ClassMetaDataLoader loader = parent.findClassMetaDataLoader(group); 662 if (loader == null) 663 { 664 loader = super.findClassMetaDataLoader(group); 665 } 666 return loader; 667 } 668 } 669 670 return super.findClassMetaDataLoader(group); 671 } 672 673 676 677 protected Map getScopedClassLoaderDomains() 678 { 679 return parent.getScopedClassLoaderDomains(); 680 } 681 682 683 protected Map getSubDomainsPerClass() 684 { 685 return parent.getSubDomainsPerClass(); 686 } 687 688 public void addConstructionInterceptionMarker(String classname) 689 { 690 parent.addConstructionInterceptionMarker(classname); 691 } 692 693 public void addFieldInterceptionMarker(String classname) 694 { 695 parent.addFieldInterceptionMarker(classname); 696 } 697 698 public void skipReference(String classname) 699 { 700 parent.skipReference(classname); 701 } 702 703 public boolean shouldSkipConstruction(String classname) 704 { 705 return parent.shouldSkipConstruction(classname); 706 } 707 708 public boolean shouldSkipFieldAccess(String classname) 709 { 710 return parent.shouldSkipFieldAccess(classname); 711 } 712 713 public void skipConstruction(String classname) 714 { 715 parent.skipConstruction(classname); 716 } 717 718 public void skipFieldAccess(String classname) 719 { 720 parent.skipFieldAccess(classname); 721 } 722 723 public boolean convertReference(String classname) 724 { 725 return parent.convertReference(classname); 726 } 727 728 729 public ArrayList getExclude() 730 { 731 return parent.getExclude(); 732 } 733 734 735 public ArrayList getInclude() 736 { 737 return parent.getInclude(); 738 } 739 740 741 public ArrayList getIgnore() 742 { 743 return parent.getIgnore(); 744 } 745 746 747 public ClassExpression[] getIgnoreExpressions() 748 { 749 return super.getIgnoreExpressions(); 750 } 751 752 public DynamicAOPStrategy getDynamicAOPStrategy() 753 { 754 return parent.getDynamicAOPStrategy(); 755 } 756 757 public void setDynamicAOPStrategy(DynamicAOPStrategy strategy) 758 { 759 parent.setDynamicAOPStrategy(strategy); 760 } 761 762 protected void updatePointcutStats(Pointcut pointcut) 763 { 764 parent.updatePointcutStats(pointcut); 765 } 766 767 protected void updateStats(PointcutStats stats) 768 { 769 parent.updateStats(stats); 770 } 771 772 public boolean isExecution() 773 { 774 return parent.isExecution(); 775 } 776 777 public boolean isConstruction() 778 { 779 return parent.isConstruction(); 780 } 781 782 public boolean isCall() 783 { 784 return parent.isCall(); 785 } 786 787 public boolean isWithin() 788 { 789 return parent.isWithin(); 790 } 791 792 public boolean isWithincode() 793 { 794 return parent.isWithincode(); 795 } 796 797 public boolean isGet() 798 { 799 return parent.isGet(); 800 } 801 802 public boolean isSet() 803 { 804 return parent.isSet(); 805 } 806 807 } 808 | Popular Tags |