AJDT: Getting started with Aspect-Oriented Programming in Eclipse

Similar documents
Aspect Oriented Programming

Aspect-Oriented Programming and Aspect-J

Course 6 7 November Adrian Iftene

Aspect-Oriented Programming with AJDT Andy Clement IBM UK Ltd MP 146, Hursley Park Winchester, Hants. England clemas at uk.ibm.

Information systems modeling. Tomasz Kubik

AOP 101: Intro to Aspect Oriented Programming. Ernest Hill

Separation of Concerns. AspectJ. What if the concerns are Cross-Cutting? SoC: Programming Paradigms. Key theme: Modularity and Encapsulation

Programming AspectJ with Eclipse and AJDT, By Example. Chien-Tsun Chen Sep. 21, 2003

Aspect Oriented Programming

Bugdel: An Aspect-Oriented Debugging System

Introduction to. Bruno Harbulot. ESNW, the University of Manchester.

(800) Toll Free (804) Fax Introduction to Java and Enterprise Java using Eclipse IDE Duration: 5 days

Aspect Weaving DyMAC middleware. by Tonje Klykken, INF5360 May 6th 2008

Aspect-Oriented Programming and AspectJ

Aspect Oriented Programming with AspectJ. Ted Leung Sauria Associates, LLC

Aspect-Oriented Programming

A Brief Introduction to Aspect-Oriented Programming. Historical View Of Languages. Procedural language Functional language Object-Oriented language

A Brief Introduction to Aspect-Oriented Programming" Historical View Of Languages"

An Aspect-Oriented Approach. Henrique Rebêlo Informatics Center

Language support for AOP

Language Oriented Modularity: From Theory to Practice

What is AOP? Business Logic Requirements Concern Identifier Security Logging (Laddad, 2003, p. 9) What is AOP? Non-AOP implementation of crosscutting

Aspect Refactoring Verifier

SCALA AND ASPECTJ. Approaching Modularizing of Crosscutting. Ramnivas Laddad. Concerns. ramnivas

COURSE DETAILS: CORE AND ADVANCE JAVA Core Java

Motivation. Ability is what you're capable of doing. Motivation determines what you do. Attitude determines how well you do it.

AOP Tutorial. Written By: Muhammad Asif. Department of Computer Science, Virtual University of Pakistan

Using Aspect-Oriented Programming to extend Protégé. Henrik Eriksson Linköping University

A Model for Software Plans

Chapter 32. Aspect-Oriented Software Development (AOSD) Ian Sommerville 2006 Software Engineering. Chapter 32 Slide 1

Course 7 25 November Adrian Iftene

JQueryScapes: customizable Java code perspectives

Enterprise Informatization LECTURE

Fluid AOP. Task-specific Modularity. Terry Hon. B.Sc., The University of British Columbia, 2004

Extreme Java Productivity Enterprise Applications in Just Minutes

JML and Aspects: The Benefits of

Fun with AspectJ. 1 Getting Started. 2 Defining Pointcuts. Cleveland State University Electrical and Computer Engineering Distributed: April 8, 2008

A short introduction to INF329. Spring AOP

Aspect Oriented Java RMI Server

Applying Aspect Oriented Programming on Security

Chapitre 6 Programmation orientée aspect (AOP)

Meta-Program and Meta-Programming

Aspect-Oriented Programming with C++ and AspectC++

GETTING STARTED WITH ASPECTJ

Mobile and Context-aware Interactive Systems

Refactoring Aspect Oriented Software

An AspectJ-enabled Eclipse Runtime Engine - Demonstration at AOSD 04 - Martin Lippert

Eclipse SOA Tools Platform Project

Aspect-oriented programming with AspectJ

Take Control with AspectJ

Employing Query Technologies for Crosscutting Concern Comprehension

Aspects and Soar: A Behavior Development Model. Jacob Crossman

JAVA COURSES. Empowering Innovation. DN InfoTech Pvt. Ltd. H-151, Sector 63, Noida, UP

Getting the Most from Eclipse

Advances in Aspect-oriented Programming

Seam 3. Pete Muir JBoss, a Division of Red Hat

OSGi on the Server. Martin Lippert (it-agile GmbH)

Improving Software Modularity using AOP

Call: Core&Advanced Java Springframeworks Course Content:35-40hours Course Outline

Spring Interview Questions

IBM. IBM WebSphere Application Server Migration Toolkit. WebSphere Application Server. Version 9.0 Release

InsECTJ: A Generic Instrumentation Framework for Collecting Dynamic Information within Eclipse

Spring & Hibernate. Knowledge of database. And basic Knowledge of web application development. Module 1: Spring Basics

What s new with tooling for Spring, Grails and the Cloud

Enterprise AOP With the Spring Framework

Language-Independent Aspect-Oriented Programming

Java SE7 Fundamentals

Software Engineering: Design Aspect-Oriented Programming and Modularity

Aspect-Oriented Programming

This cheat sheet is aimed at people with some experience in eclipse but who may not be aware of many of its features.

A Unit Testing Framework for Aspects without Weaving

