modularizing grid middleware concerns with aspectjborja/gw06/dev... · modularizing grid middleware...

34
May 2006 Modularizing Grid Middleware Concerns with AspectJ Thomas Cottenier Dragos Morar Tzilla Elrad

Upload: others

Post on 25-May-2020

7 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Modularizing Grid Middleware Concerns with AspectJborja/gw06/dev... · Modularizing Grid Middleware Concerns with AspectJ Globus Toolkit Aspects in Action How to use AspectJ with

May 2006

Modularizing Grid Middleware Concerns with AspectJ

Thomas CottenierDragos MorarTzilla Elrad

Page 2: Modularizing Grid Middleware Concerns with AspectJborja/gw06/dev... · Modularizing Grid Middleware Concerns with AspectJ Globus Toolkit Aspects in Action How to use AspectJ with

Modularizing Grid Middleware Concerns with AspectJ

Outline

Quick Demo 1 : Tracing container execution in 1 step Aspect-Oriented Software Development Aspect-Oriented Programming – AspectJ5. Demo 2: Globus Toolkit Aspects in Action6. Conclusions

Page 3: Modularizing Grid Middleware Concerns with AspectJborja/gw06/dev... · Modularizing Grid Middleware Concerns with AspectJ Globus Toolkit Aspects in Action How to use AspectJ with

Modularizing Grid Middleware Concerns with AspectJ

Quick Demo 1 : Tracing Container execution in 3 steps

1. Weave Predefined tracing Aspect: util.tracing.Tracing.aj

2. Deploy Woven Library:

3. Run! :

Page 4: Modularizing Grid Middleware Concerns with AspectJborja/gw06/dev... · Modularizing Grid Middleware Concerns with AspectJ Globus Toolkit Aspects in Action How to use AspectJ with

Modularizing Grid Middleware Concerns with AspectJ

Aspect-Oriented Software Development

AOSD is about Modularity

Evolution of Software Design: Monolithic → Modular

Abstraction Focus only on relevant propertiesDecomposition Divide software into separately named and addressable modulesEncapsulation Group related things together.Information Hiding Hide implementation details from the outsideSeparation of Concerns- Ensure that each module only deals with one concern- Low Coupling among the modules- High Cohesion within one module

Page 5: Modularizing Grid Middleware Concerns with AspectJborja/gw06/dev... · Modularizing Grid Middleware Concerns with AspectJ Globus Toolkit Aspects in Action How to use AspectJ with

Socket creation in Tomcat- fits nicely into one package (3 classes)

AOSD - Introduction

Good Modularity

Page 6: Modularizing Grid Middleware Concerns with AspectJborja/gw06/dev... · Modularizing Grid Middleware Concerns with AspectJ Globus Toolkit Aspects in Action How to use AspectJ with

Class Loading in Tomcat- mostly in one package (9 classes)

AOSD - Introduction

Good Modularity

Page 7: Modularizing Grid Middleware Concerns with AspectJborja/gw06/dev... · Modularizing Grid Middleware Concerns with AspectJ Globus Toolkit Aspects in Action How to use AspectJ with

Logging in Tomcat- scattered across the packages and classes

- error handling, security, business rules, …

AOSD - Introduction

Poor Modularity

Page 8: Modularizing Grid Middleware Concerns with AspectJborja/gw06/dev... · Modularizing Grid Middleware Concerns with AspectJ Globus Toolkit Aspects in Action How to use AspectJ with

AOSD – Introduction

Crosscutting Concerns

ScatteringIn a given implementation, the code for a concern is spread out. Single concern affects multiple modules.

TanglingMultiple concerns are interleaved in a single module

Crosscutting ConcernThe inherent structure of the concern can not be modularized in the decomposition mechanism of the language (Objects or procedures), because it follows different composition rules.

Page 9: Modularizing Grid Middleware Concerns with AspectJborja/gw06/dev... · Modularizing Grid Middleware Concerns with AspectJ Globus Toolkit Aspects in Action How to use AspectJ with

CrosscuttingConcerns:Scattering

All service operations

need to retrieve

the resource managed

by the service

Page 10: Modularizing Grid Middleware Concerns with AspectJborja/gw06/dev... · Modularizing Grid Middleware Concerns with AspectJ Globus Toolkit Aspects in Action How to use AspectJ with

CrosscuttingConcerns:Tangling

Initialization of the

Resource Properties

Factory Implementation:

Unique Resource Identifier

Resource Lifecycle

Management

Topic Lists for

Notifications

Base Resource

Functionality

Page 11: Modularizing Grid Middleware Concerns with AspectJborja/gw06/dev... · Modularizing Grid Middleware Concerns with AspectJ Globus Toolkit Aspects in Action How to use AspectJ with

