Aspect oriented refactoring of the apache cocoon shared object resource allocation system
This presentation is the property of its rightful owner.
Sponsored Links
1 / 22

Aspect-Oriented Refactoring of the Apache Cocoon Shared-Object Resource Allocation System PowerPoint PPT Presentation

  • Uploaded on
  • Presentation posted in: General

Aspect-Oriented Refactoring of the Apache Cocoon Shared-Object Resource Allocation System. Jeff Dalton February 28th, 2003 Advisor: David G. Hannay Client: Robert Berry, IBM UK. Arthur Octopus The AspectJ Mascot. Agenda. AOP & Cocoon Background Refactoring Goals & Process

Download Presentation

Aspect-Oriented Refactoring of the Apache Cocoon Shared-Object Resource Allocation System

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript

Aspect oriented refactoring of the apache cocoon shared object resource allocation system

Aspect-Oriented Refactoring of the Apache Cocoon Shared-Object Resource Allocation System

Jeff Dalton

February 28th, 2003

Advisor: David G. Hannay

Client: Robert Berry, IBM UK

Arthur Octopus

The AspectJ Mascot



  • AOP & Cocoon Background

  • Refactoring Goals & Process

  • Challenges and Obstacles

  • The Future

What is aspect oriented programming

What is Aspect Oriented Programming?

  • Concern – “a specific requirement or consideration that must be addressed in order to satisfy the overall system goal.”

  • AOP introduces a new unit of modularization—an aspect–that crosscuts other modules.

  • Aspect = pointcut + advice + intertype declaration

    • intertype declaration

      Fields and methods that the aspect manages on behalf of other types

      - The Java AOP implementation

A cross cutting concern

A Cross-cutting concern

  • Logging in org.Apache.Tomcat

    • Red shows lines of code that handles logging

    • Not in one place. Not in a small number of places.

Apache cocoon dynamic multi channel web publishing

Apache Cocoon:Dynamic multi-channel web publishing

  • “Apache Cocoon is a web development framework built around the concepts of separation of concerns and component-based web development.”

    – Cocoon website

    Usage example:

    • Take data from a database and publish the content onto a web portal in HTML, PDF, Office format, and text format all simultaneously.

Performance as crosscutting concern

Performance as crosscutting concern

  • Performance optimizations: Caching & Pooling

    • Effective techniques to improve performance

  • Caching – recycling of resources that are expensive to create and discard where more than one user can use a single object

    • “Read only”

    • A.K.A. – “Shared Object Resource Allocation”

Cocoon caching architecture

Cocoon Caching Architecture

  • Caching happens at the pipeline level with each different phase of the transformation being cached, if possible.


Cocoon caching architecture1

Cocoon Caching Architecture

  • SAX events and caching management is done in a central location: CacheManager

  • However, to be cached the classes must implement the abstract interface ...cocoon.caching.CacheableProcessingComponent

  • Two methods to be implemented:

    • Serializable generateKey();

    • SourceValdity generateValidity();

Refactoring cocoon caching

Refactoring Cocoon Caching

  • The Challenge:

    • Implementing the CacheableProcessingComponent and its methods is the crosscutting concern, we need to abstract it.

  • Accomplished through

    • Introductions – in AspectJ “Intertype Declarations”

      • The addition of methods, fields, interfaces, or inheritance information that does not directly affect the class’s behavior

  • Simple in concept, not trivial in practice.

    • Large, complex web application (~4600 class files with all blocks)

Aop adoption

AOP Adoption

  • new services, programming model

  • product lines

  • extend J2EE

  • Web services, mobile, P2P...

  • aspect libraries

  • design patterns

  • enterprise, department standards

  • module design

  • persistence

  • management

  • security

  • feature variations

  • limited use

  • design

  • error handling

  • standards & contracts

  • monitoring


  • 15 minutes

  • 30 lines

  • unpluggable

  • testing

  • tracing

  • performance measurement

Development Support forExisting Code


Re-factor CoreFunctionality





Project Task

  • Refactor the caching system in Cocoon


  • Gain experience with application of AOP to a large scale, well structured application environment.

  • Identify and quantify opportunities for using AOP to simplify an already modular code base.

  • Use AOP to enhance modularity/componentization of Cocoon.

  • Process approach

    Process: Approach

    • Used AspectJ to define a compiler warning in order to identify locations in Cocoon that implement the CacheableProcessingComponent abstract interface.

    • Wrote aspects to encapsulate the functionality.

    • Removed the code encapsulated into aspects from the base classes identified in step 1.

    • Wove the aspects into Cocoon using AspectJ compiler.

    Step 1 identify locations

    Step 1: Identify Locations


    declarewarning:staticinitialization(org.apache.cocoon.caching.CacheableProcessingComponent+)&&!within(org.apache.cocoon.caching..*):"Class implements cacheable";


    Step 2 write caching aspects

    Step 2: Write Caching Aspects



    /* Ascii art generator */

    declareparents: org.apache.cocoon.generation.asciiart.AsciiArtSVGGenerator implements CacheableProcessingComponent;

    public Serializable org.apache.cocoon.generation.asciiart.AsciiArtSVGGenerator.generateKey() {



    public SourceValidity org.apache.cocoon.generation.asciiart.AsciiArtSVGGenerator.generateValidity(){


    } ….

    Introduce Interface

    Introduce Methods

    Step 3 4 remove references weave

    Step 3 & 4: Remove References & Weave

    Code Removed

    Testing verification

    Testing & Verification

    • Finished:

      • Cocoon without caching deployed

    • In process

      • Integrating AspectJ Compiler into build process

    Challenges obstacles

    Challenges & Obstacles

    • Domain knowledge is the biggest challenge

      • Ex. Cache (external pipeline cache) vs. Store (Internal Object cache)

    • Eclipse AspectJ Development Tools (1.1.4)

      • Scalability issues: over 4600 classes in Cocoon

      • Bug: Memory Leak (Fix coming in 1.2 – ‘Lancaster’)

      • Bug: Abstract class that extend abstract class with concrete subclasses are woven too early - (Fixed in 1.1.6)

    • Ongoing modifications to cocoon caching system

    Future work

    Future work

    • Use AOP to refactor the ‘internal cache’

    • Refactor other non-performance crosscutting concerns into aspects

      • Object Recycling, Logging, etc…

    • An event-aware AOP caching system

      • Use AOP to catch SAX events and perform cache invalidations

    The future aop

    The Future: AOP

    • New versions, better tools

      • AspectJ 1.2 – “Lancaster” for Eclipse 3.0

      • “Aspect Mining” – Better ways towards aspect discovery

        • Concern Modeling Environment


          • “To general software developers it offers a suite of tools for use in creating, manipulating, and evolving aspect-oriented software, across the full software lifecycle”

          • IBM Watson Lab – Yorktown Heights

        • Aspect Mining Tool

        • More work to be done: AI and pattern recognition

      • AOSD 2004 in Lancaster, UK, March 22-25th

    Results i

    Results I


    • How should you structure your application to simplify AO extendibility?


    • Good coding practice makes AO adoption easier

      • Standard variable naming

      • Standard accessor methods


    • How can we improve the AO implementation?


    • Refactor ‘similar’ code to remove differences


    • How should aspects be viewed on a design level?


    • Still open!

    Results ii

    Results II


    • Abstracted 39 implementations of CacheableProcessingComponent.

    • Used AOP to condense and remove 24 methods from the base implementation.

      Example: Duplicate code:









    AOP: The here, the now, and the future!

    Oliver the Octopus

    Concept and name credited to:

    AspectJ team, IBM Hursley, UK

  • Login