(c) copyright 1998-2002 palo alto research center incroporated. all rights reserved.1 ao tools:...

32
(c) Copyright 1998-2002 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

Post on 21-Dec-2015

213 views

Category:

Documents


0 download

TRANSCRIPT

(c) Copyright 1998-2002 Palo Alto Research Center Incroporated. All rights reserved.1

AO Tools: State of the (AspectJ™) Art and Open

ProblemsMik Kersten

aspectj.orgPalo Alto Research Center

(c) Copyright 1998-2002 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 1998-2002 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 1998-2002 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 1998-2002 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 1998-2002 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 1998-2002 Palo Alto Research Center Incroporated. All rights reserved.7

crosscutting modularity

aspect modularity cuts across class modularity

HistoryUpdating

Display

*

2Point

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 1998-2002 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 1998-2002 Palo Alto Research Center Incroporated. All rights reserved.9

where we are: crosscutting structure

(c) Copyright 1998-2002 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 1998-2002 Palo Alto Research Center Incroporated. All rights reserved.11

demos…

• modularize concern• build configurations• crosscutting structure

(c) Copyright 1998-2002 Palo Alto Research Center Incroporated. All rights reserved.12

where we are: tool platform support

(c) Copyright 1998-2002 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 1998-2002 Palo Alto Research Center Incroporated. All rights reserved.14

netbeans screenshot…

(c) Copyright 1998-2002 Palo Alto Research Center Incroporated. All rights reserved.15

ajbrowser screenshot…

(c) Copyright 1998-2002 Palo Alto Research Center Incroporated. All rights reserved.16

emacs

(c) Copyright 1998-2002 Palo Alto Research Center Incroporated. All rights reserved.17

jdee

(c) Copyright 1998-2002 Palo Alto Research Center Incroporated. All rights reserved.18

ajdoc

(c) Copyright 1998-2002 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 1998-2002 Palo Alto Research Center Incroporated. All rights reserved.20

tools architecture overview

AspectJ Compiler

AJDE Plug-in UI

J ava IDE UI AJDE UI

J ava IDE(Eclipse, JBuilder, NetBeans)

Developer

AJDE Plug-in

ajcAJDE Framework & ASM

coupling

ajdoc

Tool

API

(c) Copyright 1998-2002 Palo Alto Research Center Incroporated. All rights reserved.21

abstract structure model

Source AST Structure ViewsAbstract Structure Model

UML StaticStructure

Hyper-annotations,code insight

Linked tree

HTML Docs

Legend: Program Element Association

• graph of program element nodes and associations

• longer lifecycle than AST, smaller footprint• generic for AO and OO structure

(c) Copyright 1998-2002 Palo Alto Research Center Incroporated. All rights reserved.22

where we are: unsolved problems

(c) Copyright 1998-2002 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 1998-2002 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 1998-2002 Palo Alto Research Center Incroporated. All rights reserved.25

where we’re going: more problems…

(c) Copyright 1998-2002 Palo Alto Research Center Incroporated. All rights reserved.26

enterprise apps, lifecycle

(c) Copyright 1998-2002 Palo Alto Research Center Incroporated. All rights reserved.27

(c) Copyright 1998-2002 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 1998-2002 Palo Alto Research Center Incroporated. All rights reserved.29

future work

StructureMiner

Enterprise AppResources(.xml, jsp,.html, .mf)

DocumentOutline Tree

EnterpriseApp Views Views

Model

Builders

Resources

RuntimeJoinpoint/

Thread ViewAJDoc

Refactoring/Mining Editor

CompilerStructure

Parser

TextEditor

updates

edits

J avaResources(.java, .aj)

Runtime

RuntmeManager

AbstractStructure

Model

(c) Copyright 1998-2002 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 1998-2002 Palo Alto Research Center Incroporated. All rights reserved.31

demo: visualizer

(c) Copyright 1998-2002 Palo Alto Research Center Incroporated. All rights reserved.32

credits

AspectJ.org is a PARC project(partially funded by DARPA under contract F30602-97-C0246)

Erik Hilsdale, Jim Hugunin, Wes Isberg, Mik Kersten and Gregor Kiczales

download the tools and docs at: http://aspectj.org

get the eclipse plug-in: http://eclipse.org/ajdt

email the team: [email protected]

find more information on AOP: http://aosd.net

1.1 is coming!