© The AspectWerkz Team 2004 What are the key issues for commercial AOP use - how does AspectWerkz address them? Jonas Bonér Senior Software Engineer BEA.

Slides:



Advertisements
Similar presentations
Numbers Treasure Hunt Following each question, click on the answer. If correct, the next page will load with a graphic first – these can be used to check.
Advertisements

Symantec 2010 Windows 7 Migration EMEA Results. Methodology Applied Research performed survey 1,360 enterprises worldwide SMBs and enterprises Cross-industry.
Simplifications of Context-Free Grammars
Variations of the Turing Machine
Angstrom Care 培苗社 Quadratic Equation II
3rd Annual Plex/2E Worldwide Users Conference 13A Batch Processing in 2E Jeffrey A. Welsh, STAR BASE Consulting, Inc. September 20, 2007.
AP STUDY SESSION 2.
1
Distributed Systems Architectures
Copyright © 2003 Pearson Education, Inc. Slide 1 Computer Systems Organization & Architecture Chapters 8-12 John D. Carpinelli.
1 Copyright © 2013 Elsevier Inc. All rights reserved. Chapter 4 Computing Platforms.
Processes and Operating Systems
AspectWerkz 2 - and the road to AspectJ 5 Jonas Bonér Senior Software Engineer BEA Systems.
David Burdett May 11, 2004 Package Binding for WS CDL.
18 Copyright © 2005, Oracle. All rights reserved. Distributing Modular Applications: Introduction to Web Services.
11 Copyright © 2005, Oracle. All rights reserved. Creating the Business Tier: Enterprise JavaBeans.
1 Copyright © 2005, Oracle. All rights reserved. Introducing the Java and Oracle Platforms.
Prepared by: Workforce Enterprise Services For: The Illinois Department of Commerce and Economic Opportunity Bureau of Workforce Development ENTRY OF EMPLOYER.
Local Customization Chapter 2. Local Customization 2-2 Objectives Customization Considerations Types of Data Elements Location for Locally Defined Data.
Process a Customer Chapter 2. Process a Customer 2-2 Objectives Understand what defines a Customer Learn how to check for an existing Customer Learn how.
CALENDAR.
1 10 pt 15 pt 20 pt 25 pt 5 pt 10 pt 15 pt 20 pt 25 pt 5 pt 10 pt 15 pt 20 pt 25 pt 5 pt 10 pt 15 pt 20 pt 25 pt 5 pt 10 pt 15 pt 20 pt 25 pt 5 pt BlendsDigraphsShort.
1 Chapter 12 File Management Patricia Roy Manatee Community College, Venice, FL ©2008, Prentice Hall Operating Systems: Internals and Design Principles,
1 Click here to End Presentation Software: Installation and Updates Internet Download CD release NACIS Updates.
Photo Slideshow Instructions (delete before presenting or this page will show when slideshow loops) 1.Set PowerPoint to work in Outline. View/Normal click.
© Tally Solutions Pvt. Ltd. All Rights Reserved Shoper 9 License Management December 09.
Break Time Remaining 10:00.
EE, NCKU Tien-Hao Chang (Darby Chang)
Turing Machines.
Anything But Typical Learning to Love JavaScript Prototypes Page 1 © 2010 Razorfish. All rights reserved. Dan Nichols March 14, 2010.
Table 12.1: Cash Flows to a Cash and Carry Trading Strategy.
Database Performance Tuning and Query Optimization
PP Test Review Sections 6-1 to 6-6
EIS Bridge Tool and Staging Tables September 1, 2009 Instructor: Way Poteat Slide: 1.
Outline Minimum Spanning Tree Maximal Flow Algorithm LP formulation 1.
Bellwork Do the following problem on a ½ sheet of paper and turn in.
CS 6143 COMPUTER ARCHITECTURE II SPRING 2014 ACM Principles and Practice of Parallel Programming, PPoPP, 2006 Panel Presentations Parallel Processing is.
Operating Systems Operating Systems - Winter 2012 Chapter 4 – Memory Management Vrije Universiteit Amsterdam.
Operating Systems Operating Systems - Winter 2010 Chapter 3 – Input/Output Vrije Universiteit Amsterdam.
Exarte Bezoek aan de Mediacampus Bachelor in de grafische en digitale media April 2014.
Sample Service Screenshots Enterprise Cloud Service 11.3.
Copyright © 2012, Elsevier Inc. All rights Reserved. 1 Chapter 7 Modeling Structure with Blocks.
1 RA III - Regional Training Seminar on CLIMAT&CLIMAT TEMP Reporting Buenos Aires, Argentina, 25 – 27 October 2006 Status of observing programmes in RA.
CONTROL VISION Set-up. Step 1 Step 2 Step 3 Step 5 Step 4.
Adding Up In Chunks.
MaK_Full ahead loaded 1 Alarm Page Directory (F11)
1 10 pt 15 pt 20 pt 25 pt 5 pt 10 pt 15 pt 20 pt 25 pt 5 pt 10 pt 15 pt 20 pt 25 pt 5 pt 10 pt 15 pt 20 pt 25 pt 5 pt 10 pt 15 pt 20 pt 25 pt 5 pt Synthetic.
Implementation Architecture
HORIZONT 1 XINFO ® The IT Information System HORIZONT Software for Datacenters Garmischer Str. 8 D München Tel ++49(0)89 /
2004 EBSCO Publishing Presentation on EBSCOadmin.
: 3 00.
5 minutes.
Chapter 2 Entity-Relationship Data Modeling: Tools and Techniques
1 hi at no doifpi me be go we of at be do go hi if me no of pi we Inorder Traversal Inorder traversal. n Visit the left subtree. n Visit the node. n Visit.
Types of selection structures
Speak Up for Safety Dr. Susan Strauss Harassment & Bullying Consultant November 9, 2012.
1 Titre de la diapositive SDMO Industries – Training Département MICS KERYS 09- MICS KERYS – WEBSITE.
Essential Cell Biology
Converting a Fraction to %
Clock will move after 1 minute
PSSA Preparation.
Chapter 11 Creating Framed Layouts Principles of Web Design, 4 th Edition.
 2003 Prentice Hall, Inc. All rights reserved. 1 Chapter 13 - Exception Handling Outline 13.1 Introduction 13.2 Exception-Handling Overview 13.3 Other.
