Aspects in the Real World Applying AOSD techniques in large systems.

Slides:



Advertisements
Similar presentations
© 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.
Advertisements

AspectWerkz 2 - and the road to AspectJ 5 Jonas Bonér Senior Software Engineer BEA Systems.
Aspect Oriented Programming. AOP Contents 1 Overview 2 Terminology 3 The Problem 4 The Solution 4 Join point models 5 Implementation 6 Terminology Review.
ASTA Aspect Software Testing Assistant Juha Gustafsson, Juha Taina, Jukka Viljamaa University of Helsinki.
1 JAC : Aspect Oriented Programming in Java An article review by Yuval Nir and Limor Lahiani.
Overview of AspectJ Aspect Oriented Software Development Seminar Technion presented by Oren Mishali.
Aspect-Oriented Programming In Eclipse ® Aspect-Oriented Programming in Eclipse with AspectJ Dr Helen Hawkins and Sian January.
Component Patterns – Architecture and Applications with EJB copyright © 2001, MATHEMA AG Component Patterns Architecture and Applications with EJB JavaForum.
Review Amit Shabtay. March 3rd, 2004 Object Oriented Design Course 2 Review What have we done during the course? Where to learn more? What is for the.
ASPECT ORIENTED SOFTWARE DEVELOPMENT Prepared By: Ebru Doğan.
University of British Columbia Software Practices Lab CAS Seminar 06 Fluid AJ - A Simple Fluid AOP Tool Terry Hon Gregor Kiczales.
II. Middleware for Distributed Systems
A Framework for Smart Proxies and Interceptors in RMI Nuno Santos P. Marques, L. Silva CISUC, University of Coimbra, Portugal
Introducing JavaBeans Identify the features of a JavaBean Create and add a bean to an application Manipulate bean properties using accessor and mutator.
Introduction to AOP.
SWE 316: Software Design and Architecture – Dr. Khalid Aljasser Objectives Lecture 11 : Frameworks SWE 316: Software Design and Architecture  To understand.
Introduction to Aspect Oriented Programming Presented By: Kotaiah Choudary. Ravipati M.Tech IInd Year. School of Info. Tech.
Aspect Oriented Programming (AOP) in.NET Brent Krueger 12/20/13.
Spring core v3.x Prepared by: Nhan Le. History v3.0 Spring Expression Language Java based bean metadata v3.1 Cache Abstraction Bean Definition Profile.
© 2006 IBM Corporation IBM WebSphere Portlet Factory Architecture.
Aspect Oriented Programming Razieh Asadi University of Science & Technology Mazandran Babol Aspect Component Based Software Engineering (ACBSE)
Supporting Heterogeneous Users in Collaborative Virtual Environments using AOP CoopIS 2001 September 5-7, Trento, Italy M. Pinto, M. Amor, L. Fuentes,
Aspect Oriented Programming Scott Nykl CSSE 411 Senior Seminar.
SAMANVITHA RAMAYANAM 18 TH FEBRUARY 2010 CPE 691 LAYERED APPLICATION.
SOFTWARE DESIGN AND ARCHITECTURE LECTURE 09. Review Introduction to architectural styles Distributed architectures – Client Server Architecture – Multi-tier.
Composing Adaptive Software Authors Philip K. McKinley, Seyed Masoud Sadjadi, Eric P. Kasten, Betty H.C. Cheng Presented by Ana Rodriguez June 21, 2006.
Modularizing Web Services Management with AOP María Agustina Cibrán, Bart Verheecke { Maria.Cibran, System and Software Engineering.
Hyper/J and Concern Manipulation Environment. The need for AOSD tools and development environment AOSD requires a variety of tools Life cycle – support.
Aspect Oriented Programming Sumathie Sundaresan CS590 :: Summer 2007 June 30, 2007.
Aspect-Oriented Refactoring of the Apache Cocoon Shared-Object Resource Allocation System Jeff Dalton February 28th, 2003 Advisor: David G. Hannay Client:
Aspect Oriented Programming Gülşah KARADUMAN.
Joel Phinney March 31, ◦ Concerns  Separation of Concerns, Tangled and Scattered Concerns, Cross-Cutting Concerns, Aspects ◦ Aspect-Oriented Software.
Methodology: The AOP Refactoring Process Aspect-Oriented Refactoring of the Apache Cocoon Shared-Object Resource Allocation System Jeff Dalton Advisor:
A Distributed Aspect-Oriented System for J2EE Applications Muga Nishizawa and Shigeru Chiba (Tokyo Institute of Technology, Japan) Background - As benefits.
Plug-In Architecture Pattern. Problem The functionality of a system needs to be extended after the software is shipped The set of possible post-shipment.
A Presentation By V AIBHAV S AHARAN Web-enHanced Information Management COMS E6125.
AOP-1 Aspect Oriented Programming. AOP-2 Aspects of AOP and Related Tools Limitation of OO Separation of Concerns Aspect Oriented programming AspectJ.
Chapter 8 Object Design Reuse and Patterns. Object Design Object design is the process of adding details to the requirements analysis and making implementation.
Virtual Support for Dynamic Join Points C. Bockisch, M. Haupt, M. Mezini, K. Ostermann Presented by Itai Sharon
1 An Aspect-Oriented Implementation Method Sérgio Soares CIn – UFPE Orientador: Paulo Borba.
Distribution and components. 2 What is the problem? Enterprise computing is Large scale & complex: It supports large scale and complex organisations Spanning.
IDENTIFYING SEMANTIC DIFFERENCES IN ASPECTJ PROGRAMS Martin Görg and Jianjun Zhao Computer Science Department, Shanghai Jiao Tong University.
Inter-Type Declarations in AspectJ Awais Rashid Steffen Zschaler © Awais Rashid, Steffen Zschaler 2009.
AspectJ – AOP for Java Tom Janofsky. Instructor at Penn State Abington Consultant with Chariot Solutions JUG Member.
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University IWPSE 2003 Program.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 JSP Application Models.
Aspect Oriented Programming Adlux Consultancy Services Pvt Ltd
Kansas City Java User’s Group Jason W. Bedell July 12, 2006
问题 Code scattering Blocks of duplicated code Blocks of complementary code, and different modules implementing complementary parts of the concern Code.
Comparison of Different AOP Approaches Presented by: Xiaojing Wang.
aspectj tools new and noteworthy Mik Kersten University of British Columbia Adrian Colyer IBM Hursley OOPSLA, October
AOSD'04, Lancaster, UK 1 Remote Pointcut - A Language Construct for Distributed AOP Muga Nishizawa (Tokyo Tech) Shigeru Chiba (Tokyo Tech) Michiaki Tatsubori.
Text TCS INTERNAL Oracle PL/SQL – Introduction. TCS INTERNAL PL SQL Introduction PLSQL means Procedural Language extension of SQL. PLSQL is a database.
Aspect-Oriented Software Development (AOSD)
Plug-In Architecture Pattern. Problem The functionality of a system needs to be extended after the software is shipped The set of possible post-shipment.
L’origine dei mali: le dipendenze tra componenti Stefano Leli 14° Workshop DotNetMarche Venerdì 16 aprile
PPL 2004, Gamagori, AICHI1 Remote Pointcut - A Language Construct for Distributed AOP Muga Nishizawa (Tokyo Tech, Japan) Shigeru Chiba (Tokyo Tech, Japan)
What are the key issues for commercial AOP use
Software Engineering Lecture 7
Chengyu Sun California State University, Los Angeles
Aspect-Oriented Programming with the Eclipse AspectJ plug-in
Aspect-Oriented Programming
Inventory of Distributed Computing Concepts
Service Oriented Architecture (SOA)
Structuring Adaptive Applications using AspectJ and AOM
SAMANVITHA RAMAYANAM 18TH FEBRUARY 2010 CPE 691
CS520 Web Programming Spring – Aspect Oriented Programming
Aspect Oriented Software Design
Plug-In Architecture Pattern
Presentation transcript:

Aspects in the Real World Applying AOSD techniques in large systems

Overview AspectJ Case Studies  IBM Websphere Introduction to AspectWerkz Issues for commercial adoption Discussion  What are the best/worst uses of AOP?  Is there a killer tool (or enhancement) still needed?  Advantages of AspectJ vs. HyperJ (Homogeneous vs. Heterogeneous concerns)

Case Studies IBM Websphere  Using AOP to solve middleware complexity issues Applying policies across product line Enabling optional features Efficient refactoring Other Studies  QuO – Programming QoS adaptive applications  COMQUAD

Homogeneous Crosscutting Concerns Homogeneous Concern applies consistent policy across code Tracing and Logging  Aspects are useful when dividing responsibility (component developers need not worry about implementing orthogonal policies in their code) Monitoring and Statistics Error Capturing  Catch ‘throws’ join point

Aspect-driven homogeneous policies Intuitively it seems that Aspects are well- suited to implementing tasks such as logging Question: is it worth re-engineering systems? IBM did some analysis of non-AO code  Admin component of Websphere 355 errors found (missing trace points, 33% of FFDC entries incorrect  Runtime component of Websphere Missing trace points, 17% of FFDC entries incorrect

Heterogeneous Crosscutting Concerns Heterogeneous concern impacts multiple places yet exhibits different behavior in each place Using aspects to perform efficient refactoring  Separate a feature of the system (EJB Support)  Goal: Create a refactored system that can build with or without EJBs  Problem: Large code base with many hard to find hooks into EJB code

Refactoring Process Concern Modelling Visualization Concern-based queries Refactoring (AO & OO) Analyze Query Report Refactor Component Alter EJB Support pointcut definition Run Query

Refactoring – Searching for Links public aspect EJBSupportSeparation { pointcut inEjbSupport() { within(T1) || within(T2) ||...; } pointcut ejbSupportLink() { call(* T1.*(..)) || call(* T2.*(..)) ||...; } declare warning : ejbSupportLink() && !inEjbSupport() : "Link to EJB Support found."; }

public class Account { private int _accountNumber; private float _balance; public Account(int accountNumber) { _accountNumber = accountNumber; } public int getAccountNumber() { AccessController.checkPermission( new BankingPermission("accountOperation")); return _accountNumber; } public void credit(float amount) { AccessController.checkPermission( new BankingPermission("accountOperation")); _balance = _balance + amount; } … Sample Refactoring – Bank Account

Add empty aspect/pointcut private static aspect PermissionCheckAspect { private pointcut permissionCheckedExecution() : (execution(public int Account.getAccountNumber()) || execution(public void Account.credit(float))) && within(Account); before() : permissionCheckedExecution() { }

Sample Refactoring – Bank Account Add crosscutting functionality (+ Warning) // optional declare warning: call(void AccessController.checkPermission(java.security.Permission)) && within(Account) && !within(PermissionCheckAspect) : "Do not call AccessController.checkPermission(..) from Account"; // end optional private pointcut permissionCheckedExecution() : (execution(public int Account.getAccountNumber()) || execution(public void Account.credit(float))) && within(Account); before() : permissionCheckedExecution() { AccessController.checkPermission( new BankingPermission("accountOperation")); }

Sample Refactoring – Bank Account public class Account { private int _accountNumber; private float _balance; public Account(int accountNumber) { _accountNumber = accountNumber; } public int getAccountNumber() { return _accountNumber; } public void credit(float amount) { _balance = _balance + amount; } private static aspect PermissionCheckAspect { private pointcut permissionCheckedExecution() : (execution(public * Account.*(..)) && !execution(String Account.toString())) && within(Account); before() : permissionCheckedExecution() { AccessController.checkPermission( new BankingPermission("accountOperation")); }

Results AspectJ compiler worked with over 20,000 source files  10.5% faster than javac with no aspects  30-50% increase in compilation with aspects (rest of build time unaffected) Queries are efficient when using CME Case for Test Driven Development?

Peculiarities of AO Refactoring Approach towards crosscutting functionality  Prototype conventional solution first? Applicability of aspect's crosscutting  Limiting the scope of the aspects Coupling consideration  Minimize coupling between classes and aspects not as important Placement of aspects  Keep aspects closer to targets (even nested)

AspectWerkz Dynamic AOP framework for Java Tailored for real world JLS compatible Definition syntax in XML and/or Attributes Load time, runtime and static weaving Allows redefinition of aspects at runtime

AspectJ Example 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; }

AspectWerkz Example 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; }

XML Definition syntax <aspect class="samples.AsynchAspect" deployment-model="perJVM"> <pointcut name="executePoint“ expression="execution(void foo.bar.Baz.*(..))“/> <advice name="execute" type="around" bind-to=“executePoint"/>

Issues for commercial adoption As proposed by BEA Systems Usability Agility Integration Expressiveness Performance Tool Support Aspect Container

Usability JLS Compatibility Stays out of the way  Developer can code just as usual in favorite IDE.  No immediate needs for custom plugins and specific tool support. Attribute definition  Self-defined and self-contained aspects  Easier to build reusable aspect libraries XML definition  Allows loose coupling between advice and pointcuts

Integration How to weave the aspects? AW uses JVM-wide hook mechanism to control all class loading (load-time weaving)  Easier to work with application servers  Weaving is platform/vendor independent AW also does runtime weaving  Uses two-phase weaving (to prepare classes)  Multi-weaving. Classes can be woven, rewoven or unwoven at any point Slower startup time (scales poorly with large codebase and freely defined pointcuts)

Tool Support AspectWerkz currently lacks good tool support apart from:  Plugin for the Maven build system  Support for debugging aspects within an IDE  JUnit extension Standardization of attributes in JSR-175 will bring many tools for working with metadata

Dynamicity vs. Performance AspectWerkz is designed to have a dynamic runtime model, which means that the user can redefine his aspect system at runtime. To support a dynamic runtime model the framework makes use of delegation and reflection and introduces a level of indirection to allow the aspects and target classes to be loosely coupled. Runtime compiler, which has similarities with JIT compilers in modern JVMs, detects advice chains that are often executed and creates a custom class on the fly that invokes the advice chain and the target method statically. AspectWerkz makes heavy use of caching and lazy loading to improve the runtime performance

Discussion Best mechanism for weaving aspects Aspects as language extension or pure Best place to use aspects? AOP refactoring Test-Driven Development via AOP Need for AOP patterns

Addendum – AspectJ Design Patterns

QuO toolkit The QuO Toolkit provides support for building systems with adaptive QoS Four main entities in the QuO model  Contracts: used to define adaptation policy  System Condition Objects: used to monitor the environment  Callbacks: used for middleware, system, and out-of-band application adaptation  Delegates: used for in-band application adaptation

Quality of Service issues in Distributed Applications Remote invocations  Can take longer than local calls  Might fail when local call doesn’t  Might expose security issues Impact of these factors varies during runtime due to environment Impact of the distributed application on the environment (changing operational mode)

Handling QoS Initial idea: modify code to examine situation and act accordingly  Violates distributed object model  Affects application code in many places Providing QoS management and control features in the system  Only partially successful since each application has specific QoS needs

QoS as an Aspect Build QoS management as an aspect and weave the result between application and middleware  aspect code has access to application-specific, middleware, and system information and controls without having to modify either the application logic or the underlying distribution middleware

QuO Aspect Model Delegates  Compile aspect into delegate which acts as proxy for calls to remote object and adds desired behavior to invocation Advice Model  applied to a particular method of a particular interface as specified in CORBA IDL  Join points METHODENTRY, PREMETHODCONTRACTEVAL, METHODCALL, POSTMETHODCONTRACTEVAL, METHODRETURN  Advice BEFORE, AFTER, INPLACEOF, ONEXCEPTION

QuO Example Document Server // Document Server IDL module Document { typedef string Query; typedef string DocumentData; typedef sequence Image; interface Server { DocumentData get_document(in Query q); Image get_image(in Query q); ); QoS Strategy  Operate Normally OR Compress images OR Give up

QuO Example Aspect behavior CompressImage () { qosket CompressImageDelegateQosket qk; ivar onserver quo::ValueSC allow compression; Document::Image Document::Server::get_image(in Document::Query q) { return value Document::Image rval; inplaceof PREMETHODCONTRACTEVAL onclient {} before METHODCALL onclient { q = qk.add_alloweompression{q); } after METHODENTRY onserver { allow_compression.booleanValue(qk.get_allow_compression(q)); ) after POSTMETHODCONTRACTEVAL onserver { region NetworkLoad { region CriticalLoad { throw CORBA::NORESOURCES; } region Compress { rval = qk.compress_image(rval); } region NoCompress { throw CORBA::NO_RESOURCES; )

Concern Manipulation Environment Tools to support usage of AOSD throughout software lifecycle  Concern Composition Component Composes/weaves different concerns in any of the supported artifact languages supported by the CME.  Concern Manager Models software in terms of arbitrary concerns and their interrelationships.  Concern Assembler Toolkit  Concern Informant Toolkit  Pattern Underlying Matcher