130 likes | 237 Views
AspectJ2EE/Clasa. Israel Institute of Technology The Computer Science department Itay Maman. Talk outline. Our Group Overview of AspectJ2EE Weaving mechanism The Clasa language A generic middleware platform: The vision. Overview of AspectJ2EE.
E N D
AspectJ2EE/Clasa Israel Institute of Technology The Computer Science department Itay Maman
Talk outline • Our Group • Overview of AspectJ2EE • Weaving mechanism • The Clasa language • A generic middleware platform: The vision
Overview of AspectJ2EE • The key issue: Weaving can be achieved via sub-classing • The sub-class will inject the additional code into its super class • Each aspect is actually a type-to-subtype mapping • Hence, aspects in AspectJ2EE are called: Shakeins • Objects must be created through an object factory • (the dynamic type of the object is different from its static type)
AspectJ2EE: What the System Generates (Assumes 4 Applied aspects) Lifecycle management is an aspect
Current focus: Clasa (1/4) Motivation • Describing the characteristic of a class is not an easy task • Example 1- Let’s define a stateless class as a class with no fields. • Can it have static fields? • Can its super class have a private instance field? • Example 2- NoName is a class without a “getName()” method • Can it have a static getName() method? • Can its super class have a private non-static getName() method?
Current focus: Clasa (2/4) Motivation (continued) • There is a major gap between the intuition and the formal definition • This gap must be bridged when: • Statistical analysis is applied over classes • A refactoring tool is developed • A point-cut is defined • … • Current point-cut constructs lack in their expressive power • Thus, they cannot capture the wide spectrum of Java element
Current focus: Clasa (3/4) What is Clasa? • A language over the domain of Java programs • A Jar file can be thought of as a database • A Clasa function can be thought of as a query • Main features • Built-in functions for handling relations • Pattern matching • Elegant syntax • Static, strong typing, with type inference • Implementation is based on ideas drawn from languages such as Icon, Prolog • By using Clasa, one can precisely define complex pointcuts
Current focus: Clasa (4/4) Some Clasa queries has_age := abstract class { public int getAge(); public void setAge(int); } primitive := boolean | char | int | long | float | double; serializeable := primitive | implements: { ‘java.lang.Serializeable‘) non_private_ctor := [public|protected|default] ctor; singleton := class { no non_private_ctor; static T create(); private static T field; }
Generic middleware platform (GMF) 1/4 1st approach • What AspectJ2EE needs? • An infrastructure which provides core J2EE services: • Persistency • Security • Transaction • Logging • … • The protocol should be minimal but complete • No fancy (compound) operations • Just like the APIs provided by an operating system
Generic middleware platform (GMF) 2/4 (1st approach continued) • What AspectJ2EE does not need? • AspectJ2EE’s weaver is based on inheritance • The advice is woven by means of sub-classing • sub-classing is a built-in mechanism of Java • =>No “Aspect awareness”: Neither the GMF nor the JVM need to support aspects • A “nice to have” feature: • GMF will allow client code to customize the type of each created object • Can be thought of as a built-in object factory • Increases POJOness of the code
Generic middleware platform (GMF) 3/4 2nd approach • Let’s think of the GMF abstractly… • Provides a set of built-in aspects • Allows developers to define new aspects • Is implemented by aspects ?! => one aspect-weaving mechanism that is used both internally and externally • Pros • Small, compact core • A Highly customizable GMF • Cons • Bootstrapping • Not specifically related to middleware platforms • Performance
Generic middleware platform (GMF) 4/4 (2nd approach continued) • What is the minimal kernel of such a GMF? • A Pointcut matching engine • “primitive” aspect: Object creation • The type-to-subtype mapping is just a parameter • “primitive” aspect: System configuration change • The bottom line: • A small kernel • A huge library • Almost every thing can be customized