InfoQ

News

Interview: Ramnivas Laddad on AOP Design, Modelling, and Policy Enforcement

Posted by Floyd Marinescu on Apr 17, 2007 11:00 AM

Community
Java
Topics
AOP,
Modeling,
Design
Tags
AspectJ
Ramnivas Laddad talks about domain aspects, how aspects fit in the design phase, how to model aspects in UML, how to enforce policies with Aspects, how he used Aspects to diagnose production problems including touch threading problems, and using aspects to simplify design pattern implementation.

Watch Ramnivas Laddad on AOP Design, Modelling, and Policy Enforcement (21:16 min)

One particular interesting use of Aspects Ramnivas mentions involved enforcing single-threaded use: <blockquote>I will give you an example that was my first serious aspect that really helped me solve some problems. I was working on a Swing based project and used to get some intermittent problems, you suspected that it was some threading related issues. You might be aware that Swing is a single-threaded library, that means you are not supposed to call Swing components from any thread other than dispatcher thread. So we had this problem which showed up only once in a while, and for some reason whenever we gave it to customers that problem would show up for sure. We did a couple reviews, and spotted some points, but not really anything that helped us. So I wrote a small aspect that said: "Make sure that whenever a UI component is updated the caller thread is in the dispatch thread, if it is not then report it". So we compiled our code with this aspect, and just used that code in the jar file for a few days, just normal usage. And at the end of the day we got a lot of output that told us all the places the violation was happening (and the callstacks). So we knew exactly why it happened. And that time if I remember correctly it was AspectJ .8 version. So obviously I did not want to put that code in production, it was not the right thing to do. So I basically implemented the correct code manually so Aspects helped me to enforce the policy of single threaded rule.</blockquote>

See also the considerable amount of content on AOP at: http://infoq.com/aop.

3 comments

Reply

Concrete example of Business aspects by Karthik N Posted Apr 17, 2007 10:19 PM
Re: Concrete example of Business aspects by Rickard Öberg Posted Apr 18, 2007 8:33 AM
Re: Concrete example of Business aspects by Floyd Marinescu Posted Apr 19, 2007 9:06 AM
  1. Back to top

    Concrete example of Business aspects

    Apr 17, 2007 10:19 PM by Karthik N

    Anyone know of any more Elaborate examples of using AOP/Aspectj for business aspects? I know the interview can over only so much in-depth.

  2. Back to top

    Re: Concrete example of Business aspects

    Apr 18, 2007 8:33 AM by Rickard Öberg

    We use AOP for our entire domain model in our app. Currently we have 168 mixins that are used in various combinations in objects, and here are some examples: * ACL * Metadata * User info (matches user, group, container in LDAP) * Parent/child relationships (one for child, one for parent/container) * Icon and displayname (there are lots of different variants of this, for different objects) * File info * Site/Page/Layout/Portlet and other CMS-related mixins * Hit counter (also CMS related) and so on... That was mixins. Then we also have 130+ interceptor style aspects that maintain various domain rules. Many are related to lifecycle management of aggregated objects (e.g. remove aggregated objects when owning object is removed), and many are related to maintaining various rules (e.g. if an object is added to a container, then the child->parent relationship must be properly updated). These interceptors are all specific to some few number of methods in some specific mixin (i.e. they are not widely applicable to many different mixins and methods), but they ARE heavily reused anyway since the mixins are reused in many domain objects. We also sometimes use interceptor aspects to define method parameter validation rules, so that these are not hardcoded in the various methods and mixins.

  3. Back to top

    Re: Concrete example of Business aspects

    Apr 19, 2007 9:06 AM by Floyd Marinescu

    On InfoQ.com's code base Alexandru Popescu used AspectJ to add things like discussion threads and the topic/tag categorization to content items at runtime. It's a nice implementation - domain objects (articles, videos, books) don't need to know about the discussion threads associated with them or how they are categorized, those get added in as introductions afterwards. We can even do some cool things like havin articles and news posts announcing them share the same discussion threads.

Exclusive Content

Typemock: Past, Present and Future

Eli Lopian of Typemock answers a few questions on Typemock origins and where Typemock is headed.

Agile in Practice: What Is Actually Going On Out There?

Scott Ambler talks about actual data resulting from surveys made during 2006-2008, showing how Agile is perceived and implemented within organizations.

Building Smart Windows Applications

From QCon 2008, Daniel Moth presents on using Visual Studio 2008 and .NET 3.5 to create compelling rich Windows applications.

Joshua Kerievsky about Industrial XP

Joshua Kerievsky, founder of Industrial Logic, talks about Industrial Extreme Programming which extends XP by including practices dealing with management, customers and developers.

Jeff Barr Discusses Amazon Web Services

Amazon Web Services (AWS) Evangelist Jeff Barr discusses SimpleDB, S3, EC2, SQS, cloud computing, how different Amazon services interact, origins of AWS, AWS globalization and the March AWS outage.

More Than Just Spin (Up) : Virtualization for the Enterprise and SaaS

Cloud services have helped bring virtualization to the forefront. Its full power however, also includes other benefits such as high availability, disaster recovery, and rapid provisioning.

Ruby Beyond Rails

John Lam talks about his path to dynamic languages, some of the problems of making IronRuby run fast, and how the DLR helps with implementing languages.

VMware Infrastructure 3 Book Excerpt and Author Interview

VMware Infrastructure 3: Advanced Technical Design Guide and Advanced Operations Guide provides a wealth of practical insights into setting up virtualization in todays corporate environments.