CrosscuttingConcerns:Tangling

Initialization of the

Resource Properties

Factory Implementation:

Unique Resource Identifier

Resource Lifecycle

Management

Topic Lists for

Notifications

Base Resource

Functionality

Page 12: Modularizing Grid Middleware Concerns with AspectJborja/gw06/dev... · Modularizing Grid Middleware Concerns with AspectJ Globus Toolkit Aspects in Action How to use AspectJ with

CrosscuttingConcerns:Tangling

Initialization of the

Resource Properties

Factory Implementation:

Unique Resource Identifier

Resource Lifecycle

Management

Topic Lists for

Notifications

Base Resource

Functionality

Page 13: Modularizing Grid Middleware Concerns with AspectJborja/gw06/dev... · Modularizing Grid Middleware Concerns with AspectJ Globus Toolkit Aspects in Action How to use AspectJ with

Auxiliary concerns are scattered and tangledSynchronization, Real-time constraints, Error-checking, Object interaction constraints, Memory management, Persistency, Security, Caching, Logging, Monitoring, Testing, Domain specific optimization

80% of problems come from this 20% of code– Inflexibility: hard to change/maintain

have to find all the code involved and be sure to change it consistently

– Redundancy: same fragment of code in many placesLeads to inconsistency

– Incomprehensibility: can’t see the forest for the trees

AOSD – Introduction

Crosscutting Concerns

Page 14: Modularizing Grid Middleware Concerns with AspectJborja/gw06/dev... · Modularizing Grid Middleware Concerns with AspectJ Globus Toolkit Aspects in Action How to use AspectJ with

crosscutting is inherent in complex systems crosscutting concerns

– have a clear purpose– have a natural structure

let’s capture the structure of crosscutting concerns explicitly

– in a modular way– with linguistic and tool support

AOSD – Introduction

The AOSD idea

Page 15: Modularizing Grid Middleware Concerns with AspectJborja/gw06/dev... · Modularizing Grid Middleware Concerns with AspectJ Globus Toolkit Aspects in Action How to use AspectJ with

AOSD – Introduction

Aspects

Goal of AOSDEnable the modular (not scattered) implementation of crosscutting concerns.

AspectExplicit abstraction for representing crosscutting concerns

Aspect-Oriented ProgrammingLanguage that provides mechanisms to capture aspects

Aspect WeaverComposition mechanism that coordinates aspects with the rest of the code.

Page 16: Modularizing Grid Middleware Concerns with AspectJborja/gw06/dev... · Modularizing Grid Middleware Concerns with AspectJ Globus Toolkit Aspects in Action How to use AspectJ with

AOSD - Aspect-Oriented Programming

Aspect-Oriented Language Elements

join point (JP) modelcertain principled points in program execution such as method calls, field accesses, and object construction

means of identifying JPspicking out join points of interest (predicate)pointcut: set of join points

means of specifying behavior at JPs what happens advice declarations

pointcut traced(): call(* Line.*) ||

call(* Point.*);

before(): traced() { println(“Entering:” + thisjoinpoint);

}

Page 17: Modularizing Grid Middleware Concerns with AspectJborja/gw06/dev... · Modularizing Grid Middleware Concerns with AspectJ Globus Toolkit Aspects in Action How to use AspectJ with

Aspect-Oriented Programming

Aspect-Oriented Language Elements

Joinpointscertain principled points in program execution such as method calls, field accesses, and object construction

- method execution- method call- field get & set- exception handler execution- static & dynamic initialization- …

:Line end1:Point

moveBy(int, int) moveBy(int, int)

setX(int)

setY(int)

moveBy(int, int)

setX(int)

setY(int)

end2:Point

Page 18: Modularizing Grid Middleware Concerns with AspectJborja/gw06/dev... · Modularizing Grid Middleware Concerns with AspectJ Globus Toolkit Aspects in Action How to use AspectJ with

AOSD – Aspect-Oriented Programming

Aspect-Oriented Language Elements

Pointcuts: Queries over Joinpoints- filters picking out join points- primitive and user-definable - composable with &&, ||, !

pointcut moves(): call(void Line.setP1(Point)) || call(void Line.setP2(Point)) || call(void Point.setX(int)) || call(void Point.setY(int)) || call(void FigureElement.incrXY());

pointcut traced():

call(* Line.*) || call(* Point.*);

Page 19: Modularizing Grid Middleware Concerns with AspectJborja/gw06/dev... · Modularizing Grid Middleware Concerns with AspectJ Globus Toolkit Aspects in Action How to use AspectJ with

