Skip to content

Commit

Permalink
Rename SystemArchitecture aspect to CommonPointcuts in AOP ref doc
Browse files Browse the repository at this point in the history
  • Loading branch information
sbrannen committed Jul 6, 2020
1 parent 52c2ca6 commit 8be2a43
Showing 1 changed file with 41 additions and 41 deletions.
82 changes: 41 additions & 41 deletions src/docs/asciidoc/core/core-aop.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -524,10 +524,10 @@ matching.
[[aop-common-pointcuts]]
==== Sharing Common Pointcut Definitions

When working with enterprise applications, developers often want to refer to modules of the
application and particular sets of operations from within several aspects. We recommend
defining a `SystemArchitecture` aspect that captures common pointcut expressions for
this purpose. Such an aspect typically resembles the following example:
When working with enterprise applications, developers often want to refer to modules of
the application and particular sets of operations from within several aspects. We
recommend defining a `CommonPointcuts` aspect that captures common pointcut expressions
for this purpose. Such an aspect typically resembles the following example:

[source,java,indent=0,subs="verbatim",role="primary"]
.Java
Expand All @@ -538,7 +538,7 @@ this purpose. Such an aspect typically resembles the following example:
import org.aspectj.lang.annotation.Pointcut;
@Aspect
public class SystemArchitecture {
public class CommonPointcuts {
/**
* A join point is in the web layer if the method is defined
Expand Down Expand Up @@ -602,7 +602,7 @@ this purpose. Such an aspect typically resembles the following example:
import org.springframework.aop.Pointcut
@Aspect
class SystemArchitecture {
class CommonPointcuts {
/**
* A join point is in the web layer if the method is defined
Expand Down Expand Up @@ -669,7 +669,7 @@ write the following:
----
<aop:config>
<aop:advisor
pointcut="com.xyz.myapp.SystemArchitecture.businessService()"
pointcut="com.xyz.myapp.CommonPointcuts.businessService()"
advice-ref="tx-advice"/>
</aop:config>
Expand Down Expand Up @@ -923,7 +923,7 @@ You can declare before advice in an aspect by using the `@Before` annotation:
@Aspect
public class BeforeExample {
@Before("com.xyz.myapp.SystemArchitecture.dataAccessOperation()")
@Before("com.xyz.myapp.CommonPointcuts.dataAccessOperation()")
public void doAccessCheck() {
// ...
}
Expand All @@ -939,7 +939,7 @@ You can declare before advice in an aspect by using the `@Before` annotation:
@Aspect
class BeforeExample {
@Before("com.xyz.myapp.SystemArchitecture.dataAccessOperation()")
@Before("com.xyz.myapp.CommonPointcuts.dataAccessOperation()")
fun doAccessCheck() {
// ...
}
Expand Down Expand Up @@ -999,7 +999,7 @@ declare it by using the `@AfterReturning` annotation:
@Aspect
public class AfterReturningExample {
@AfterReturning("com.xyz.myapp.SystemArchitecture.dataAccessOperation()")
@AfterReturning("com.xyz.myapp.CommonPointcuts.dataAccessOperation()")
public void doAccessCheck() {
// ...
}
Expand All @@ -1015,7 +1015,7 @@ declare it by using the `@AfterReturning` annotation:
@Aspect
class AfterReturningExample {
@AfterReturning("com.xyz.myapp.SystemArchitecture.dataAccessOperation()")
@AfterReturning("com.xyz.myapp.CommonPointcuts.dataAccessOperation()")
fun doAccessCheck() {
// ...
}
Expand All @@ -1040,7 +1040,7 @@ the following example shows:
public class AfterReturningExample {
@AfterReturning(
pointcut="com.xyz.myapp.SystemArchitecture.dataAccessOperation()",
pointcut="com.xyz.myapp.CommonPointcuts.dataAccessOperation()",
returning="retVal")
public void doAccessCheck(Object retVal) {
// ...
Expand All @@ -1058,7 +1058,7 @@ the following example shows:
class AfterReturningExample {
@AfterReturning(
pointcut = "com.xyz.myapp.SystemArchitecture.dataAccessOperation()",
pointcut = "com.xyz.myapp.CommonPointcuts.dataAccessOperation()",
returning = "retVal")
fun doAccessCheck(retVal: Any) {
// ...
Expand Down Expand Up @@ -1093,7 +1093,7 @@ example shows:
@Aspect
public class AfterThrowingExample {
@AfterThrowing("com.xyz.myapp.SystemArchitecture.dataAccessOperation()")
@AfterThrowing("com.xyz.myapp.CommonPointcuts.dataAccessOperation()")
public void doRecoveryActions() {
// ...
}
Expand All @@ -1109,7 +1109,7 @@ example shows:
@Aspect
class AfterThrowingExample {
@AfterThrowing("com.xyz.myapp.SystemArchitecture.dataAccessOperation()")
@AfterThrowing("com.xyz.myapp.CommonPointcuts.dataAccessOperation()")
fun doRecoveryActions() {
// ...
}
Expand All @@ -1133,7 +1133,7 @@ following example shows how to do so:
public class AfterThrowingExample {
@AfterThrowing(
pointcut="com.xyz.myapp.SystemArchitecture.dataAccessOperation()",
pointcut="com.xyz.myapp.CommonPointcuts.dataAccessOperation()",
throwing="ex")
public void doRecoveryActions(DataAccessException ex) {
// ...
Expand All @@ -1151,7 +1151,7 @@ following example shows how to do so:
class AfterThrowingExample {
@AfterThrowing(
pointcut = "com.xyz.myapp.SystemArchitecture.dataAccessOperation()",
pointcut = "com.xyz.myapp.CommonPointcuts.dataAccessOperation()",
throwing = "ex")
fun doRecoveryActions(ex: DataAccessException) {
// ...
Expand Down Expand Up @@ -1184,7 +1184,7 @@ The following example shows how to use after finally advice:
@Aspect
public class AfterFinallyExample {
@After("com.xyz.myapp.SystemArchitecture.dataAccessOperation()")
@After("com.xyz.myapp.CommonPointcuts.dataAccessOperation()")
public void doReleaseLock() {
// ...
}
Expand All @@ -1200,7 +1200,7 @@ The following example shows how to use after finally advice:
@Aspect
class AfterFinallyExample {
@After("com.xyz.myapp.SystemArchitecture.dataAccessOperation()")
@After("com.xyz.myapp.CommonPointcuts.dataAccessOperation()")
fun doReleaseLock() {
// ...
}
Expand Down Expand Up @@ -1252,7 +1252,7 @@ The following example shows how to use around advice:
@Aspect
public class AroundExample {
@Around("com.xyz.myapp.SystemArchitecture.businessService()")
@Around("com.xyz.myapp.CommonPointcuts.businessService()")
public Object doBasicProfiling(ProceedingJoinPoint pjp) throws Throwable {
// start stopwatch
Object retVal = pjp.proceed();
Expand All @@ -1272,7 +1272,7 @@ The following example shows how to use around advice:
@Aspect
class AroundExample {
@Around("com.xyz.myapp.SystemArchitecture.businessService()")
@Around("com.xyz.myapp.CommonPointcuts.businessService()")
fun doBasicProfiling(pjp: ProceedingJoinPoint): Any {
// start stopwatch
val retVal = pjp.proceed()
Expand Down Expand Up @@ -1331,15 +1331,15 @@ You could write the following:
[source,java,indent=0,subs="verbatim,quotes",role="primary"]
.Java
----
@Before("com.xyz.myapp.SystemArchitecture.dataAccessOperation() && args(account,..)")
@Before("com.xyz.myapp.CommonPointcuts.dataAccessOperation() && args(account,..)")
public void validateAccount(Account account) {
// ...
}
----
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
.Kotlin
----
@Before("com.xyz.myapp.SystemArchitecture.dataAccessOperation() && args(account,..)")
@Before("com.xyz.myapp.CommonPointcuts.dataAccessOperation() && args(account,..)")
fun validateAccount(account: Account) {
// ...
}
Expand All @@ -1358,7 +1358,7 @@ from the advice. This would look as follows:
[source,java,indent=0,subs="verbatim,quotes",role="primary"]
.Java
----
@Pointcut("com.xyz.myapp.SystemArchitecture.dataAccessOperation() && args(account,..)")
@Pointcut("com.xyz.myapp.CommonPointcuts.dataAccessOperation() && args(account,..)")
private void accountDataAccessOperation(Account account) {}
@Before("accountDataAccessOperation(account)")
Expand All @@ -1369,7 +1369,7 @@ from the advice. This would look as follows:
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
.Kotlin
----
@Pointcut("com.xyz.myapp.SystemArchitecture.dataAccessOperation() && args(account,..)")
@Pointcut("com.xyz.myapp.CommonPointcuts.dataAccessOperation() && args(account,..)")
private fun accountDataAccessOperation(account: Account) {
}
Expand Down Expand Up @@ -1612,7 +1612,7 @@ The following example shows how to do so:
.Java
----
@Around("execution(List<Account> find*(..)) && " +
"com.xyz.myapp.SystemArchitecture.inDataAccessLayer() && " +
"com.xyz.myapp.CommonPointcuts.inDataAccessLayer() && " +
"args(accountHolderNamePattern)")
public Object preProcessQueryPattern(ProceedingJoinPoint pjp,
String accountHolderNamePattern) throws Throwable {
Expand All @@ -1624,7 +1624,7 @@ The following example shows how to do so:
.Kotlin
----
@Around("execution(List<Account> find*(..)) && " +
"com.xyz.myapp.SystemArchitecture.inDataAccessLayer() && " +
"com.xyz.myapp.CommonPointcuts.inDataAccessLayer() && " +
"args(accountHolderNamePattern)")
fun preProcessQueryPattern(pjp: ProceedingJoinPoint,
accountHolderNamePattern: String): Any {
Expand Down Expand Up @@ -1695,7 +1695,7 @@ the `UsageTracked` interface (to expose statistics via JMX for example):
@DeclareParents(value="com.xzy.myapp.service.*+", defaultImpl=DefaultUsageTracked.class)
public static UsageTracked mixin;
@Before("com.xyz.myapp.SystemArchitecture.businessService() && this(usageTracked)")
@Before("com.xyz.myapp.CommonPointcuts.businessService() && this(usageTracked)")
public void recordUsage(UsageTracked usageTracked) {
usageTracked.incrementUseCount();
}
Expand All @@ -1713,7 +1713,7 @@ the `UsageTracked` interface (to expose statistics via JMX for example):
lateinit var mixin: UsageTracked
}
@Before("com.xyz.myapp.SystemArchitecture.businessService() && this(usageTracked)")
@Before("com.xyz.myapp.CommonPointcuts.businessService() && this(usageTracked)")
fun recordUsage(usageTracked: UsageTracked) {
usageTracked.incrementUseCount()
}
Expand Down Expand Up @@ -1757,12 +1757,12 @@ annotation. Consider the following example:
[source,java,indent=0,subs="verbatim,quotes",role="primary"]
.Java
----
@Aspect("perthis(com.xyz.myapp.SystemArchitecture.businessService())")
@Aspect("perthis(com.xyz.myapp.CommonPointcuts.businessService())")
public class MyAspect {
private int someState;
@Before("com.xyz.myapp.SystemArchitecture.businessService()")
@Before("com.xyz.myapp.CommonPointcuts.businessService()")
public void recordServiceUsage() {
// ...
}
Expand All @@ -1772,12 +1772,12 @@ annotation. Consider the following example:
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
.Kotlin
----
@Aspect("perthis(com.xyz.myapp.SystemArchitecture.businessService())")
@Aspect("perthis(com.xyz.myapp.CommonPointcuts.businessService())")
class MyAspect {
private val someState: Int = 0
@Before("com.xyz.myapp.SystemArchitecture.businessService()")
@Before("com.xyz.myapp.CommonPointcuts.businessService()")
fun recordServiceUsage() {
// ...
}
Expand Down Expand Up @@ -1841,7 +1841,7 @@ call `proceed` multiple times. The following listing shows the basic aspect impl
this.order = order;
}
@Around("com.xyz.myapp.SystemArchitecture.businessService()")
@Around("com.xyz.myapp.CommonPointcuts.businessService()")
public Object doConcurrentOperation(ProceedingJoinPoint pjp) throws Throwable {
int numAttempts = 0;
PessimisticLockingFailureException lockFailureException;
Expand Down Expand Up @@ -1881,7 +1881,7 @@ call `proceed` multiple times. The following listing shows the basic aspect impl
this.order = order
}
@Around("com.xyz.myapp.SystemArchitecture.businessService()")
@Around("com.xyz.myapp.CommonPointcuts.businessService()")
fun doConcurrentOperation(pjp: ProceedingJoinPoint): Any {
var numAttempts = 0
var lockFailureException: PessimisticLockingFailureException
Expand Down Expand Up @@ -1944,7 +1944,7 @@ expression so that only `@Idempotent` operations match, as follows:
[source,java,indent=0,subs="verbatim,quotes",role="primary"]
.Java
----
@Around("com.xyz.myapp.SystemArchitecture.businessService() && " +
@Around("com.xyz.myapp.CommonPointcuts.businessService() && " +
"@annotation(com.xyz.myapp.service.Idempotent)")
public Object doConcurrentOperation(ProceedingJoinPoint pjp) throws Throwable {
// ...
Expand All @@ -1953,7 +1953,7 @@ expression so that only `@Idempotent` operations match, as follows:
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
.Kotlin
----
@Around("com.xyz.myapp.SystemArchitecture.businessService() && " +
@Around("com.xyz.myapp.CommonPointcuts.businessService() && " +
"@annotation(com.xyz.myapp.service.Idempotent)")
fun doConcurrentOperation(pjp: ProceedingJoinPoint): Any {
// ...
Expand Down Expand Up @@ -2048,12 +2048,12 @@ pointcut expression. Another way of defining the above pointcut would be as foll
<aop:config>
<aop:pointcut id="businessService"
expression="com.xyz.myapp.SystemArchitecture.businessService()"/>
expression="com.xyz.myapp.CommonPointcuts.businessService()"/>
</aop:config>
----

Assume that you have a `SystemArchitecture` aspect as described in <<aop-common-pointcuts>>.
Assume that you have a `CommonPointcuts` aspect as described in <<aop-common-pointcuts>>.

Then declaring a pointcut inside an aspect is very similar to declaring a top-level pointcut,
as the following example shows:
Expand Down Expand Up @@ -2617,7 +2617,7 @@ through JMX for example.)
default-impl="com.xyz.myapp.service.tracking.DefaultUsageTracked"/>
<aop:before
pointcut="com.xyz.myapp.SystemArchitecture.businessService()
pointcut="com.xyz.myapp.CommonPointcuts.businessService()
and this(usageTracked)"
method="recordUsage"/>
Expand Down Expand Up @@ -3606,7 +3606,7 @@ fully qualified class names:
// the creation of a new bean (any object in the domain model)
protected pointcut beanCreation(Object beanInstance) :
initialization(new(..)) &&
SystemArchitecture.inDomainModel() &&
CommonPointcuts.inDomainModel() &&
this(beanInstance);
}
----
Expand Down

0 comments on commit 8be2a43

Please sign in to comment.