AOSA - Betriebssystemkomponenten und der Aspektmoderatoransatz

From Feature to Code. SCRUM + NetBeans RCP + Featureous. John Kostaras JCrete August 2014

Specifying Pointcuts in AspectJ

Desarrollo de Aplicaciones Web Empresariales con Spring 4

Chapter 1 GETTING STARTED. SYS-ED/ Computer Education Techniques, Inc.

So, What is an Aspect?

At the shell prompt, enter idlde

Chapter 3. Interactive Software Development Assistants Logic-based Software Representation. Logic-based Software Analysis

EVALUATING DATA STRUCTURES FOR RUNTIME STORAGE OF ASPECT INSTANCES

Java J Course Outline

Eclipse SOA Tooling Platform: Project Overview. An Overview of the Eclipse STP (SOA Tooling Platform) Project

Some language elements described in this text are not yet supported in the current JAsCo version (0.8.x). These are: Multiple hook constructors

Advanced Java Programming

Using and Extending AspectJ for Separating Concerns in Parallel Java Code

Aquarium: AOP for Ruby

Aspect-Oriented Programming

Mapping Features to Aspects

Java Training For Six Weeks

Call: JSP Spring Hibernate Webservice Course Content:35-40hours Course Outline

purequery Deep Dive Part 2: Data Access Development Dan Galvin Galvin Consulting, Inc.

Idioms for Building Software Frameworks in AspectJ

J2EE Development. Course Detail: Audience. Duration. Course Abstract. Course Objectives. Course Topics. Class Format.

