@@ -484,7 +484,7 @@ pointcut expressions by name. The following example shows three pointcut express
484
484
@Pointcut("execution(public * \*(..))")
485
485
private void anyPublicOperation() {} // <1>
486
486
487
- @Pointcut("within(com.xyz.someapp .trading..*)")
487
+ @Pointcut("within(com.xyz.myapp .trading..*)")
488
488
private void inTrading() {} // <2>
489
489
490
490
@Pointcut("anyPublicOperation() && inTrading()")
@@ -502,7 +502,7 @@ trading module.
502
502
@Pointcut("execution(public * \*(..))")
503
503
private fun anyPublicOperation() {} // <1>
504
504
505
- @Pointcut("within(com.xyz.someapp .trading..*)")
505
+ @Pointcut("within(com.xyz.myapp .trading..*)")
506
506
private fun inTrading() {} // <2>
507
507
508
508
@Pointcut("anyPublicOperation() && inTrading()")
@@ -526,13 +526,13 @@ matching.
526
526
527
527
When working with enterprise applications, developers often want to refer to modules of the
528
528
application and particular sets of operations from within several aspects. We recommend
529
- defining a " `SystemArchitecture`" aspect that captures common pointcut expressions for
529
+ defining a `SystemArchitecture` aspect that captures common pointcut expressions for
530
530
this purpose. Such an aspect typically resembles the following example:
531
531
532
532
[source,java,indent=0,subs="verbatim",role="primary"]
533
533
.Java
534
534
----
535
- package com.xyz.someapp ;
535
+ package com.xyz.myapp ;
536
536
537
537
import org.aspectj.lang.annotation.Aspect;
538
538
import org.aspectj.lang.annotation.Pointcut;
@@ -542,26 +542,26 @@ this purpose. Such an aspect typically resembles the following example:
542
542
543
543
/**
544
544
* A join point is in the web layer if the method is defined
545
- * in a type in the com.xyz.someapp .web package or any sub-package
545
+ * in a type in the com.xyz.myapp .web package or any sub-package
546
546
* under that.
547
547
*/
548
- @Pointcut("within(com.xyz.someapp .web..*)")
548
+ @Pointcut("within(com.xyz.myapp .web..*)")
549
549
public void inWebLayer() {}
550
550
551
551
/**
552
552
* A join point is in the service layer if the method is defined
553
- * in a type in the com.xyz.someapp .service package or any sub-package
553
+ * in a type in the com.xyz.myapp .service package or any sub-package
554
554
* under that.
555
555
*/
556
- @Pointcut("within(com.xyz.someapp .service..*)")
556
+ @Pointcut("within(com.xyz.myapp .service..*)")
557
557
public void inServiceLayer() {}
558
558
559
559
/**
560
560
* A join point is in the data access layer if the method is defined
561
- * in a type in the com.xyz.someapp .dao package or any sub-package
561
+ * in a type in the com.xyz.myapp .dao package or any sub-package
562
562
* under that.
563
563
*/
564
- @Pointcut("within(com.xyz.someapp .dao..*)")
564
+ @Pointcut("within(com.xyz.myapp .dao..*)")
565
565
public void inDataAccessLayer() {}
566
566
567
567
/**
@@ -570,31 +570,31 @@ this purpose. Such an aspect typically resembles the following example:
570
570
* "service" package, and that implementation types are in sub-packages.
571
571
*
572
572
* If you group service interfaces by functional area (for example,
573
- * in packages com.xyz.someapp .abc.service and com.xyz.someapp .def.service) then
574
- * the pointcut expression "execution(* com.xyz.someapp ..service.*.*(..))"
573
+ * in packages com.xyz.myapp .abc.service and com.xyz.myapp .def.service) then
574
+ * the pointcut expression "execution(* com.xyz.myapp ..service.*.*(..))"
575
575
* could be used instead.
576
576
*
577
577
* Alternatively, you can write the expression using the 'bean'
578
578
* PCD, like so "bean(*Service)". (This assumes that you have
579
579
* named your Spring service beans in a consistent fashion.)
580
580
*/
581
- @Pointcut("execution(* com.xyz.someapp ..service.*.*(..))")
581
+ @Pointcut("execution(* com.xyz.myapp ..service.*.*(..))")
582
582
public void businessService() {}
583
583
584
584
/**
585
585
* A data access operation is the execution of any method defined on a
586
586
* dao interface. This definition assumes that interfaces are placed in the
587
587
* "dao" package, and that implementation types are in sub-packages.
588
588
*/
589
- @Pointcut("execution(* com.xyz.someapp .dao.*.*(..))")
589
+ @Pointcut("execution(* com.xyz.myapp .dao.*.*(..))")
590
590
public void dataAccessOperation() {}
591
591
592
592
}
593
593
----
594
594
[source,kotlin,indent=0,subs="verbatim",role="secondary"]
595
595
.Kotlin
596
596
----
597
- package com.xyz.someapp
597
+ package com.xyz.myapp
598
598
599
599
import org.aspectj.lang.annotation.Aspect
600
600
import org.aspectj.lang.annotation.Pointcut
@@ -606,28 +606,28 @@ this purpose. Such an aspect typically resembles the following example:
606
606
607
607
/**
608
608
* A join point is in the web layer if the method is defined
609
- * in a type in the com.xyz.someapp .web package or any sub-package
609
+ * in a type in the com.xyz.myapp .web package or any sub-package
610
610
* under that.
611
611
*/
612
- @Pointcut("within(com.xyz.someapp .web..*)")
612
+ @Pointcut("within(com.xyz.myapp .web..*)")
613
613
fun inWebLayer() {
614
614
}
615
615
616
616
/**
617
617
* A join point is in the service layer if the method is defined
618
- * in a type in the com.xyz.someapp .service package or any sub-package
618
+ * in a type in the com.xyz.myapp .service package or any sub-package
619
619
* under that.
620
620
*/
621
- @Pointcut("within(com.xyz.someapp .service..*)")
621
+ @Pointcut("within(com.xyz.myapp .service..*)")
622
622
fun inServiceLayer() {
623
623
}
624
624
625
625
/**
626
626
* A join point is in the data access layer if the method is defined
627
- * in a type in the com.xyz.someapp .dao package or any sub-package
627
+ * in a type in the com.xyz.myapp .dao package or any sub-package
628
628
* under that.
629
629
*/
630
- @Pointcut("within(com.xyz.someapp .dao..*)")
630
+ @Pointcut("within(com.xyz.myapp .dao..*)")
631
631
fun inDataAccessLayer() {
632
632
}
633
633
@@ -637,15 +637,15 @@ this purpose. Such an aspect typically resembles the following example:
637
637
* "service" package, and that implementation types are in sub-packages.
638
638
*
639
639
* If you group service interfaces by functional area (for example,
640
- * in packages com.xyz.someapp .abc.service and com.xyz.someapp .def.service) then
641
- * the pointcut expression "execution(* com.xyz.someapp ..service.*.*(..))"
640
+ * in packages com.xyz.myapp .abc.service and com.xyz.myapp .def.service) then
641
+ * the pointcut expression "execution(* com.xyz.myapp ..service.*.*(..))"
642
642
* could be used instead.
643
643
*
644
644
* Alternatively, you can write the expression using the 'bean'
645
645
* PCD, like so "bean(*Service)". (This assumes that you have
646
646
* named your Spring service beans in a consistent fashion.)
647
647
*/
648
- @Pointcut("execution(* com.xyz.someapp ..service.*.*(..))")
648
+ @Pointcut("execution(* com.xyz.myapp ..service.*.*(..))")
649
649
fun businessService() {
650
650
}
651
651
@@ -654,7 +654,7 @@ this purpose. Such an aspect typically resembles the following example:
654
654
* dao interface. This definition assumes that interfaces are placed in the
655
655
* "dao" package, and that implementation types are in sub-packages.
656
656
*/
657
- @Pointcut("execution(* com.xyz.someapp .dao.*.*(..))")
657
+ @Pointcut("execution(* com.xyz.myapp .dao.*.*(..))")
658
658
fun dataAccessOperation() {
659
659
}
660
660
@@ -669,7 +669,7 @@ write the following:
669
669
----
670
670
<aop:config>
671
671
<aop:advisor
672
- pointcut="com.xyz.someapp .SystemArchitecture.businessService()"
672
+ pointcut="com.xyz.myapp .SystemArchitecture.businessService()"
673
673
advice-ref="tx-advice"/>
674
674
</aop:config>
675
675
@@ -1057,7 +1057,9 @@ the following example shows:
1057
1057
@Aspect
1058
1058
class AfterReturningExample {
1059
1059
1060
- @AfterReturning(pointcut = "com.xyz.myapp.SystemArchitecture.dataAccessOperation()", returning = "retVal")
1060
+ @AfterReturning(
1061
+ pointcut = "com.xyz.myapp.SystemArchitecture.dataAccessOperation()",
1062
+ returning = "retVal")
1061
1063
fun doAccessCheck(retVal: Any) {
1062
1064
// ...
1063
1065
}
@@ -1148,7 +1150,9 @@ following example shows how to do so:
1148
1150
@Aspect
1149
1151
class AfterThrowingExample {
1150
1152
1151
- @AfterThrowing(pointcut = "com.xyz.myapp.SystemArchitecture.dataAccessOperation()", throwing = "ex")
1153
+ @AfterThrowing(
1154
+ pointcut = "com.xyz.myapp.SystemArchitecture.dataAccessOperation()",
1155
+ throwing = "ex")
1152
1156
fun doRecoveryActions(ex: DataAccessException) {
1153
1157
// ...
1154
1158
}
@@ -1744,8 +1748,8 @@ it until later.
1744
1748
By default, there is a single instance of each aspect within the application
1745
1749
context. AspectJ calls this the singleton instantiation model. It is possible to define
1746
1750
aspects with alternate lifecycles. Spring supports AspectJ's `perthis` and `pertarget`
1747
- instantiation models ( `percflow, percflowbelow,` and `pertypewithin` are not currently
1748
- supported) .
1751
+ instantiation models; `percflow`, ` percflowbelow`, and `pertypewithin` are not currently
1752
+ supported.
1749
1753
1750
1754
You can declare a `perthis` aspect by specifying a `perthis` clause in the `@Aspect`
1751
1755
annotation. Consider the following example:
@@ -1758,7 +1762,7 @@ annotation. Consider the following example:
1758
1762
1759
1763
private int someState;
1760
1764
1761
- @Before(com.xyz.myapp.SystemArchitecture.businessService())
1765
+ @Before(" com.xyz.myapp.SystemArchitecture.businessService()" )
1762
1766
public void recordServiceUsage() {
1763
1767
// ...
1764
1768
}
@@ -1773,23 +1777,23 @@ annotation. Consider the following example:
1773
1777
1774
1778
private val someState: Int = 0
1775
1779
1776
- @Before(com.xyz.myapp.SystemArchitecture.businessService())
1780
+ @Before(" com.xyz.myapp.SystemArchitecture.businessService()" )
1777
1781
fun recordServiceUsage() {
1778
1782
// ...
1779
1783
}
1780
1784
1781
1785
}
1782
1786
----
1783
1787
1784
- In the preceding example, the effect of the `'perthis'` clause is that one aspect instance is created for
1785
- each unique service object that executes a business service (each unique object bound to
1786
- 'this' at join points matched by the pointcut expression). The aspect instance is
1787
- created the first time that a method is invoked on the service object. The aspect goes
1788
- out of scope when the service object goes out of scope. Before the aspect instance is
1789
- created, none of the advice within it executes. As soon as the aspect instance has been
1790
- created, the advice declared within it executes at matched join points, but only
1791
- when the service object is the one with which this aspect is associated. See the AspectJ
1792
- Programming Guide for more information on `per` clauses.
1788
+ In the preceding example, the effect of the `'perthis'` clause is that one aspect
1789
+ instance is created for each unique service object that executes a business service (each
1790
+ unique object bound to 'this' at join points matched by the pointcut expression). The
1791
+ aspect instance is created the first time that a method is invoked on the service object.
1792
+ The aspect goes out of scope when the service object goes out of scope. Before the aspect
1793
+ instance is created, none of the advice within it executes. As soon as the aspect
1794
+ instance has been created, the advice declared within it executes at matched join points,
1795
+ but only when the service object is the one with which this aspect is associated. See the
1796
+ AspectJ Programming Guide for more information on `per` clauses.
1793
1797
1794
1798
The `pertarget` instantiation model works in exactly the same way as `perthis`, but it
1795
1799
creates one aspect instance for each unique target object at matched join points.
@@ -1949,7 +1953,8 @@ expression so that only `@Idempotent` operations match, as follows:
1949
1953
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
1950
1954
.Kotlin
1951
1955
----
1952
- @Around("com.xyz.myapp.SystemArchitecture.businessService() && " + "@annotation(com.xyz.myapp.service.Idempotent)")
1956
+ @Around("com.xyz.myapp.SystemArchitecture.businessService() && " +
1957
+ "@annotation(com.xyz.myapp.service.Idempotent)")
1953
1958
fun doConcurrentOperation(pjp: ProceedingJoinPoint): Any {
1954
1959
// ...
1955
1960
}
0 commit comments