Advice- code body attached to a pointcut- code runs at every join point picked out by a pointcut- after advice runs after the computation of a join point

(both returning normally and throwing an exception)

after(): moves() { Display.update();}

AOSD – Aspect-Oriented Programming

Aspect-Oriented Language Elements

before(): (sets(int Point.x)) && !withincode(void Point.setX())) || (sets(int Point.y)) && !withincode(void Point.setY())) { throw new AccessDeniedException();

}

Page 20: Modularizing Grid Middleware Concerns with AspectJborja/gw06/dev... · Modularizing Grid Middleware Concerns with AspectJ Globus Toolkit Aspects in Action How to use AspectJ with

An Aspect is a type that crosscuts other types

aspect MoveCounting {int count = 0;pointcut moves():

...as before ...

after(): moves() && !cflowbelow(moves()) { count++;

}}

AOSD – Aspect-Oriented Programming

Aspect-Oriented Language Elements

Page 21: Modularizing Grid Middleware Concerns with AspectJborja/gw06/dev... · Modularizing Grid Middleware Concerns with AspectJ Globus Toolkit Aspects in Action How to use AspectJ with

AOSD – AOSD for Middleware

E.g.: J2EE without EJB – Lightweight Containers

Lightweight Container :- Manage application code, but does not impose

dependencies on that code (non-invasiveness)- Quick to start up- Does not require special deployment steps for objects- Light footprint and minimal API dependencies- Low deployment effort and performance overhead- Possible to deploy fine-grained objects

Inversion of Control : avoid having application code depending on a container

Aspects can encapsulate the dependencies on the Container

Page 22: Modularizing Grid Middleware Concerns with AspectJborja/gw06/dev... · Modularizing Grid Middleware Concerns with AspectJ Globus Toolkit Aspects in Action How to use AspectJ with

MathService

add(Integer)substract (Integer)

<<interface >>

Resource

MathResourcevalue:Integer

getValue():IntegersetValue(Integer)getLastOp():String

lastOp:String

setLastOp (String)

<<interface >>

ResourceProperties

<<interface >>

MathQNames

<<interface >>

ResourceHome

ResourceContextImpl

ResourceContext

<<interface >>

ResourceProperty

MathResourceHome

MathFactoryService

<<interface >>

ResourceIdentifier

getID():Object

ResourceHomeImpl

<<interface >>

ResourceKey

SimpleResourceKey

<<interface >>

ResourceLifeTime

<<interface >>

TopicListAccessor

<<interface >>

ResourcePropertySet

SimpleResourceProperty

SimpleResourcePropertySet

<<interface >>

TopicList

SimpleTopicList

propSet

topicList <<interface >>

ResourcePropertyMetaData

SimpleResourcePropertyMetaData

::java::util::Calendar

terminationTime

::java::lang::Object

key

Page 23: Modularizing Grid Middleware Concerns with AspectJborja/gw06/dev... · Modularizing Grid Middleware Concerns with AspectJ Globus Toolkit Aspects in Action How to use AspectJ with

MathService

add(Integer)substract(Integer)

<<interface >>

Resource

MathResource

value:IntegerlastOp:String

getValue():IntegersetValue(Integer)getLastOp():StringsetLastOp(String)

<<interface >>

ResourceProperties

<<interface >>

MathQNames

<<interface >>

ResourceHome

ResourceContextImpl

ResourceContext

<<interface >>

ResourceProperty

MathResourceHome

MathFactoryService

ResourceHomeImpl

<<interface >>

ResourceKey

SimpleResourceKey

<<interface >>

ResourcePropertySet

SimpleResourceProperty

SimpleResourcePropertySet

propSet

<<Aspect>>

ResourcePropertyAspect

<<Aspect>>

MathResourcePropertyAspect

qNameInstanceCreated

resourceInit

getResource

Resource Properties

Page 24: Modularizing Grid Middleware Concerns with AspectJborja/gw06/dev... · Modularizing Grid Middleware Concerns with AspectJ Globus Toolkit Aspects in Action How to use AspectJ with

LyfeCycle Management

MathService

add(Integer)substract(Integer)

MathResource

value:IntegerlastOp:String

getValue():IntegersetValue(Integer)getLastOp():StringsetLastOp(String)

MathResourceHomeMathQNames

interface

ResourceHome

SimpleResourceKey

interface

ResourceKey

MathFactoryService

ResourceHomeImplResourceContextImpl

ResourceContext

resourceInit()

ReflectionResourceProperty

MathLyfeCycleAspect

<< interface >>

ResourcePropertyMetaData

SimpleResourcePropertyMetaData

::java::util::Calendar <<interface >>

