AspectJ
Encyclopedia
AspectJ is an aspect-oriented
Aspect-oriented programming
In computing, aspect-oriented programming is a programming paradigm which aims to increase modularity by allowing the separation of cross-cutting concerns...

 extension created at PARC for the Java
Java (programming language)
Java is a programming language originally developed by James Gosling at Sun Microsystems and released in 1995 as a core component of Sun Microsystems' Java platform. The language derives much of its syntax from C and C++ but has a simpler object model and fewer low-level facilities...

 programming language. It is available in Eclipse Foundation
Eclipse Foundation
The Eclipse Foundation is a not-for-profit, member supported corporation that hosts the open-source Eclipse Projects and helps cultivate both an open source community and an ecosystem of complementary products and services...

 open-source projects, both stand-alone and integrated into Eclipse. AspectJ has become the widely-used de-facto standard for AOP
Aspect-oriented programming
In computing, aspect-oriented programming is a programming paradigm which aims to increase modularity by allowing the separation of cross-cutting concerns...

 by emphasizing simplicity and usability for end users. It uses Java-like syntax and has included IDE integrations for displaying crosscutting structure since its initial public release in 2001.

Simple language description

All valid Java programs are also valid AspectJ programs, but AspectJ also allows programmers to define special constructs called aspects. Aspects can contain several entities unavailable to standard classes. These are:
  • inter-type declarations—allow a programmer to add methods, fields, or interfaces to existing classes from within the aspect. This example adds an acceptVisitor (see visitor pattern
    Visitor pattern
    In object-oriented programming and software engineering, the visitor design pattern is a way of separating an algorithm from an object structure on which it operates. A practical result of this separation is the ability to add new operations to existing object structures without modifying those...

    ) method to the Point class:



