Survey of AspectOriented Programming - PowerPoint PPT Presentation

1 / 8
About This Presentation
Title:

Survey of AspectOriented Programming

Description:

Survey of Aspect-Oriented Programming. Neerja Bhatnagar. CS 203 Programming ... import java.util.logging.*; static Logger logger = Logger.getLogger('Log' ... – PowerPoint PPT presentation

Number of Views:40
Avg rating:3.0/5.0
Slides: 9
Provided by: Nee71
Category:

less

Transcript and Presenter's Notes

Title: Survey of AspectOriented Programming


1
Survey of Aspect-Oriented Programming
  • Neerja Bhatnagar

CS 203 Programming Languages Fall 2004
2
Motivation for AOP
  • Code continues to grow in size and complexity
  • Code evolves to become unmodularized, and hence
    unclean
  • Application logic gets intermingled with system
    code
  • For example, business logic of processing credit
    card payment intermingled with code that logs the
    transaction
  • AOP aims to improve software design and
    development via separation of concerns

3
Conventional Logging
  • Does not utilize aspects
  • Utilizes java.util.logging
  • import java.util.logging.
  • static Logger logger Logger.getLogger(Log)
  • public void setEmployeeAddress(String address)
  • if (name ! null)
  • logger.logp(Level.INFO, Employee,
  • setEmployeeAddress, Address Changed)
  • employeeAddress address

4
Logging with Aspects
  • import org.aspectj.lang.
  • import java.util.logging.
  • public aspect AspectLog
  • Logger logger
  • Logger.getLogger(Log)
  • // specify point of execution for
  • // logging. within matches methods
  • pointcut logMethods() execution( .(..))
  • within(AspectLog)
  • // begin logging before reaching
  • // join point
  • before()logMethods()
  • Java code remains unchanged!
  • public class Employee
  • public Employee()
  • setEmployeeAddress(String
  • address)
  • Push functionality related to logging into
    aspect(s)
  • Application logic remains unchanged.

5
AOP Languages and Frameworks
Languages
  • AspectJ (Aspects for Java)
  • AspectC (Aspects for C, may be C)
  • Weave.NET (Language Independent Aspects)

Frameworks
  • Nanning (for Java) (http//nanning.codehaus.org)
  • AspectWerkz (for Java) (http//aspectwerkz.codehau
    s.org)
  • JBoss (for Java) (http//www.jboss.org)
  • HyperJ (for Java) (www.research.ibm.com/hyperspace
    /hyperj)
  • Others abc, AspectC, CLAW, AOP, AspectDNG

6
AOP Terminology (Buzzwords)
  • public class Employee
  • public String employeeName
  • public Employee()
  • public void setEmployeeName(String name)
  • if (name ! null)
  • logger.logp(Level.INFO, "Employee",
  • "setEmployeeName", "Name change")
  • employeeName name

Point Cut
Crosscutting concern
Join Point
7
AOP Terminology (Buzzwords), contd.
  • import org.aspectj.lang.
  • import java.util.logging.
  • public aspect AspectLog
  • Logger logger
  • Logger.getLogger(Log)
  • // specify point of execution for
  • // logging. within matches methods
  • pointcut logMethods() execution( .(..))
  • within(AspectLog)
  • // code that actually logs
  • // begin logging before reaching
  • // join point
  • before()logMethods()

Aspect
Advice
8
Thank You
Write a Comment
User Comments (0)
About PowerShow.com