Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Aspect-oriented programming
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
===AspectJ's join-point model=== {{Main article|AspectJ}} {{unordered list | The join points in AspectJ include method or constructor call or execution, the initialization of a class or object, field read and write access, and exception handlers. They do not include loops, super calls, throws clauses, or multiple statements. | Pointcuts are specified by combinations of ''primitive pointcut designators'' (PCDs). "Kinded" PCDs match a particular kind of join point (e.g., method execution) and often take a Java-like signature as input. One such pointcut looks like this: <syntaxhighlight lang="aspectj"> execution(* set*(*)) </syntaxhighlight> This pointcut matches a method-execution join point, if the method name starts with "<code>set</code>" and there is exactly one argument of any type. "Dynamic" PCDs check runtime types and bind variables. For example, <syntaxhighlight lang="aspectj"> this(Point) </syntaxhighlight> This pointcut matches when the currently executing object is an instance of class <code>Point</code>. Note that the unqualified name of a class can be used via Java's normal type lookup. "Scope" PCDs limit the lexical scope of the join point. For example: <syntaxhighlight lang="aspectj"> within(com.company.*) </syntaxhighlight> This pointcut matches any join point in any type in the <code>com.company</code> package. The ''<code>*</code>'' is one form of the wildcards that can be used to match many things with one signature. Pointcuts can be composed and named for reuse. For example: <syntaxhighlight lang="aspectj"> pointcut set() : execution(* set*(*) ) && this(Point) && within(com.company.*); </syntaxhighlight> This pointcut matches a method-execution join point, if the method name starts with "<code>set</code>" and <code>this</code> is an instance of type <code>Point</code> in the <code>com.company</code> package. It can be referred to using the name "<code>set()</code>". | Advice specifies to run at (before, after, or around) a join point (specified with a pointcut) certain code (specified like code in a method). The AOP runtime invokes Advice automatically when the pointcut matches the join point. For example: <syntaxhighlight lang="aspectj"> after() : set() { Display.update(); } </syntaxhighlight> This effectively specifies: "if the ''<code>set()</code>'' pointcut matches the join point, run the code <code>Display.update()</code> after the join point completes."}}
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)