aspect VisitAspect {
void Point.acceptVisitor(Visitor v) {
v.visit(this);
}
}

  • pointcut
    Pointcut
    In aspect-oriented computer programming, a pointcut is a set of join points. Whenever the program execution reaches one of the join points described in the pointcut, a piece of code associated with the pointcut is executed. This allows a programmer to describe where and when additional code...

    s — allow a programmer to specify join point
    Join point
    In computer science, a join point is a point in the control flow of a program. In aspect-oriented programming a set of join points is described as a pointcut...

    s (well-defined moments in the execution of a program, like method call, object instantiation, or variable access). All pointcuts are expressions (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 Point whose name begins with set:



pointcut set : execution(* set*(..) ) && this(Point);

  • advice — allows a programmer to specify code to run at a join point matched by a pointcut
    Pointcut
    In aspect-oriented computer programming, a pointcut is a set of join points. Whenever the program execution reaches one of the join points described in the pointcut, a piece of code associated with the pointcut is executed. This allows a programmer to describe where and when additional code...

    . The actions can be performed before, after, or around the specified join point
    Join point
    In computer science, a join point is a point in the control flow of a program. In aspect-oriented programming a set of join points is described as a pointcut...

    . Here, the advice refreshes the display every time something on Point is set, using the pointcut declared above:



after : set {
Display.update;
}


AspectJ also supports limited forms of pointcut-based static checking and aspect reuse (by inheritance). See the AspectJ Programming Guide for a more detailed description of the language.

AspectJ compatibility and implementations

AspectJ has been designed to be implemented in many ways, including source- or bytecode-weaving and directly in the VM (virtual machine). In all cases, the AspectJ program is transformed into a valid Java program run in a Java VM. Any classes affected by aspects are binary-compatible with the unaffected classes (in order to maintain compatibility with any classes that were compiled with the unaffected originals). Supporting multiple implementations allows the language to grow as technology changes, and being Java-compatible ensures platform availability.

Key to its success has been engineering and language decisions designed to make the language usable and programs deployable. The original Xerox AspectJ implementation used source weaving, which required access to source code. When Xerox contributed the code to Eclipse, AspectJ was reimplemented using the Eclipse Java compiler and a bytecode weaver based on BCEL, so developers could write aspects for code in binary (.class) form. At this time the AspectJ language was restricted to support a per-class model essential for incremental compilation and load-time weaving. This made IDE integrations as responsive as their Java counterparts, and it enabled developers to deploy aspects without altering the build process. This led to increased adoption, as AspectJ became usable for impatient Java programmers and enterprise-level deployments. Since then, the Eclipse team has increased performance and correctness, upgraded the AspectJ language to support Java 5 language features like generics and annotations, and integrated annotation-style pure-java aspects from AspectWerkz
AspectWerkz
AspectWerkz is a dynamic, lightweight and high-performance AOP/AOSD framework for Java. It has been merged with the AspectJ project, which supports AspectWerkz functionality since AspectJ 5....

.

The Eclipse project supports both command-line and Ant
Apache Ant
Apache Ant is a software tool for automating software build processes. It is similar to Make but is implemented using the Java language, requires the Java platform, and is best suited to building Java projects....

 interfaces. A related Eclipse project has steadily improved the Eclipse IDE support (AJDT) for AspectJ and other providers of crosscutting structure. IDE support for emacs
Emacs
Emacs is a class of text editors, usually characterized by their extensibility. GNU Emacs has over 1,000 commands. It also allows the user to combine these commands into macros to automate work.Development began in the mid-1970s and continues actively...

, NetBeans
NetBeans
NetBeans refers to both a platform framework for Java desktop applications, and an integrated development environment for developing with Java, JavaScript, PHP, Python, Groovy, C, C++, Scala, Clojure, and others...

, and JBuilder
JBuilder
JBuilder is an integrated development environment for the programming language Java, from Borland, and then CodeGear. Codegear was purchased by Embarcadero Technologies in 2008....

 foundered when Xerox put them into open source, but support for Oracle's JDeveloper did appear. IDE support has been key to Java programmers using AspectJ and understanding crosscutting concerns.

BEA has offered limited support in a VM for aspect-oriented extensions, but for extensions to be supported in all Java VM's would require agreement through Sun's Java Community Process (see also the java.lang.instrument package available since Java SE 5 which is some kind of common ground for JVM load-time instrumentation).

Academic interest in both the semantics and implementation of aspect-oriented
Aspect-oriented programming
In computing, aspect-oriented programming is a programming paradigm which aims to increase modularity by allowing the separation of cross-cutting concerns...

 languages has surrounded AspectJ since its release. The leading research implementation of AspectJ is the AspectBench Compiler, or abc; it supports extensions for changing the syntax and semantics of the language and forms the basis for many AOP experiments that the AspectJ team can no longer support, given its broad user base.

Many programmers discover AspectJ as an enabling technology for other projects they use, most notably Spring AOP. A sister Spring project, Spring Roo
Spring Roo
Spring Roo is an open source software tool that uses convention-over-configuration principles to provide rapid application development of Java-based enterprise software. The resulting applications use common Java technologies such as Spring Framework, Java Persistence API, Java Server Pages, Apache...

, automatically maintains AspectJ inter-type declarations as its principal code generation output.

History and contributors

Gregor Kiczales
Gregor Kiczales
Gregor Kiczales is a professor of computer science at the University of British Columbia in Canada. His best known work is on Aspect-oriented programming and the AspectJ extension for Java at Xerox PARC. He has also contributed to the design of the Common Lisp Object System, and is the author of...

 started and led the Xerox PARC
Xerox PARC
PARC , formerly Xerox PARC, is a research and co-development company in Palo Alto, California, with a distinguished reputation for its contributions to information technology and hardware systems....

 team that eventually developed AspectJ; he coined the term "crosscutting". Fourth on the team, Chris Maeda coined the term "aspect-oriented programming." Jim Hugunin
Jim Hugunin
Jim Hugunin is a software programmer who created the Python programming language extension Numeric , and later created Python implementations for the Java Platform and for Microsoft .NET platform ; he has also co-designed the AspectJ extension for the Java programming language...

 and Erik Hilsdale (Xerox PARC
Xerox PARC
PARC , formerly Xerox PARC, is a research and co-development company in Palo Alto, California, with a distinguished reputation for its contributions to information technology and hardware systems....

 team members 12 and 13) were the original compiler and weaver engineers, Mik Kersten
Mik Kersten
Mik Kersten is a Canadian computer specialist who created and leads the open-source Eclipse Mylyn project. Kersten invented the Task-Focused Interface technology underlying Mylyn while working on his PhD at the University of British Columbia in Vancouver, Canada. While completing his PhD,...

 implemented the IDE integration and started the Eclipse AJDT project with Adrian Colyer (current lead of the AspectJ project) and Andrew Clement (current compiler engineer).

Jonas Boner and Alex Vasseur engineered the AspectWerkz
AspectWerkz
AspectWerkz is a dynamic, lightweight and high-performance AOP/AOSD framework for Java. It has been merged with the AspectJ project, which supports AspectWerkz functionality since AspectJ 5....

 project, and later contributed to the AspectJ project when it merged in the AspectWerkz annotation style and load-time weaving support.

The AspectBench Compiler was developed and is being maintained as a joint effort of the Programming Tools Group at the Oxford University Computing Laboratory
Oxford University Computing Laboratory
The Department of Computer Science, until 2011 named the Computing Laboratory , is a department of Oxford University in England...

, the Sable Research Group
Sable Research Group
The Sable Research Group is located at the School of Computer Science at McGill University and currently under the supervision of Laurie Hendren and Clark Verbrugge. The name of the group originates from the idea that the original goal was to develop research tools for the programming language Java...

 at McGill University
McGill University
Mohammed Fathy is a public research university located in Montreal, Quebec, Canada. The university bears the name of James McGill, a prominent Montreal merchant from Glasgow, Scotland, whose bequest formed the beginning of the university...

 and the Institute for Basic Research in Computer Science (BRICS).

See also

  • Aspect-oriented programming
    Aspect-oriented programming
    In computing, aspect-oriented programming is a programming paradigm which aims to increase modularity by allowing the separation of cross-cutting concerns...

  • AspectWerkz
    AspectWerkz
    AspectWerkz is a dynamic, lightweight and high-performance AOP/AOSD framework for Java. It has been merged with the AspectJ project, which supports AspectWerkz functionality since AspectJ 5....

  • Spring AOP (part of the Spring Framework
    Spring Framework (Java)
    The Spring Framework is an open source application framework for the Java platform.The first version was written by Rod Johnson, who released the framework with the publication of his book Expert One-on-One J2EE Design and Development in October 2002. The framework was first released under the...

    )
  • Aspect-oriented software development
    Aspect-oriented software development
    In computing, Aspect-oriented software development is an emerging software development technology that seeks new modularizations of software systems in order to isolate secondary or supporting functions from the main program's business logic...


External links

  • AspectJ Home Page
  • Xerox has for AOP/AspectJ, but published AspectJ source code under the Common Public License, which grants some patent rights.
  • http://www.eclipse.org/aspectj/doc/released/progguide/index.html
  • AJDT
  • http://aspectbench.org/
  • http://www.ibm.com/developerworks/java/library/j-aspectj
The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK