AspectWerkz
| Company type | Open source software project |
|---|---|
| Industry | Software development, Programming languages |
| Founded | 2001 |
| Founder | Gregor Kiczales and team at Xerox PARC |
Area served | Worldwide |
Key people | Gregor Kiczales, Chris Maeda, Jim Hugunin, Erik Hilsdale, Mik Kersten, Adrian Colyer, Andrew Clement, Alexander Kriegisch |
| Products | AspectJ programming language and tools, AspectJ Development Tools (AJDT) |
| Owner | Eclipse Foundation |
| Parent | Eclipse Foundation |
| Website | www |
AspectJ represents an aspect-oriented programming (AOP) enhancement for the Java platform, initially created at PARC and currently sustained by the Eclipse Foundation as an open-source initiative. It is accessible both as a standalone tool and integrated within Eclipse, having established itself as a prominent de facto standard in AOP by emphasizing ease of use and straightforwardness. Since its debut in 2001, AspectJ employs syntax similar to Java and offers IDE features that facilitate the visualization of crosscutting patterns.
Simplified explanation
Every valid Java program is also a valid AspectJ program; however, AspectJ introduces unique constructs known as aspects. These constructs encompass:
- Extension methods
- Enable the addition of new methods, fields, or interfaces to pre-existing classes within an aspect's scope. For example, incorporating an
acceptVisitormethod into thePointclass:
- <syntaxhighlight lang="aspectj">
aspect VisitAspect {
void Point.acceptVisitor(Visitor v) {
v.visit(this);
}
} </syntaxhighlight>
- Pointcuts
- Define specific join points—precise execution events such as method invocations or object creations—that correspond to particular expressions. For example, this pointcut targets any instance method in
Pointbeginning withset:
- <syntaxhighlight lang="aspectj">
pointcut set() : execution(* set*(..) ) && this(Point); </syntaxhighlight>
- Advices
- Specify code snippets to run before, after, or around join points matched by a pointcut. The sample below triggers a display refresh following any execution of a
setmethod onPoint:
- <syntaxhighlight lang="aspectj">
after () : set() {
Display.update();
} </syntaxhighlight>
Additionally, AspectJ offers limited static checking based on pointcuts and supports aspect inheritance for reuse, thereby improving modular design and maintainability within Java applications.
Compatibility and implementations of AspectJ
AspectJ can be realized through source-weaving, bytecode-weaving, or directly within the virtual machine (VM), resulting in valid Java bytecode compatible with any Java VM. Classes influenced by aspects maintain binary compatibility with unaffected classes, ensuring smooth integration. The availability of various implementation methods allows AspectJ to adapt alongside evolving technologies while preserving accessibility on the Java platform.
Key engineering decisions underpinning its widespread adoption include practical design choices ensuring deployability. The original Xerox implementation utilized source weaving, necessitating access to source code. Following its contribution to Eclipse, AspectJ was re-engineered employing the Eclipse Java compiler combined with a BCEL-based bytecode weaver. This approach permitted developers to create aspects for compiled (.class) files. It introduced a per-class model vital for incremental compilation and load-time weaving, enhancing IDE responsiveness and enabling deployment without modifying existing build workflows. These improvements significantly increased acceptance among enterprise Java practitioners.
Subsequently, the Eclipse team enhanced performance and reliability, incorporated support for Java 5 features such as generics and annotations, and merged annotation-driven pure-Java aspects from AspectWerkz.
Support is offered via both command-line tools and Ant interfaces within Eclipse. The related AspectJ Development Tools (AJDT) project has bolstered Eclipse IDE integration, a factor critical to developer uptake. Efforts to extend support to other IDEs like emacs, NetBeans, and JBuilder diminished after open-sourcing, though Oracle's JDeveloper did achieve compatibility.
BEA provided limited virtual machine support for aspect-oriented extensions; however, broader VM-level adoption would require agreement through Sun’s Java Community Process—particularly leveraging the java.lang.instrument package introduced in Java SE 5 to enable JVM load-time instrumentation.
Academic investigation into AspectJ continues actively, with the premier research tool being the AspectBench Compiler (abc), which facilitates syntax and semantic enhancements beyond those maintained by the main AspectJ team.
A considerable number of developers utilize AspectJ as foundational technology for frameworks such as Spring AOP. Its companion project, Spring Roo, primarily employs AspectJ inter-type declarations for generating code output.
History and key contributors
The development of AspectJ was spearheaded by Gregor Kiczales and his team at Xerox PARC, where the concept of crosscutting was first introduced. The term aspect-oriented programming was coined by the fourth member, Chris Maeda. The initial compiler and weaver were designed by Jim Hugunin and Erik Hilsdale. Subsequently, Mik Kersten took charge of integrating AspectJ into an IDE and launched the Eclipse AJDT initiative alongside Adrian Colyer and Andrew Clement. Following Colyer's departure, Clement assumed leadership and became the primary contributor. To enhance maintenance efficiency, AJDT was eventually consolidated under the Eclipse AspectJ umbrella; however, both projects continue to be maintained in distinct repositories.
In 2021, Alexander Kriegisch joined the project as a contributor before advancing to committer and maintainer roles. Since March 2021, he has served as the chief maintainer and officially became the lead for both the AspectJ and AJDT projects in 2024.
The AspectBench Compiler represents a joint collaboration involving the Programming Tools Group at Oxford University Computing Laboratory, the Sable Research Group at McGill University, and the Institute for Basic Research in Computer Science (BRICS).
AspectWerkz
AspectWerkz was a lightweight, dynamic AOP framework tailored for Java, which eventually merged with AspectJ to extend its capabilities from AspectJ 5 onwards.
Developed by Jonas Boner and Alex Vasseur, AspectWerkz introduced annotation-based aspect declarations and load-time weaving features that were incorporated into AspectJ. Unlike versions of AspectJ before 5, AspectWerkz did not add new language syntax but instead used Java annotations to define aspects. It performs bytecode manipulation to weave classes during build-time, class loading, and runtime via standardized JVM APIs. Aspects can be specified using Java annotations, custom doclets compatible with Java 1.3/1.4, or XML configuration files.
The framework provides an API facilitating aspect usage as proxies, delivering a smooth experience for developers accustomed to proxy-oriented designs.
AspectWerkz 2.0 is distributed under an LGPL-style license, making it suitable for both commercial applications and open source projects.
See also
- Aspect-oriented programming
- Spring AOP (a component of the Spring Framework)
- Aspect-oriented software development
References
- Ramnivas Laddad, AspectJ in Action: Enterprise AOP with Spring, 2nd edition, Manning Publications, 2009, 550 pages, ISBN 978-1-933988-05-4
- Russ Miles, AspectJ Cookbook, O'Reilly Media, 2004, 354 pages, ISBN 978-0-596-00654-9
- Adrian Colyer et al., Eclipse AspectJ: Aspect-Oriented Programming with AspectJ and the Eclipse AspectJ Development Tools, Addison-Wesley Professional, 2004, 504 pages, ISBN 978-0-321-24587-8
- Joseph D. Gradecki & Nicholas Lesiecki, Mastering AspectJ: Aspect-Oriented Programming in Java, Wiley, 2003, 456 pages, ISBN 978-0-471-43104-6
External links
- AJDT
- Aspect bench
- AspectJ Home Page
- AspectWerkz Project homepage
- Improve modularity with aspect-oriented programming
- Spring AOP and AspectJ Introduction
- The AspectJ Programming Guide
Xerox holds US patent 6467086 related to AOP/AspectJ but distributes the AspectJ source under the Common Public License, which grants certain patent rights.
- Articles with short description
- Programming languages
- Aspect-oriented programming
- Aspect-oriented software development
- Cross-platform software
- Eclipse (software)
- Eclipse software
- Eclipse technology
- Java programming language family
- Software distribution
- Software using the Eclipse Public License
- Programming languages created in 2001
- 2001 software
- Cross-platform free software
- High-level programming languages
- Java APIs