1 / 18

Introduction to Aspect Oriented Programming

Introduction to Aspect Oriented Programming. Presented By: Kotaiah Choudary. Ravipati M.Tech IInd Year. School of Info. Tech. Contents. Introduction AOP Methodology AOP Languages AspectJ. Programming Methodologies. Introduction. Concern Abstraction. AO Programming. Object

jane
Download Presentation

Introduction to Aspect Oriented Programming

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Introduction toAspect Oriented Programming Presented By: Kotaiah Choudary. Ravipati M.Tech IInd Year. School of Info. Tech.

  2. Contents • Introduction • AOP Methodology • AOP Languages • AspectJ Aspect Oriented Programming

  3. Programming Methodologies Introduction Concern Abstraction AO Programming Object Abstraction OO Programming Function Abstraction Procedural Programming Assembly Programming Programming Methodologies Evaluation m/c Programming Aspect Oriented Programming

  4. Present Design Problem Introduction • The architect’s dilemma • How much design is too much? Aspect Oriented Programming

  5. Terminology Introduction • Concern • A specific requirement or consideration that must be addressed in order to satisfy the overall system goal • E.g. Banking system: Customer and Account management, Interbanking transactions, ATM transactions, Persistence of all entities, Transaction integrity, Authorization of access to various services, Logging, Security, Error checking, Policy enforcement Aspect Oriented Programming

  6. Terminology cont Introduction • Core concerns • Central functionality of a Business logic (single module) • Customer and Account management, Interbanking transactions, ATM transactions • Crosscut concerns • System-level, peripheral requirements (multiple modules) • Persistence of all entities, Transaction integrity, Authorization of access to various services, logging, Security, Error checking, Policy enforcement Aspect Oriented Programming

  7. Typical Application Introduction Business Logic Concern Accounting ATM Persistence Logging Database Logging Implementation modules Persistence System Accounting ATM Database Logging Persistence System Aspect Oriented Programming

  8. Implementation by Traditional Languages Introduction API invocations Accounting Module ATM Module Logging Module Database Module Aspect Oriented Programming

  9. Implementation by AOP Introduction Automatically Weaving Invocations Accounting Module API Invocation Logging Aspect ATM Module Logging Module Aspect: A modular unit of crosscutting concern implementation Database Module Aspect Oriented Programming

  10. AOP Methodology AOP Methodology • The idea behind AOP is “Separation of concern” • AOP builds upon Existing Methodologies (OOP, Procedural programming), augmenting them with concepts and constructs in order to modularize crosscutting concerns. • Now, concern consists of what? Aspect Oriented Programming

  11. AOP Development Stages AOP Methodology Security Business Logic Logging Persistence Integrating all concerns Identify concerns Aspect Oriented Programming

  12. AOP Languages AOP Languages • AOP Language Specification • Describes the language constructs and syntax • Specification for implementing the individual concerns and rules for weaving different concerns Aspect Oriented Programming

  13. AOP Languages cont AOP Languages • AOP language implementation • Verifies the code and translates the code into an executable form • Implementation done by two steps • Combining individual concerns using the weaving rules - Weaving • Then converting result into executable code. • Some AOP Languages • AspectJ, Aspect#, AspectC++, PHPaspect. Aspect Oriented Programming

  14. AspectJ AspectJ • Aspect-oriented extension to Java language • Language Specification • Language Implementation • Concern by Java Language • Weaving rules by extension Tools • Crosscutting in AspectJ • Implementation of the weaving rules by the compiler • 2 Types: • Dynamic Crosscutting • Weaving of new Behavior into execution of program • Static Crosscutting • weaving of modifications into the static structure, to support the Dynamic Crosscutting Aspect Oriented Programming

  15. AspectJ cont AspectJ • Crosscutting Elements • Join Point • Well-defined points in the execution of a program • Pointcut • A means of referring to collections of join points and certain values at those join points • Advice • Method-like constructs to define additional behavior at join points • Introduction • Instruction that changes to the classes, interfaces of the system • Compile time Declaration • Instruction for adding compile time warnings and errors to the system • Aspect • Unit of modular crosscutting implementation Aspect Oriented Programming

  16. Example AspectJ Public class Logging{//class public void check( ) { System.out.println("Inside Logging Class Method"); }} public class ATM { //class public void foo(int number, String name) { System.out.println("Inside foo Method"); } public static void main(String[] args) { MyClass myObject = new MyClass( ); myObject.foo(1, “SIT"); } } public aspect Log { //Aspect pointcut callPointcut( ) : call(void ATM.foo(int, String)); //Pointcut before( ) : callPointcut( ) { //Advice System.out.println( “I am from Log aspect"); Logging logg= new Logging(); logg.check(); } } Name of Pointcut before after around Aspect Oriented Programming

  17. Example cont AspectJ • Compile • ajc ATM.java Log. java • output: • ATM.class Log.class • Run • java ATM • Output: • I am from Log aspect Inside foo Method Here let us assume Logging class already compiled Aspect Oriented Programming

  18. References • AspectJ Cookbook , O'Reilly, December 2004 • Aspectj In Action - Practical Aspect-Oriented Programming, 2003 • http://www.codeproject.com/gen/design/aop.asp#2 • http://en.wikipedia.org/wiki/Aspect_oriented_programming • Erik Putrycz, Guy Bernard, IEEE 2002, Using Aspect Oriented Programming to build a portable load balancing service Aspect Oriented Programming

More Related