Aspect-Oriented Programming with the Eclipse AspectJ plug-in

Slides:



Advertisements
Similar presentations
Aspect Oriented Programming. AOP Contents 1 Overview 2 Terminology 3 The Problem 4 The Solution 4 Join point models 5 Implementation 6 Terminology Review.
Advertisements

ASTA Aspect Software Testing Assistant Juha Gustafsson, Juha Taina, Jukka Viljamaa University of Helsinki.
1 JAC : Aspect Oriented Programming in Java An article review by Yuval Nir and Limor Lahiani.
©Ian Sommerville 2006Software Engineering, 8th edition. Chapter 32 Slide 1 Aspect-oriented Software Development.
Aspect Oriented Programming - AspectJ Radhika Rajput.
Secure Systems Research Group - FAU Aspect Oriented Programming Carlos Oviedo Secure Systems Research Group.
Aspect-Oriented Programming. Procedural Programming Abstract program into procedures. Object-Oriented Programming Abstract program into objects. Aspect-Oriented.
University of British Columbia Software Practices Lab Fluid AOP Join Point Models Terry Hon Gregor Kiczales.
University of British Columbia Software Practices Lab 2005 CASCON A Fluid AOP Editor Terry Hon Gregor Kiczales.
ASPECT ORIENTED SOFTWARE DEVELOPMENT Prepared By: Ebru Doğan.
University of British Columbia Software Practices Lab CAS Seminar 06 Fluid AJ - A Simple Fluid AOP Tool Terry Hon Gregor Kiczales.
Introduction to Java Lab CS110A – Lab Section 004 Instructor: Duo Wei.
Aspect Oriented Programming Written by Michael Beder.
Outline Introduction Problem Statement Object-Oriented Design Aspect-Oriented Design Conclusion Demo.
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University 1 Debugging Support.
Introduction to AOP.
Introduction to Aspect Oriented Programming Presented By: Kotaiah Choudary. Ravipati M.Tech IInd Year. School of Info. Tech.
Aspect Oriented Programming (AOP) in.NET Brent Krueger 12/20/13.
Aspect Oriented Programming Razieh Asadi University of Science & Technology Mazandran Babol Aspect Component Based Software Engineering (ACBSE)
Abc Compiler Zak Fry. Who and Where Programming Tools Group at Oxford University, UK – Oege de Moor Sable Research Group at McGill University, Quebec.
Aspect Oriented Programming Scott Nykl CSSE 411 Senior Seminar.
©Ian Sommerville 2006Software Engineering, 8th edition. Chapter 32 Slide 1 Aspect-oriented Software Development 1.
Clement Allen, PhD Florida A&M University SUMMER 2006.
Aspect Oriented Programming Sumathie Sundaresan CS590 :: Summer 2007 June 30, 2007.
Aspect Oriented Programming Gülşah KARADUMAN.
Methodology: The AOP Refactoring Process Aspect-Oriented Refactoring of the Apache Cocoon Shared-Object Resource Allocation System Jeff Dalton Advisor:
A Distributed Aspect-Oriented System for J2EE Applications Muga Nishizawa and Shigeru Chiba (Tokyo Institute of Technology, Japan) Background - As benefits.
TRANSPARENT EXTENSION OF SINGLE- USER APPLICATIONS TO MULTI-USER REAL-TIME COLLABORATIVE SYSTEMS An Aspect Oriented Approach to Framework Integration ICEIS.
AOP-1 Aspect Oriented Programming. AOP-2 Aspects of AOP and Related Tools Limitation of OO Separation of Concerns Aspect Oriented programming AspectJ.
CCC: An Aspect-Oriented Intermediate Language on.Net Platform Yingfei Xiong and Feng Wan University of Electronic Science and Technology of China, China.
1 An Aspect-Oriented Implementation Method Sérgio Soares CIn – UFPE Orientador: Paulo Borba.
IDENTIFYING SEMANTIC DIFFERENCES IN ASPECTJ PROGRAMS Martin Görg and Jianjun Zhao Computer Science Department, Shanghai Jiao Tong University.
Inter-Type Declarations in AspectJ Awais Rashid Steffen Zschaler © Awais Rashid, Steffen Zschaler 2009.
Slicing AspectJ Woven Code Luca Cavallaro Mattia Monga Antonio Castaldo D'Ursi Davide Balzarotti Politecnico di Milano.
AspectJ – AOP for Java Tom Janofsky. Instructor at Penn State Abington Consultant with Chariot Solutions JUG Member.
Weaving a Debugging Aspect into Domain-Specific Language Grammars SAC ’05 PSC Track Santa Fe, New Mexico USA March 17, 2005 Hui Wu, Jeff Gray, Marjan Mernik,
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University IWPSE 2003 Program.
Chapter 8: Aspect Oriented Programming Omar Meqdadi SE 3860 Lecture 8 Department of Computer Science and Software Engineering University of Wisconsin-Platteville.
AOP-Driven Variability in Software Product Lines Vander Alves, Ayla Dantas, and Paulo Borba Informatics Center – UFPE – Brazil
Java FilesOops - Mistake Java lingoSyntax
Kansas City Java User’s Group Jason W. Bedell July 12, 2006
问题 Code scattering Blocks of duplicated code Blocks of complementary code, and different modules implementing complementary parts of the concern Code.
Comparison of Different AOP Approaches Presented by: Xiaojing Wang.
aspectj tools new and noteworthy Mik Kersten University of British Columbia Adrian Colyer IBM Hursley OOPSLA, October
AOSD'04, Lancaster, UK 1 Remote Pointcut - A Language Construct for Distributed AOP Muga Nishizawa (Tokyo Tech) Shigeru Chiba (Tokyo Tech) Michiaki Tatsubori.
Introduction to Aspect- Oriented Programming CS 3360 Gregor Kiczales, et. al. Getting started with AspectJ, CACM, 44(10):59-65, October Spring 2012.
CSC450 Software Engineering Devon M. Simmonds University of North Carolina, Wilmington 1.
AspectScope: An Outline Viewer for AspectJ Programs Michihiro Horie, Shigeru Chiba Tokyo Institute of Technology, Japan.
AOP with AspectJ Awais Rashid, Steffen Zschaler © Awais Rashid, Steffen Zschaler 2009.
Aspect-Oriented Software Development (AOSD)
Computer Science A 1. Course plan Introduction to programming Basic concepts of typical programming languages. Tools: compiler, editor, integrated editor,
1 Aspectual Caml an Aspect-Oriented Functional Language Hideaki Tatsuzawa Hidehiko Masuhara Akinori Yonezawa University of Tokyo.
AspectJ Development Tools Mik Kersten University of British Columbia October 28, 2003.
aspectj tools new and noteworthy Mik Kersten University of British Columbia Andy Clement, George Harley IBM Hursley Labs.
 Is a programming paradigm  Extends OOP  Enables modularization of cross cutting concerns.
