Using Python Decorators as Java-style Annotations Jeff Bauer - - PowerPoint PPT Presentation

using python decorators as java style annotations
SMART_READER_LITE
LIVE PREVIEW

Using Python Decorators as Java-style Annotations Jeff Bauer - - PowerPoint PPT Presentation

Using Python Decorators as Java-style Annotations Jeff Bauer AspectJ - Before/After Output: @AspectJ - Before/After Output: Syntax Before/After Around def MyFunction(): def MyFunction(): --do something-- --do something--


slide-1
SLIDE 1

Using Python Decorators as Java-style Annotations

Jeff Bauer

slide-2
SLIDE 2

AspectJ - Before/After

Output:

slide-3
SLIDE 3

@AspectJ - Before/After

Output:

slide-4
SLIDE 4

Syntax

Before/After def MyFunction():

  • -do something--

@Before(<pointcut>) def MyAdvice():

  • -apply adivce--

Around def MyFunction():

  • -do something--

@After(<pointcut>) def MyAdvice(proceed, *args, **kwargs):

  • -apply adivce--
slide-5
SLIDE 5

Implementation & Examples

slide-6
SLIDE 6

Future Goals

  • “this” and “target” keywords

○ Access things other than what is passed in ○ Differentiate between call & execution

  • Applying multiple advices to one function
  • Applying advice to different kinds of methods

○ Global, Class, Static

  • Choosing functions to advise using RegExs
slide-7
SLIDE 7

Questions?