Index. Symbols. /**, symbol, 73 >> symbol, 21

A Closer Look at XPages in IBM Lotus Domino Designer 8.5 Ray Chan Advisory I/T Specialist Lotus, IBM Software Group

Chapter 4 Remote Procedure Calls and Distributed Transactions

AOP Framed! Informatics Center Federal University of Pernambuco

Introduction to Web Application Development Using JEE, Frameworks, Web Services and AJAX

Communication and Distributed Processing

Type of Classes Nested Classes Inner Classes Local and Anonymous Inner Classes

Transcription:

AJDT: Getting started with Aspect-Oriented Programming in Eclipse Matt Chapman IBM Java Technology Hursley, UK AJDT Committer Andy Clement IBM Java Technology Hursley, UK AJDT & AspectJ Committer Mik Kersten UBC AJDT & AspectJ Committer 2 nd March 2005

Agenda What is Aspect-Oriented Programming (AOP)? A brief overview of AspectJ Demos demos demos AspectJ Development Tools (AJDT) for Eclipse Adopting the technology Looking ahead AJDT AspectJ 2

good modularity socket creation in Tomcat colored lines show relevant lines of code fits nicely into one package (3 classes) 3

pretty good modularity class loading in Tomcat colored lines show relevant lines of code mostly in one package (9 classes) 4

not so good modularity logging in Tomcat scattered across the packages and classes error handling, security, business rules, 5

the cost of tangled code redundant code same fragment of code in many places difficult to reason about non-explicit structure the big picture of the tangling isn t clear difficult to change have to find all the code involved and be sure to change it consistently 6

the aop idea crosscutting is inherent in complex systems crosscutting concerns have a clear purpose have a natural structure so, let s capture the structure of crosscutting concerns explicitly... in a modular way with linguistic and tool support aspects are well-modularized crosscutting concerns 7

How does it work? AOP concepts join points pointcuts advice inter-type declarations aspects 8

Join Points Points (events) in the execution of a program E.g. Call to a method, set of a field, initialization of an instance Every program has hundreds/thousands of these Including all your existing Java programs! Not all events are of equal interest calling a method vs. the execution of the 27 th byte code instruction 9

Types of Join Points Method & Constructor call Method & Constructor execution advice execution Field get & set Exception handler execution Static & dynamic initialization 10

Pointcuts Used to match join point events that occur during the program execution Choose a subset of all the join points that occur during execution name and parameters pointcut move() : call(void Line.setP1(Point)) call(void Line.setP2(Point)); composition call of a method 11

Pointcuts You can select join points based on the kind of join point call, execution, get, set, the static context within, withincode the runtime context this, target, args, cflow, cflowbelow 12

Pointcuts Can provide contextual information about join points they match pointcut accountchange(bankaccount acc) : set(!transient * *) && formal parameter target(acc); wildcards parameter binding 13

Advice Action to take at matched join points parameter binding after(bankaccount acc) returning : accountchange(acc) { view.updateaccountdetails(acc); } executes at every join point matched by accountchange 14

Types of Advice before() Before the selected join point matched after() returning After successfully returning from the selected join point after() throwing After returning with an exception from the selected join point after() finally After returning normally or with an exception from the selected join point around() Both before and after, optionally executing the selected join point 15

Aspects The unit of modularity for cross-cutting concerns huh? 16

An Aspect unit of modularity public aspect AccountWatcher { private View view; public void setview(view v) { this.view = v;} pointcut accountchange(bankaccount acc) : set(!transient * *) && target(acc); state behaviour after(bankaccount acc) returning : accountchange(p) { } } view.updateaccount(p); there are no explicit calls to this advice in the system 17

Enough! Time for a demo a day in the life of an AspectJ programmer Eclipse is #1 for AOP AspectJ Development Tools (AJDT) for Eclipse Integrate the AspectJ compiler into the Eclipse environment Open Source Developed in Hursley Partnership with AspectJ team 18

AJDT Demo A simple project 19

Web Services Invocation Framework (WSIF) Middleware component Simple Java API for invoking web services, no matter how or where they are provided Released to Apache But IBM wants a version tightly coupled to IBM s normal qualities of service IBM tracing/monitoring/management How do we manage this? 20

AJDT Demo - WSIF 21

Exploring Re-Use: The WSIF Story org.apache.wsif WSIF for Open Source Community + WebSphere RAS WebSphere FFDC Composition WSIF for WebSphere WebSphere PMI 22

Demo conclusions Capabilities of AOSD technology look promising Code size reduction No tangling Faster development times Product-line engineering 23

Eliminating tangling BEFORE try { if (!removed) entitybean.ejbpassivate(); setstate( POOLED ); } catch (RemoteException ex ) { FFDCEngine.processException( ex, EBean.passivate(), 237, this); destroy(); throw ex; } finally { if (!removed && statisticscollector!= null) { statisticscollector. recordpassivation(); } removed = false; beanpool.put( this ); if (Logger.isEnabled) { Logger.exit(tc, passivate ); } } AFTER try { if (!removed) entitybean.ejbpassivate(); setstate( POOLED ); } catch (RemoteException ex ) { destroy(); throw ex; } finally { removed = false; beanpool.put( this ); } Crosscutting concerns extracted Example: Code to handle EJB Entity bean passivation 24

Applications of AOP Problem determination Logging, FFDC, performance monitoring Architectural rule enforcement Contracts, encapsulation, separation (no up calls ) Other concerns Security, transactions, persistence, caching/pooling, locking Open source integration 25

Adopting AOP reward 26 exploration enforcement auxiliary / infrastructure core / business AO Analysis, AO Design, AO Strategy time & confidence

Simple but powerful enforcement aspect Warn developers using System.out, System.err and printstacktrace Try this when you get home! public aspect EnforceLogging { pointcut scope(): within(com.example..*); pointcut printing(): get(* System.out) get(* System.err) call(* Throwable+.printStackTrace()); } declare warning: scope() && printing(): "don't print, use the logger"; 27

AJDT status: Stable release stream 1.1.12 released August 2004 Changes since 1.1.4 include: Per-project and global compiler settings Related location context menu entries Gutter annotations for in-jar aspects and ITDs New cheat sheet and welcome pages New dynamic build configurations New advice icons including indication of runtime test Property pages for InPath and AspectPath settings Standalone extensible Visualiser Ajdoc wizard Export AspectJ plugins wizard Breakpoints in aspects 28

AJDT status: Development release stream Milestone builds of 1.2.0 Nearly there - changes so far include: AspectJEditor improvements: code completion, organize imports, add import, code formatting, and folding Eagerly parsed structure of aspects shown in package explorer and outline view Visualiser changes: rendering is faster and uses less memory, new look, extensible drawing styles and palettes, new drawing preferences page, new selection and keyboard traversal mechanisms, improved scaling modes, support for showing AspectJ errors and warnings, and new provider for Eclipse resources New wizard for exporting AspectJ projects to JAR files New launch configurations with support for AspectPath and main methods in aspects cont d 29

AJDT status: Development release stream Changes in 1.2.0 continued: Now built with AspectJ / AJDT New cross reference view to show crosscutting relationships Image decorator to show advised elements In-place outline view in AspectJ editor Incremental compilation now the default New advises markers, to allow two-way navigation via markers Visible project settings file to enable shared configurations Includes AspectJ 5 builds 30

AJDT Future plans Deliver AJDT 1.2.0 final for Eclipse 3.0 and 3.1: Closer integration with JDT/Eclipse A robust, stable development environment AJDT 1.2.1 and beyond: Aspect-aware and aspect-specific refactorings AspectJ-specific quick fixes Support for aspect libraries More views and support for working with the crosscutting nature of your applications 31

Current AspectJ Status v1.2.1 currently released version See the readme s for 1.2 and 1.2.1 linked from our website Last release before we tackled Tiger Currently working on AspectJ5 Targeted for March release AspectJ5 Features: Includes JDT compiler that supports Java 5 annotations/generics/autoboxing/varargs/enums/etc.. Pointcut syntax now aware of Java 5 language features Write pointcuts that match based on annotations After joining with the AspectWerkz team AspectJ5 will now support an alternative annotation style syntax for aspect development Improved Load Time Weaving support 32

What Next? AspectJ home page: http://www.eclipse.org/aspectj AJDT home page: http://www.eclipse.org/ajdt Pick up a book Attend a conference (see http://aosd.net) Or email us: Matt Chapman mchapman@uk.ibm.com Andy Clement clemas@uk.ibm.com Chicago, USA March 14-18, 2005 Mik Kersten beatmik@cs.ubc.ca 33