Object-Oriented programming for Beginners LEAPS Computing 2015
Software Engineering Lecture 7
An Interface Mechanism for Encapsulating Weaving in Class-based AOP
SharePoint-Hosted Apps and JavaScript
Lecturer: Mukhtar Mohamed Ali “Hakaale”
Aspect-Oriented Programming
Aspect-Oriented Programming
Aspect-Oriented Design and Patterns
Eclipse Database Plug-ins
Fundamentals of Programming
Structuring Adaptive Applications using AspectJ and AOM
AspectAda Aspect-Oriented Programming for Ada95
Aspect Oriented Software Design
Aspect Oriented Programming
Presentation transcript:

Aspect-Oriented Programming with the Eclipse AspectJ plug-in David Gallardo

The problem Object-oriented programming provides a solution for business logic, but other concerns complicate a clean OO design and implementation Common services are often required: Logging Authentication Persistence Instrumentation Etc. These requirements lead to code unrelated to the business being scattered throughout the application and are called crosscutting concerns. Problems in more detail: Code tangling (classes deal with issues besides business logic) Code scattering (service code needs to be included in multiple classes) Lower productivity (code duplicated instead of re-used) Limited re-usability (business logic is polluted with service code that is potentially system or platform specific)

Crosscutting concerns Crosscutting concerns, are also called orthogonal concerns. Removing these concerns (removing the code that does logging, for example) doesn’t affect the behavior of the base program.

