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
AspectJ
(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!
==Simple language description== All valid Java programs are also valid AspectJ programs, but AspectJ lets programmers define special constructs called ''[[Aspect-oriented software development#Aspects|aspects]]''. Aspects can contain several entities unavailable to standard classes. These are: ;[[Extension method]]s: Allow a programmer to add methods, fields, or interfaces to existing classes from within the aspect. This example adds an <code>acceptVisitor</code> (see [[visitor pattern]]) method to the <code>Point</code> class: :<syntaxhighlight lang="aspectj"> aspect VisitAspect { void Point.acceptVisitor(Visitor v) { v.visit(this); } } </syntaxhighlight> ;[[Pointcut]]s: Allow a programmer to specify join points (well-defined moments in the execution of a program, like method call, object instantiation, or variable access). All pointcuts are expressions ([[Aspect-oriented software development#Quantification and obliviousness|quantifications]]) that determine whether a given join point matches. For example, this point-cut matches the execution of any instance method in an object of type <code>Point</code> whose name begins with <code>set</code>: :<syntaxhighlight lang="aspectj"> pointcut set() : execution(* set*(..) ) && this(Point); </syntaxhighlight> ;[[Advice (programming)|Advices]]: Allow a programmer to specify code to run at a join point matched by a [[pointcut]]. The actions can be performed ''before'', ''after'', or ''around'' the specified join point. Here, the advice refreshes the display every time something on <code>Point</code> is set, using the pointcut declared above: :<syntaxhighlight lang="aspectj"> after () : set() { Display.update(); } </syntaxhighlight> AspectJ also supports limited forms of pointcut-based static checking and aspect reuse (by inheritance). See the [http://www.eclipse.org/aspectj/doc/released/progguide/index.html AspectJ Programming Guide] for a more detailed description of the language.
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)