AspectOriented Programming with AspectJ - PowerPoint PPT Presentation

1 / 14
About This Presentation
Title:

AspectOriented Programming with AspectJ

Description:

... properties that can be cleanly encapsulated in a unit of ... AOP languages, like AspectJ, provide mechanisms to cleanly abstract from components & aspects ... – PowerPoint PPT presentation

Number of Views:49
Avg rating:3.0/5.0
Slides: 15
Provided by: jnhe
Category:

less

Transcript and Presenter's Notes

Title: AspectOriented Programming with AspectJ


1
Aspect-Oriented Programmingwith AspectJ
  • Jorrit N. Herder
  • jnherder_at_cs.vu.nl
  • Vrije Universiteit, Amsterdam
  • May 30, 2002

2
Without AOP
3
With AOP
4
Talk Outline
  • Different types of properties in software
  • What aspect-oriented programming does
  • An aspect-oriented extension to Java
  • Seperating aspects and components
  • Code example how synchronization policies can be
    enforced with AOP
  • Overview of AOP and conclusion

5
Software properties (1/2)
  • Components properties that can be cleanly
    encapsulated in a unit of function or behavior,
    like a procedure or object.
  • Aspects cross-cutting concerns that cannot be
    captured in a functional decomposition
    properties affecting the performance or semantics
    of components.

6
Software properties (2/2)
  • Components
  • GUI elements
  • Readers and writers
  • Database
  • Aspects
  • Debugging
  • Logging
  • Synchronization

7
Aspect-Oriented Programming
  • Separation of components and aspects
  • This higher level of abstraction results in
  • Better understanding of software because of high
    level of abstraction
  • Easier development and maintenance because
    tangling of code is prevented
  • Increased potential for reuse for both components
    as well as aspects

8
AspectJ
  • Is a general-purpose aspect-oriented extension to
    Java, which is freely available from
    http//www.aspectj.org/
  • Java defines components as before
  • by encapsulating data and behavior in objects
  • AspectJ defines aspect modules
  • by describing join points and behavior

9
Aspect Modules
  • Identify join points
  • Points in the execution of components where
    aspects should be applied
  • E.g method invocation or object construction
  • Describe behavior at join points
  • Wrap join points with extra code just before or
    just after execution
  • E.g. lock and unlock shared data

10
Example (1/2)
  • Suppose multiple objects are concurrently working
    on some shared data
  • Exclusive access needed for modification shared
    data must be locked temporarily
  • Components readers, writers, and data
  • Aspect the locking literally cross-cuts all
    components that are working on the data

11
Example (2/2)
  • Without AOP
  • Every component that works on the shared data
    must take care of the locking itself, leading to
    tangled and complex code
  • With AOP
  • The locking aspects and components are separated
    by defining aspect modules, resulting in usual
    benefits of modularization

12
  • aspect ExclusiveAccess
  • pointcut access() / three join points /
  • call( void SharedData.setX(TypeX) )
  • call( void SharedData.setY(TypeY) )
  • call( void SharedData.setZ(TypeZ) )
  • before() access() / behavior at joint
    point /
  • acquireLock() / just before entering
    /
  • after() access() / behavior at joint
    point /
  • releaseLock() / just after
    returning /

13
Overview of AOP
14
Conclusion
  • Todays programming languages have problems
    capturing cross-cuttings
  • AOP languages, like AspectJ, provide mechanisms
    to cleanly abstract from components aspects
  • Improved modularity allows simpler code that is
    easier to develop and maintain, and that has
    greater potential for reuse
Write a Comment
User Comments (0)
About PowerShow.com