Applying Aspect-Oriented Software Development to Middleware Frameworks

Ph.D. Thesis, The Technion -- Israel Institute of Technology(2007)

Abstract

This work presents a suite of related programming constructs and technologies aimed at integrating aspect-oriented programming (AOP) in the middleware frameworks used for enterprise application development. These constructs include shakeins (and the AspectJ2EE language design based on it), JTL (the Java Tools Language), factories, and object evolution. Shakeins are a novel programming construct which, like mixins and generic classes, generates new classes from existing ones in a universal, uniform, and automatic manner: Given a class, a shakein generates a new class which has the same type as the original, but with different data and code implementation. This thesis argues that shakeins are restricted, yet less chaotic, aspects. It further claims that shakeins are well suited for the introduction of AOP into existing middleware applications. To demonstrate the applicability of shakeins to the middleware framework domain, we introduce the AspectJ2EE language which, with the help of shakeins and a new deploy-time weaving mechanism, brings the blessings of AOP to the enterprise Java (J2EE) framework. A unique advantage of AspectJ2EE, which is less general (and hence less complicated) than AspectJ, is that it can be smoothly integrated into J2EE implementations without breaking their architecture. Any aspect-oriented language or framework must provide developers with a mechanism for specifying a set of join points, i.e., program locations that should be modified by relevant aspects. Such “pointcut” specifications are commonly expressed using queries written in a dedicated, declarative language. We present JTL, the Java Tools Language, as a new query language. JTL provides a rich and powerful query-by-example mechanism which minimizes the abstraction gap between queries and the program elements they match. We further show how JTL can be extended to support program transformations, going as far as making JTL an AOP language in its own right. Factories are presented as a new mechanism for controlling object instantiation, overcoming anomalies that can be found in the construction mechanisms of Java, C++, Eiffel and similar object-oriented languages. Factories (not to be confused with the Factory Method or Abstract Factory design patterns) provide classes with a complete control over their instantiation mechanism. In particular, classes can enforce the application of shakeins to all instances, without disturbing existing client code. Finally, we allow shakeins to behave as dynamic aspects, i.e., aspects that can be applied to an object or removed from it at runtime. Because applying a shakein to a class generates a new class, we find that this implies the ability to change an object’s class at runtime—i.e., object reclassification is required. As it turns out, reclassification using shakeins is part of a more general concept, which we call Object Evolution. Object evolution is a restriction of general reclassification by which dynamic changes to an object’s class are monotonic: an object may gain, but never lose, externally-visible properties. We argue that there are many applications of monotonic evolution in practical systems. The monotonicity property makes it easier to maintain static type safety with object evolution than in general object reclassification.

Research Areas