The Artima Developer Community
Sponsored Link

Indeterminate Heuristics
AspectJ in Two Paragraphs
by Dale Asberry
July 15, 2004
Summary
I collaborated with a coworker to create this blurb for a corporate technology roadmap.

Advertisement

AspectJ is an aspect-oriented extension to the Java ™ programming language. According to the folks at PARC who initiated this work 10 years ago,"...A key intuition underlying our work is that simple hierarchies are not rich enough to capture complex structures. In fact, we believe that any single ontological structure is insufficient. As a result, we have been exploring a variety of mechanisms that make it possible to view implement a system from multiple perspectives. One thing we believe about these multiple perspectives is that in order to have significant power they must be able to crosscut each other. That is, one perspective must be able to organize the implementation in fundamentally different ways than other perspectives." AspectJ is an implementation of these design principles for the Java language.

In this instance, we are researching the use of aspects to assist debugging an existing Java application. It has several different sources of data access and no single place in which to place logging or parameter setting logic. As such, we have found it very labor intensive to reliably search out all of those points and cut-and-paste the same code to every one of them. AspectJ allows us to define "pointcuts", or semantically well-defined places, where the existing object-oriented code can be prepended to, appended to, or wrapped by, "advice". Pointcuts and advice will allow us to consistently log all (diversely implemented) database accesses using only one definition (the aspect file). The advised code will add an identifier to every SQL statement in the application before it is executed by DB2. The advised code will also set the necessary JDBC parameters on every connection to enable additional tracing information produced by DB2. Because there is no editing of the actual codebase, the chance of code drift and bug introductions can be minimized. The chance that side-effects will be introduced into the codebase is almost non-existent since aspects cannot be directly referenced by Java classes. Aspects exist outside of existing code and, if they do not contain application logic themselves, can be selectively added or omitted during the Ant build.

There are many other uses for AOP and there are public statements by IBM that it will be included in an upcoming release of WSAD( http://news.com.com/2100-1008_3-5178164.html ).

For more information...

Aspect Oriented Programming http://aosd.net/

AspectJ http://eclipse.org/aspectj/

Other uses...

Undo in AspectJ http://blogs.codehaus.org/people/tirsen/archives/000690_undo_in_aspectj.html

Using Aspects as a Test Coverage Tool http://homepage.mac.com/spullara/rants/C1464297901/E158600668/index.html

Dependency Injection http://jroller.com/page/colyer/20040518

Morphing objects based on context http://jroller.com/page/rickard/20040509

Seamless object filters http://kasparov.skife.org/blog/2004/04/26#objectfilter-announce

Performance analysis http://www.onjava.com/pub/a/onjava/2004/05/12/aop.html

NullObjects http://www.artima.com/weblogs/viewpost.jsp?thread=43091

Maintaining legacy applications http://www-106.ibm.com/developerworks/library/j-aopsc2.html?ca=drs-t511

Using AspectJ to implement and enforce coding standards http://daleasberry.com/newsletters/200210/20021002.shtml

Talk Back!

Have an opinion? Be the first to post a comment about this weblog entry.

RSS Feed

If you'd like to be notified whenever Dale Asberry adds a new entry to his weblog, subscribe to his RSS feed.

About the Blogger

R. Dale Asberry been hacking since 1978, professionally since 1990. He's certified in Java 1.1 and has a four digit MCP number. He discovered Jini at the 2000 JavaOne and has been building incredibly cool, dynamic, distributed architectures ever since! Over time, he's discovered several principles that have contributed to his success - they are the Princples of: Enabling Others, Simplicity, No Complaining, Least Work, Least Surprise, Least Damage, and "It Just Works".

This weblog entry is Copyright © 2004 Dale Asberry. All rights reserved.

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use