Physics for Scientists & Engineers, 3rd Edition
Select a time to count down from the clock above
Introduction Peter Dolog dolog [at] cs [dot] aau [dot] dk Intelligent Web and Information Systems September 9, 2010.
1 Decidability continued…. 2 Theorem: For a recursively enumerable language it is undecidable to determine whether is finite Proof: We will reduce the.
Aspects in the Real World Applying AOSD techniques in large systems.
What are the key issues for commercial AOP use
Presentation transcript:

© The AspectWerkz Team 2004 What are the key issues for commercial AOP use - how does AspectWerkz address them? Jonas Bonér Senior Software Engineer BEA Systems

2© The AspectWerkz Team 2004 Outline I AspectWerkz overview what is AspectWerkz? how does it compare with AspectJ? II Design goals and decisions what are the key issues for commercial AOP? how does AspectWerkz solve them? III Conclusion future, links, questions

3© The AspectWerkz Team 2004 Outline I AspectWerkz overview what is AspectWerkz? how does it compare with AspectJ? II Design goals and decisions what are the key issues for commercial AOP? how does AspectWerkz solve them? III Conclusion future, links, questions

4© The AspectWerkz Team 2004 What is AspectWerkz? Dynamic AOP framework for Java Open Source, founded Q Sponsored by Tailored for dynamic AOP in real world applications JLS compatible Definition syntax in XML and/or Attributes Load time, runtime and static weaving Allows redefinition of aspects at runtime

