(c) Copyright Palo Alto Research Center Incroporated. All rights reserved.1 AO Tools: State of the (AspectJ™) Art and Open Problems Mik Kersten aspectj.org Palo Alto Research Center
(c) Copyright Palo Alto Research Center Incroporated. All rights reserved.2 good modularity XML parsing in org.apache.tomcat –red shows relevant lines of code –nicely fits in one box XML parsing
(c) Copyright Palo Alto Research Center Incroporated. All rights reserved.3 good modularity URL pattern matching in org.apache.tomcat –red shows relevant lines of code –nicely fits in two boxes (using inheritance) URL pattern matching
(c) Copyright Palo Alto Research Center Incroporated. All rights reserved.4 problems like… logging in org.apache.tomcat –red shows lines of code that handle logging –not in just one place –not even in a small number of places logging is not modularized
(c) Copyright Palo Alto Research Center Incroporated. All rights reserved.5 logging, zoomed in //From ContextManager public void service( Request rrequest, Response rresponse ) { // log( "New request " + rrequest ); try { // System.out.print("A"); rrequest.setContextManager( this ); rrequest.setResponse(rresponse); rresponse.setRequest(rrequest); // wront request - parsing error int status=rresponse.getStatus(); if( status < 400 ) status= processRequest( rrequest ); if(status==0) status=authenticate( rrequest, rresponse ); if(status == 0) status=authorize( rrequest, rresponse ); if( status == 0 ) { rrequest.getWrapper().handleRequest(rrequest, rresponse); } else { // something went wrong handleError( rrequest, rresponse, null, status ); } } catch (Throwable t) { handleError( rrequest, rresponse, t, 0 ); } // System.out.print("B"); try { rresponse.finish(); rrequest.recycle(); rresponse.recycle(); } catch( Throwable ex ) { if(debug>0) log( "Error closing request " + ex); } // log( "Done with request " + rrequest ); // System.out.print("C"); return; } // log( "New request " + rrequest ); // System.out.print(“A”); // System.out.print("B"); // log("Done with request " + rrequest); if(debug>0) log("Error closing request " + ex); // System.out.print("C");
(c) Copyright Palo Alto Research Center Incroporated. All rights reserved.6 aspect PublicErrorLogging { Log log = new Log(); pointcut publicInterface (): call(public * org.apache.tomcat..*.*(..)); after() throwing (Error e): publicInterface() { log.write(e); } logging, modularized crosscutting concerns –tangled implementation complex, difficult to maintain –modular implementation can be clear, easy to maintain crosscutting concerns per se not complicated! captures public interface of tomcat package
(c) Copyright Palo Alto Research Center Incroporated. All rights reserved.7 crosscutting modularity aspect modularity cuts across class modularity HistoryUpdating Display * 2 Point getX() getY() setX(int) setY(int) moveBy(int, int) Line getP1() getP2() setP1(Point) setP2(Point) moveBy(int, int) Figure makePoint(..) makeLine(..) FigureElement moveBy(int, int)
(c) Copyright Palo Alto Research Center Incroporated. All rights reserved.8 that’s great, but… “how do I know what aspects affect my code?” “what will be executed?” “do you support my IDE?” “do you support Emacs?” “do you support Vi?”
(c) Copyright Palo Alto Research Center Incroporated. All rights reserved.9 where we are: crosscutting structure
(c) Copyright Palo Alto Research Center Incroporated. All rights reserved.10 crosscutting structure harder to show –not hierarchical –global structure –must be compatible with OO tools important to show –tool support helped OO win –advice invocation is implicit –hard to infer structure from source alone
(c) Copyright Palo Alto Research Center Incroporated. All rights reserved.11 demos… modularize concern build configurations crosscutting structure
(c) Copyright Palo Alto Research Center Incroporated. All rights reserved.12 where we are: tool platform support
(c) Copyright Palo Alto Research Center Incroporated. All rights reserved.13 multiple tool platforms development task-specific functionality –compilation & build management –editing & structure navigation –documentation must be presented consistently in –command line tools –IDEs Eclipse JBuilder NetBeans
(c) Copyright Palo Alto Research Center Incroporated. All rights reserved.14 netbeans screenshot…
(c) Copyright Palo Alto Research Center Incroporated. All rights reserved.15 ajbrowser screenshot…
(c) Copyright Palo Alto Research Center Incroporated. All rights reserved.16 emacs
(c) Copyright Palo Alto Research Center Incroporated. All rights reserved.17 jdee
(c) Copyright Palo Alto Research Center Incroporated. All rights reserved.18 ajdoc
(c) Copyright Palo Alto Research Center Incroporated. All rights reserved.19 tools architecture core framework provides –AspectJ-specific tool functionality –AspectJ structure model –GUI for Swing platforms –abstract UI and event model tool clients extend core –present task-specific views of crosscutting –goal is seamless integration with host platform
(c) Copyright Palo Alto Research Center Incroporated. All rights reserved.20 tools architecture overview
(c) Copyright Palo Alto Research Center Incroporated. All rights reserved.21 abstract structure model graph of program element nodes and associations longer lifecycle than AST, smaller footprint generic for AO and OO structure
(c) Copyright Palo Alto Research Center Incroporated. All rights reserved.22 where we are: unsolved problems
(c) Copyright Palo Alto Research Center Incroporated. All rights reserved.23 join point terminology several kinds of join points –method & constructor call –method & constructor execution –field get & set –exception handler execution –static & dynamic initialization a Line dispatch method call join points method execution join points
(c) Copyright Palo Alto Research Center Incroporated. All rights reserved.24 problems dynamic information (what actually executes) advice ordering runtime inspection (show abstraction, not execution) better build configuration support eager parsing
(c) Copyright Palo Alto Research Center Incroporated. All rights reserved.25 where we’re going: more problems…
(c) Copyright Palo Alto Research Center Incroporated. All rights reserved.26 enterprise apps, lifecycle
(c) Copyright Palo Alto Research Center Incroporated. All rights reserved.27
(c) Copyright Palo Alto Research Center Incroporated. All rights reserved.28 future work richer structure model –crosscutting (of classes) –crosscutting (of enterprise tiers, resources) –runtime (joinpoints, test suite) –emergent (evolution) better views –dynamic information –comprehensive refactoring –structure mining –version control –design and global structure
(c) Copyright Palo Alto Research Center Incroporated. All rights reserved.29 future work
(c) Copyright Palo Alto Research Center Incroporated. All rights reserved.30 logging (again) logging in org.apache.tomcat –red shows lines of code that handle logging –not in just one place –not even in a small number of places
(c) Copyright Palo Alto Research Center Incroporated. All rights reserved.31 demo: visualizer
(c) Copyright Palo Alto Research Center Incroporated. All rights reserved.32 credits AspectJ.org is a PARC project (partially funded by DARPA under contract F C0246) Erik Hilsdale, Jim Hugunin, Wes Isberg, Mik Kersten and Gregor Kiczales download the tools and docs at: get the eclipse plug-in: the team: find more information on AOP: is coming!