The solution: Aspect-Oriented Programming Researchers at Xerox PARC start examining limitations of OOP in early 1990s Separation of concerns is identified as the key Crosscutting concerns are implemented separately as Aspects. Aspects are the fundamental unit in AOP and are equivalent to a class in OOP. Aspects interact with an application at interesting and pre-defined points in its execution such as method calls and field assignments. These are called join points. AOP has a small amount of jargon to learn. Here we introduce Aspects, crosscutting concerns and join points. We’ll see a few more terms when AspectJ, a specific AOP language is introduced.

Programming in AOP Decompose application into separate business and crosscutting concerns Implement concerns as classes and aspects Recompose business and crosscutting logic using an AOP compiler. This process is called weaving and the compiler that performs this is called a weaver. The details of this process can vary. The weaver could use source-to-source translation (with an additional compilation step), source to bytecode translation, or just-in-time execution. AspectJ does the second, source to bytecode translation, since it is basically a standard Java compiler that’s been extended to support AspectJ.

AspectJ: The first AOP language Xerox PARC researchers develop AspectJ, the first AOP language. AspectJ is a simple, well-integrated extension of Java It was given to the Eclipse Consortium in early 2002 Available on the Eclipse.org website

Installing the Eclipse AspectJ plug-in Available for 3.1. from the update site: http://download.eclipse.org/technology/ajdt/31/dev/update Works in conjunction with Eclipse’s Java development tools. This provides a source-to-bytecode weaver, based on the Eclipse Java compiler. Plus views and perspectives that support for AOP programming. Eclipse projects have one or more "natures" associated with them, so tools can identify what they can work with. Aspect projects have both Java and Aspect natures, so you can use both the Java tools and AspectJ tools to work with them.

Creating an aspect You create an aspect in Eclipse pretty much like you do a class: Create an AspectJ project for it to live Use the New wizard and select Aspect. You’ll get something that looks like this: public aspect Example { } If you named your aspect Example, it will be in a file named (by default) Example.aj

Identifying join points with a pointcut A joint point or a set of joint points is identified with a pointcut expression. A pointcut uses patterns and wildcards that match type, name and method parameters. The following identifies calls to public methods of type void that begin with the letters “say”: pointcut talk() : call(public void say*(..)); The pointcut expression language is fairly extensive & isn’t covered here. The following identifies all public getter methods that return an int or a long: pointcut access() : call(int get*(..)) || call(long get*(..));

Giving advice Pointcuts only identify where an aspect should introduce behavior. They need to be associated with advice—a code body—in order to do anything. Advice can run before or after a join point. Advice can also run around a join point. Advice of this type can affect the execution of the join point—executing it conditionally, or, in the case of a method call, modifying the parameters.

Examples of advice Here are some examples of advice for the pointcut talk from two slides ago: before() : talk() { System.out.println("Hello!"); } after() : talk() { System.out.println("Goodbye!"); }; These two pieces of advice will print out “Hello!” before, and “Goodbye!” after, every join point identified by the pointcut talk—that is, every public void method that begins with the letters “say”.

Introductions One more AspectJ feature can be included in an aspect, an introduction, or inter-type declaration. This allows the aspect to alter classes by adding fields or methods, altering class heirarchy, etc. We won’t be using these here.

Eclipse AspectJ support Decorators in the editor view identify which methods and fields in a class have advice associated with them. Cross References view provides details about advice are associated with each method or field, or methods or fields associate with each advice. Aspect Visualization perspectives shows graphically which class is affected by each aspect. Debugging support is extended to advice. We’ll see these in the demo that follows…

Eclipse AspectJ demo Demonstrate how to install using Update Create an Aspect Project Create a class and an aspect and run Demonstrate editor support, outline, cross-reference. Demonstrate Aspect Visualization perspective with Eclipse-provided example