diff options
Diffstat (limited to 'docs/progGuideDB/idioms.adoc')
-rw-r--r-- | docs/progGuideDB/idioms.adoc | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/docs/progGuideDB/idioms.adoc b/docs/progGuideDB/idioms.adoc index 8e5f6e43e..e27395a48 100644 --- a/docs/progGuideDB/idioms.adoc +++ b/docs/progGuideDB/idioms.adoc @@ -7,62 +7,62 @@ This chapter consists of very short snippets of AspectJ code, typically pointcuts, that are particularly evocative or useful. This section is a work in progress. -Here's an example of how to enfore a rule that code in the java.sql +Here's an example of how to enfore a rule that code in the `java.sql` package can only be used from one particular package in your system. -This doesn't require any access to code in the java.sql package. +This doesn't require any access to code in the `java.sql` package. [source, java] .... /* Any call to methods or constructors in java.sql */ pointcut restrictedCall(): - call(* java.sql.*.*(..)) || call(java.sql.*.new(..)); + call(* java.sql.*.*(..)) || call(java.sql.*.new(..)); /* Any code in my system not in the sqlAccess package */ pointcut illegalSource(): - within(com.foo..*) && !within(com.foo.sqlAccess.*); + within(com.foo..*) && !within(com.foo.sqlAccess.*); declare error: restrictedCall() && illegalSource(): - "java.sql package can only be accessed from com.foo.sqlAccess"; + "java.sql package can only be accessed from com.foo.sqlAccess"; .... -Any call to an instance of a subtype of AbstractFacade whose class is -not exactly equal to AbstractFacade: +Any call to an instance of a subtype of `AbstractFacade` whose class is +not exactly equal to `AbstractFacade`: [source, java] .... pointcut nonAbstract(AbstractFacade af): - call(* *(..)) - && target(af) - && !if(af.getClass() == AbstractFacade.class); + call(* *(..)) + && target(af) + && !if(af.getClass() == AbstractFacade.class); .... -If AbstractFacade is an abstract class or an interface, then every +If `AbstractFacade` is an abstract class or an interface, then every instance must be of a subtype and you can replace this with: [source, java] .... pointcut nonAbstract(AbstractFacade af): - call(* *(..)) - && target(af); + call(* *(..)) + && target(af); .... -Any call to a method which is defined by a subtype of AbstractFacade, -but which isn't defined by the type AbstractFacade itself: +Any call to a method which is defined by a subtype of `AbstractFacade`, +but which isn't defined by the type `AbstractFacade` itself: [source, java] .... pointcut callToUndefinedMethod(): - call(* AbstractFacade+.*(..)) - && !call(* AbstractFacade.*(..)); + call(* AbstractFacade+.*(..)) + && !call(* AbstractFacade.*(..)); .... The execution of a method that is defined in the source code for a type -that is a subtype of AbstractFacade but not in AbstractFacade itself: +that is a subtype of `AbstractFacade` but not in `AbstractFacade` itself: [source, java] .... pointcut executionOfUndefinedMethod(): - execution(* *(..)) - && within(AbstractFacade+) - && !within(AbstractFacade) + execution(* *(..)) + && within(AbstractFacade+) + && !within(AbstractFacade) .... |