Introduction to Aspect Oriented Programming - PowerPoint PPT Presentation

1 / 18
About This Presentation
Title:

Introduction to Aspect Oriented Programming

Description:

Implementation done by two steps ... Compile time Declaration. Instruction for adding compile time warnings ... http://www.codeproject.com/gen/design/aop.asp#2 ... – PowerPoint PPT presentation

Number of Views:149
Avg rating:3.0/5.0
Slides: 19
Provided by: SIT52
Category:

less

Transcript and Presenter's Notes

Title: Introduction to Aspect Oriented Programming


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

3
Programming Methodologies
Introduction
4
Present Design Problem
Introduction
  • The architects dilemma
  • How much design is too much?

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

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

7
Typical Application
Introduction
Accounting
ATM
Database
Logging
Persistence
System
8
Implementation by Traditional Languages
Introduction
9
Implementation by AOP
Introduction
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?

11
AOP Development Stages
AOP Methodology
Integrating all concerns
Identify concerns
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

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.

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

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

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
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

18
References
  • AspectJ Cookbook , O'Reilly, December 2004
  • Aspectj In Action - Practical Aspect-Oriented
    Programming, 2003
  • http//www.codeproject.com/gen/design/aop.asp2
  • http//en.wikipedia.org/wiki/Aspect_oriented_progr
    amming
  • Erik Putrycz, Guy Bernard, IEEE 2002, Using
    Aspect Oriented Programming to build a portable
    load balancing service
Write a Comment
User Comments (0)
About PowerShow.com