5© The AspectWerkz Team 2004 Example using AspectJ aspect AsynchAspect { private ThreadPool m_threadPool =... Object around(): execution(void foo.bar.Baz.*(..)){ m_threadPool.execute(new Runnable() { public void run() { try { // proceed the execution in a new thread proceed(); } catch (Throwable e) { throw new WrappedRuntimeException(e); } }); return null; } }

6© The AspectWerkz Team 2004 The same example using AspectWerkz class AsynchAspect extends Aspect { private ThreadPool m_threadPool =... execution(void foo.bar.Baz.*(..)) */ Object execute(JoinPoint joinPoint) throws Throwable { m_threadPool.execute(new Runnable() { public void run() { try { // proceed the execution in a new thread joinPoint.proceed(); } catch (Throwable e) { throw new WrappedRuntimeException(e); } }); return null; } } Bind advice to pointcut

7© The AspectWerkz Team 2004 XML definition syntax <aspect class="samples.AsynchAspect" deployment-model="perJVM"> <advice name="execute" type="around" bind-to="execution(void foo.bar.Baz.*(..))"/> Deployment modelBind advice to pointcut

8© The AspectWerkz Team 2004 One underlying model Join point model Aspect model Runtime system Static compilation Load time weaving Runtime weaving XML definition Attribute definition One sole model Different views Different weaving schemes

9© The AspectWerkz Team 2004 Outline I AspectWerkz overview what is AspectWerkz? how does it compare with AspectJ? II Design goals and decisions what are the key issues for commercial AOP? how does AspectWerkz solve them? III Conclusion future, links, questions, etc.

10© The AspectWerkz Team 2004 Design goals and decisions overview JLS compatibi lity XML and Attribute definition Load time and Runtime weaving AspectJs join point/ pointcut model Dynamic runtime model Runtime compiler (JIT) Usability & Ease of adoption Integration Tool support Expressivenes s & Orthogonality Performance vs. Dynamicity Enterprise application support Goals Decisions

11© The AspectWerkz Team 2004 Design goals and decisions overview JLS compatibi lity XML and Attribute definition Load time and Runtime weaving AspectJs join point/ pointcut model Dynamic runtime model Runtime compiler (JIT) Usability & Ease of adoption Integration Tool support Expressivenes s & Orthogonality Performance vs. Dynamicity Enterprise application support Goals Decisions

12© The AspectWerkz Team 2004 Design goals and decisions overview JLS compatibi lity XML and Attribute definition Load time and Runtime weaving AspectJs join point/ pointcut model Dynamic runtime model Runtime compiler (JIT) Usability & Ease of adoption Integration Tool support Expressivenes s & Orthogonality Performance vs. Dynamicity Enterprise application support Goals Decisions

13© The AspectWerkz Team 2004 Design goals and decisions overview JLS compatibi lity XML and Attribute definition Load time and Runtime weaving AspectJs join point/ pointcut model Dynamic runtime model Runtime compiler (JIT) Usability & Ease of adoption Integration Tool support Expressivenes s & Orthogonality Performance vs. Dynamicity Enterprise application support Goals Decisions

14© The AspectWerkz Team 2004 Design goals and decisions overview JLS compatibi lity XML and Attribute definition Load time and Runtime weaving AspectJs join point/ pointcut model Dynamic runtime model Runtime compiler (JIT) Usability & Ease of adoption Integration Tool support Expressivenes s & Orthogonality Performance vs. Dynamicity Enterprise application support Goals Decisions

15© The AspectWerkz Team 2004 Design goals and decisions overview JLS compatibi lity XML and Attribute definition Load time and Runtime weaving AspectJs join point/ pointcut model Dynamic runtime model Runtime compiler (JIT) Usability & Ease of adoption Integration Tool support Expressivenes s & Orthogonality Performance vs. Dynamicity Enterprise application support Goals Decisions

16© The AspectWerkz Team 2004 Design goals and decisions overview JLS compatibi lity XML and Attribute definition Load time and Runtime weaving AspectJs join point/ pointcut model Dynamic runtime model Runtime compiler (JIT) Usability & Ease of adoption Integration Tool support Expressivenes s & Orthogonality Performance vs. Dynamicity Enterprise application support Goals Decisions

17© The AspectWerkz Team 2004 Usability and Ease of adoption JLS compatibil ity XML and Attribute definition Load time and Runtime weaving AspectJs join point/ pointcut model Dynamic runtime model Runtime compiler (JIT) Usability & Ease of adoption Integration Tool support Expressivenes s & Orthogonality Performance vs. Dynamicity Enterprise application support Goals Decisions

18© The AspectWerkz Team 2004 Design decisions JLS compatibility Attribute definition (self-defined aspects) Metadata represented as attributes Currently custom JavaDoc tags are parsed and inserted in the compiled aspect.class file Ready for JSR-175 (attributes in Java 1.5) XML definition Definition of the aspect if no metadata used Reuse and refinement of the model if metadata used

19© The AspectWerkz Team 2004 Advantages Pure Java and XML is intuitive to users of Java and J2EE Integrates well in any IDE source parse Works well with any testing framework and refactoring tool AspectWerkz stays out of the way Allows decoupling of pointcuts and advice Some decisions can be taken at deployment time

20© The AspectWerkz Team 2004 Disadvantages Less elegant and concise syntax compared to a language extension

21© The AspectWerkz Team 2004 Why two definition models? Which to prefer? Complements each other Good in different contexts and situations

22© The AspectWerkz Team 2004 XML definition Advantages No post compilation for metadata management Loosely coupled Drawbacks Separates the implementation from the definition Can make the application harder to maintain refactor

23© The AspectWerkz Team 2004 Attribute definition Advantages Aspects are self-defined and self-contained Both implementation and definition in the same single class Easy to build reusable aspect libraries Drawbacks Requires an additional compilation step (not in Java 1.5 and above) Stronger coupling

24© The AspectWerkz Team 2004 Conclusions Both AspectWerkzs approach and AspectJs language extension introduces a new language Hard to keep the model orthogonal, extensible and expressive but yet simple and easy to understand Early versions with advice modeled after the command pattern did not scale at all For example a single aspect could consist of five classes and a XML definition file

25© The AspectWerkz Team 2004 Integration JLS compatibi lity XML and Attribute definition Load time and Runtime weaving AspectJs join point/ pointcut model Dynamic runtime model Runtime compiler (JIT) Usability & Ease of adoption Integration Tool support Expressivenes s & Orthogonality Performance vs. Dynamicity Enterprise application support Goals Decisions

26© The AspectWerkz Team 2004 Target problem Using a custom class loader has problems (JBoss, weblogic-aspects and cglib etc.): All classes needs to be loaded using this custom loader Can not transform classes loaded by any other loader AspectWerkzs solution: Provides a JVM wide hook mechanism Controls all class loading in the JVM Platform and vendor independent Tested and verified on: WebLogic, JBoss, Tomcat, WebSphere, IBM JRE, BEA JRockit, Sun HotSpot, Java 1.3, 1.4

27© The AspectWerkz Team 2004 Load time weaving JDI and HotSwap Using classloader patching Requires the –Xdebug flag (debug mode) JRockit MAPIs class redefinition capabilities No classloader patching or -Xdebug flag JVMTI (JSR-163) in Java 1.5 Will standardize class redefinition in Java No classloader patching or –Xdebug flag

28© The AspectWerkz Team 2004 Runtime weaving Problem: some weaving operations requires schema changes Our current solution: Two phase weaving First phase: Classes are first prepared at load time (tiny) Second phase: Classes can then be woven at any point In-process HotSwap No JDWP and startup JVM needed Multi weaving Classes can be woven, rewoven or unwoven at any point

29© The AspectWerkz Team 2004 Runtime weaving Zero overhead at runtime (for non- woven or unwoven methods) The original bytecode is guaranteed to run (for non-woven or unwoven methods)

30© The AspectWerkz Team 2004 Conclusions The JVM wide hook mechanism makes it possible for the framework to work correct in complex class loader hierarchies (application servers etc.) We believe that load time and runtime bytecode weaving makes the integration more transparent than a static compilation process

31© The AspectWerkz Team 2004 Disadvantages Slows down startup time: The startup process does not scale well in certain situations This problem will somehow be addressed with: JVMTI => No -Xdebug flag needed JRockit MAPI => No -Xdebug (Java 1.3 and 1.4) Port to ASM bytecode library (>700% percent faster than BCEL/Javassist) Optimizations (like parsing the constant pool to allow early filtering of classes) Native JVM support

32© The AspectWerkz Team 2004 Tool support JLS compatibi lity XML and Attribute definition Load time and Runtime weaving AspectJs join point/ pointcut model Dynamic runtime model Runtime compiler (JIT) Usability & Ease of adoption Integration Tool support Expressivenes s & Orthogonality Performance vs. Dynamicity Enterprise application support Goals Decisions

33© The AspectWerkz Team 2004 Tool support AspectWerkz is currently lacking good tool support apart from: Plugin for the build system Support for debugging aspects within an IDE JUnit (unit testing framework) extension The standardization of attributes in JSR-175 will bring many tools for working with metadata We believe that good tool support will become a crucial factor for mass adoption

34© The AspectWerkz Team 2004 Expressiveness and Orthogonality JLS compatibi lity XML and Attribute definition Load time and Runtime weaving AspectJs join point/ pointcut model Dynamic runtime model Runtime compiler (JIT) Usability & Ease of adoption Integration Tool support Expressivenes s & Orthogonality Performance vs. Dynamicity Enterprise application support Goals Decisions

35© The AspectWerkz Team 2004 Join point and pointcut model Regular expression based pointcut language, largely inspired by AspectJ Join point model largely inspired by AspectJ Supported join points: method (static and member) and constructor execution method (static and member) and constructor call field (static and member) modification and access catch clauses cflow Supports pointcut composition Supported advice: around, before and after

36© The AspectWerkz Team 2004 Orthogonality Orthogonality is: crucial for the model to scale (with the needs of the application) needed for the model to be intuitive and predictable In the latest version we have reached a high level of orthogonality: All advice types works with all pointcut designators Pointcut composition allows combinations of all types of pointcuts

37© The AspectWerkz Team 2004 Definition constructs Definition constructs in AspectJ: join points pointcuts advice implementation AspectWerkz introduces a new construct the binding from pointcuts to advice implementation Allows AspectWerkz to have named advice Useful in dynamic AOP as a handle to the advice

38© The AspectWerkz Team 2004 Current limitations Does not support all the dynamic and static pointcut designators as AspectJ We currently do not support: cflowbelow (in development) within (in development) args (planned) target (planned) static initialization (planned) pre initialization if

39© The AspectWerkz Team 2004 Performance vs. Dynamicity JLS compatibi lity XML and Attribute definition Load time and Runtime weaving AspectJs join point/ pointcut model Dynamic runtime model Runtime compiler (JIT) Usability & Ease of adoption Integration Tool support Expressivenes s & Orthogonality Performance vs. Dynamicity Enterprise application support Goals Decisions

40© The AspectWerkz Team 2004 Design decisions Dynamic runtime model Allows redefinition of the system at runtime Introduces a layer of indirection, loose coupling Makes use of delegation and reflection Runtime (Just-In-Time) Compiler Similar to JIT compilers in modern JVMs Detects advice chains that are often executed and compiles a custom class on the fly that invokes the advice chain and the target join point statically Aware of redefinitions of the runtime model Makes heavy use of caching and lazy loading to improve runtime performance

41© The AspectWerkz Team 2004 Advantages The dynamic runtime model allows addition of advice removal of advice reordering of advice swapping of introduced implementations at runtime with almost zero overhead The dynamic compiler allows us to have the best of both worlds Performance closer to a statically compiled approach The advantage of a dynamic runtime model

42© The AspectWerkz Team 2004 Simple benchmark The overhead of five around advice applied to a method call join point AspectJ ms/call AspectWerkz 0.10 RC ms/call JBoss AOP 1.0Beta ms/call Configuration: Hardware: Intel Pentium 4 Mobile 1.6 MHz JVM: HotSpot 1.4.2_01 OS: Windows XP

43© The AspectWerkz Team 2004 Limitations Hard to match the speed of statically compiled systems (AspectJ etc.) since: We have to keep track of join point state: Need to handle the state management Need to know if a join point is redefined and has become dirty (and the JIT compiled class is stale) Need a level of indirection Can not add new pointcuts to the system without: Reloading of the classes Inserting traps at all potential points in the system Runtime weaving is needed

44© The AspectWerkz Team 2004 Enterprise application support JLS compatibi lity XML and Attribute definition Load time and Runtime weaving AspectJs join point/ pointcut model Dynamic runtime model Runtime compiler (JIT) Usability & Ease of adoption Integration Tool support Expressivenes s & Orthogonality Performance vs. Dynamicity Enterprise application support Goals Decisions

45© The AspectWerkz Team 2004 Requirements for Enterprise AOP Security Isolation Visibility Runtime management Deployment modules Needs to be handled both: Horizontally – within one single class loader Vertically – following a class loader hierarchy Aspect Container

46© The AspectWerkz Team 2004 Aspect Container We have a problem when multiple dynamic aspect systems are deployed in the same JVM Need a way to allow them to co-exist and interact in a well-defined, organized, layered way A class is transformed according to the definitions of all aspect systems that is visible from its defining class loader Security, visibility and isolation needs to follow the same scheme To be implemented

47© The AspectWerkz Team 2004 Outline I AspectWerkz overview what is AspectWerkz? how does it compare with AspectJ? II Design goals and decisions what are the key issues for commercial AOP? how does AspectWerkz solve them? III Conclusion future, links, questions

48© The AspectWerkz Team 2004 Future work Native JVM support for AOP JRockit JVM 1.5 Java 1.5 support for generics and attributes Weaving based on JVMTI Metadata driven AOP Tool support Aspect Container

49© The AspectWerkz Team 2004 Where can I find more information? Documentation Technical papers daw-aspectwerkz.pdf daw-aspectwerkz.pdf Articles Weblog articles

50© The AspectWerkz Team 2004 Questions?

51© The AspectWerkz Team 2004 Thanks for listening

52© The AspectWerkz Team 2004 Example of use-cases Very useful in enterprise application environments Weave third party libraries without having post process all the jars For example when advising on an interface, e.g. java.sql.PreparedStatement+.execute() Sometimes the decision to apply an aspect can not be taken at build time but at: Deployment time, perhaps much later and by another person Runtime (runtime diagnostics, profiling, performance optimizations etc.)

53© The AspectWerkz Team 2004 Lessons learned Some extra effort needed to deal with differences in application server implementations (class loading schemes etc.) differences in JVM implementations (IBM JRE) We had problems with thread safety in the transformation process Issues with bugs in bytecode libraries

54© The AspectWerkz Team 2004 Loose coupling using delegation BeforeAdvice1 AfterAdvice1 BeforeAdvice2 AfterAdvice2 perJVM perClass perThread perInstance object.myMethod() caller instance callee instance Join Point public void myMethod() {... }