ResourceLifeTime

LyfeCycleAspect

<<aspect>>

<<aspect>>

terminationTime

Page 25: Modularizing Grid Middleware Concerns with AspectJborja/gw06/dev... · Modularizing Grid Middleware Concerns with AspectJ Globus Toolkit Aspects in Action How to use AspectJ with

+ Notifications

MathService

add(Integer)substract(Integer)

MathResource

value:IntegerlastOp:String

getValue():IntegersetValue(Integer)getLastOp():StringsetLastOp(String)

MathQNamesMathFactoryService

MathResourceHome

interface

ResourceHome

SimpleResourceKey

interface

ResourceKey

ResourceHomeImplResourceContextImpl

ResourceContext

initializeTopicList()

addToTopicList()

MathLyfeCycleAspect

<< interface>>

ResourcePropertyMetaData

SimpleResourcePropertyMetaData

::java::util::Calendar

<<interface

ResourceLifeTime

LyfeCycleAspect

<<aspect>>

<<aspect>>

MathNotificationsAspect<<aspect>>

NotificationsAspect<<aspect>>

<< Interface>>

TopicListAccessor

interface

TopicList

SimpleTopicList

topicList>>

Page 26: Modularizing Grid Middleware Concerns with AspectJborja/gw06/dev... · Modularizing Grid Middleware Concerns with AspectJ Globus Toolkit Aspects in Action How to use AspectJ with

Modularizing Grid Middleware Concerns with AspectJ

Globus Toolkit Aspects in Action

Page 27: Modularizing Grid Middleware Concerns with AspectJborja/gw06/dev... · Modularizing Grid Middleware Concerns with AspectJ Globus Toolkit Aspects in Action How to use AspectJ with

Modularizing Grid Middleware Concerns with AspectJ

Globus Toolkit Aspects in Action

Page 28: Modularizing Grid Middleware Concerns with AspectJborja/gw06/dev... · Modularizing Grid Middleware Concerns with AspectJ Globus Toolkit Aspects in Action How to use AspectJ with

Modularizing Grid Middleware Concerns with AspectJ

Globus Toolkit Aspects in ActionGeneric Resource Management

Aspect for Singleton Resources:

Reusable as-is, without any modification

Page 29: Modularizing Grid Middleware Concerns with AspectJborja/gw06/dev... · Modularizing Grid Middleware Concerns with AspectJ Globus Toolkit Aspects in Action How to use AspectJ with

Modularizing Grid Middleware Concerns with AspectJ

Globus Toolkit Aspects in Action

Generic Resource Management

Aspect for Singleton Resources:

Instantiation for a particular service and resource:

Page 30: Modularizing Grid Middleware Concerns with AspectJborja/gw06/dev... · Modularizing Grid Middleware Concerns with AspectJ Globus Toolkit Aspects in Action How to use AspectJ with

Modularizing Grid Middleware Concerns with AspectJ

Globus Toolkit Aspects in ActionGeneric Resource Management

Aspect for Factory Resources:

Reusable as-is, without any modification

Page 31: Modularizing Grid Middleware Concerns with AspectJborja/gw06/dev... · Modularizing Grid Middleware Concerns with AspectJ Globus Toolkit Aspects in Action How to use AspectJ with

Modularizing Grid Middleware Concerns with AspectJ

Globus Toolkit Aspects in Action

Generic Resource Management

Aspect for Factory Resources:

Instantiation for a particular service and resource:

Page 32: Modularizing Grid Middleware Concerns with AspectJborja/gw06/dev... · Modularizing Grid Middleware Concerns with AspectJ Globus Toolkit Aspects in Action How to use AspectJ with

Modularizing Grid Middleware Concerns with AspectJ

Globus Toolkit Aspects in Action

How to use AspectJ with the Programmer’s tutorial:

2. In the Build.xml file, comment out the ‘compile’ task. We will compile files manually

3. Build the Stubs for the Service using globus-build-service.sh

4. Compile the service files with the AspectJ compiler and copy the class files to the build directory

9. Build the gar archive by running globus-build-service.sh again

10. Deploy the service and run

Page 33: Modularizing Grid Middleware Concerns with AspectJborja/gw06/dev... · Modularizing Grid Middleware Concerns with AspectJ Globus Toolkit Aspects in Action How to use AspectJ with

Modularizing Grid Middleware Concerns with AspectJ

Globus Toolkit Aspects in Action

Page 34: Modularizing Grid Middleware Concerns with AspectJborja/gw06/dev... · Modularizing Grid Middleware Concerns with AspectJ Globus Toolkit Aspects in Action How to use AspectJ with

Thank You

Questions?