25
Towards Executable Aspect-Oriented UML Models 10th Int. Workshop on Aspect-Oriented Modeling (AOM), 6th Int. Conf. on Aspect-Oriented Software Development (AOSD) March 12th, 2007. Vancouver British Columbia (Canada) Lidia Fuentes and Pablo Sánchez Dpto. Lenguajes y Ciencias de la Computación Universidad de Málaga, (Spain) {lff,pablo }@lcc.uma.es

Towards Executable Aspect-Oriented UML Models 10th Int. Workshop on Aspect-Oriented Modeling (AOM), 6th Int. Conf. on Aspect-Oriented Software Development

Embed Size (px)

Citation preview

Page 1: Towards Executable Aspect-Oriented UML Models 10th Int. Workshop on Aspect-Oriented Modeling (AOM), 6th Int. Conf. on Aspect-Oriented Software Development

Towards Executable Aspect-Oriented UML Models

10th Int. Workshop on Aspect-Oriented Modeling (AOM),6th Int. Conf. on Aspect-Oriented Software Development (AOSD)

March 12th, 2007. Vancouver British Columbia (Canada)

Lidia Fuentes and Pablo SánchezDpto. Lenguajes y Ciencias de la Computación

Universidad de Málaga, (Spain){lff,pablo}@lcc.uma.es

Page 2: Towards Executable Aspect-Oriented UML Models 10th Int. Workshop on Aspect-Oriented Modeling (AOM), 6th Int. Conf. on Aspect-Oriented Software Development

AOSD for improving modularization

I would like to separate my crosscutting concerns

Page 3: Towards Executable Aspect-Oriented UML Models 10th Int. Workshop on Aspect-Oriented Modeling (AOM), 6th Int. Conf. on Aspect-Oriented Software Development

AOSD for improving modularization

I would like to separate my crosscutting concerns

AOSD !!

!!

Page 4: Towards Executable Aspect-Oriented UML Models 10th Int. Workshop on Aspect-Oriented Modeling (AOM), 6th Int. Conf. on Aspect-Oriented Software Development

Reasoning about AO Models

Base ModelsBase Models

Page 5: Towards Executable Aspect-Oriented UML Models 10th Int. Workshop on Aspect-Oriented Modeling (AOM), 6th Int. Conf. on Aspect-Oriented Software Development

Reasoning about AO Models

Base ModelsBase Models

Aspect ModelsAspect Models

Page 6: Towards Executable Aspect-Oriented UML Models 10th Int. Workshop on Aspect-Oriented Modeling (AOM), 6th Int. Conf. on Aspect-Oriented Software Development

Reasoning about AO Models

Base ModelsBase Models

Aspect ModelsAspect Models

Pointcut ModelsPointcut Models

{hook=BEFORE_SEND}

*:* Bank

pay(..)

Page 7: Towards Executable Aspect-Oriented UML Models 10th Int. Workshop on Aspect-Oriented Modeling (AOM), 6th Int. Conf. on Aspect-Oriented Software Development

Reasoning about AO Models

Base ModelsBase Models

Aspect ModelsAspect Models

Pointcut ModelsPointcut Models

{hook=BEFORE_SEND}

*:* Bank

pay(..)

?

Page 8: Towards Executable Aspect-Oriented UML Models 10th Int. Workshop on Aspect-Oriented Modeling (AOM), 6th Int. Conf. on Aspect-Oriented Software Development

Simple solution

• If I want to know what my model does, the quickest way is to execute it.

• UML models can be executed (UML Action Semantics).

• There are tools that execute UML models (e.g. Telelogic Rhapsody, KC iUML).

Page 9: Towards Executable Aspect-Oriented UML Models 10th Int. Workshop on Aspect-Oriented Modeling (AOM), 6th Int. Conf. on Aspect-Oriented Software Development

Simple solution

• If I want to know what my model does, the quickest way is to execute it.

• UML models can be executed (UML Action Semantics).

• There are tools that execute UML models (e.g. Telelogic Rhapsody, KC iUML).

Page 10: Towards Executable Aspect-Oriented UML Models 10th Int. Workshop on Aspect-Oriented Modeling (AOM), 6th Int. Conf. on Aspect-Oriented Software Development

XMI

Simple solution

• If I want to know what my model does, the quickest way is to execute it.

• UML models can be executed (UML Action Semantics).

• There are tools that execute UML models (e.g. Telelogic Rhapsody, KC iUML).

XMI

Base ModelsBase Models Aspect Models

Aspect ModelsPointcut Models

Pointcut Models

{hook=BEFORE_SEND}

*:* Bankpay(..)

XMI

WeaverWeaver

Woven ModelsWoven Models

Page 11: Towards Executable Aspect-Oriented UML Models 10th Int. Workshop on Aspect-Oriented Modeling (AOM), 6th Int. Conf. on Aspect-Oriented Software Development

The Online Book Store System

• The Online Book Store has to provide a way for customers to place orders for books.

• A customer will start a new order by selecting a book and specifying the required quantity.

• The customer can continue adding more books to the order.• Once the customer is satisfied with his/her selections, the order goes to the

check out stage. • Each time a new book is added to the order, the order must be persisted. • Persistence is a crosscutting concern !! => AO modeling

Page 12: Towards Executable Aspect-Oriented UML Models 10th Int. Workshop on Aspect-Oriented Modeling (AOM), 6th Int. Conf. on Aspect-Oriented Software Development

Base model (plain Executable UML)

OBS System<< component >> Delivery

<< component >>

CreditCard<< component >>

Network

(1) Decompose the system into a set of interconnected components

Page 13: Towards Executable Aspect-Oriented UML Models 10th Int. Workshop on Aspect-Oriented Modeling (AOM), 6th Int. Conf. on Aspect-Oriented Software Development

Base model (plain Executable UML)

(2) Model internals of each component (OBS System in the figure)

ShoppingCart

+addItem( book : Book, quantity : int )+removeItem( book : Book )+checkOut()

Customer

-name : String-creditCard : String

+getCreditCard() : String

Book

-author : String-title : StringClerk

+packOrder()

System

+register()+unregister()

1..*

0..*

1..*

SelectedProduct

-quantity : Integer

-books

Page 14: Towards Executable Aspect-Oriented UML Models 10th Int. Workshop on Aspect-Oriented Modeling (AOM), 6th Int. Conf. on Aspect-Oriented Software Development

Base model (plain Executable UML)

(3) Construct a state machine by each class (ShoppingCart in the figure)

ItemsAdded

addItem( book : Book, quantity : int ) / UpdateItems

WaitingForCreditConfirmation

Empty

WaitingForDeliveryConfirmation

addItem( book : Book, quantity : int ) / UpdateItems

[else] / notifyProblem [creditOk=true & deliveryOk=true] / sendOk

checkOut() / doCheckOut

Behaviors are associated to transition events => modeled as activity diagrams

Page 15: Towards Executable Aspect-Oriented UML Models 10th Int. Workshop on Aspect-Oriented Modeling (AOM), 6th Int. Conf. on Aspect-Oriented Software Development

Base model (plain Executable UML)

(3) Specify each behavior (UpdateItems in the diagram) using activity diagrams and actions

This does not have Persistence.

<<WriteStructuralFeature>>

Quantity

valuebook

<<ReadSelf>>

ThisShoppingCart

SelectedProduct<<CreateLinkObject>>

book

cart

quantity : intbook : BookShoppingCart

+addItem( book : Book, quantity : int )+removeItem( book : Book )+checkOut()

Customer

-name : String-creditCard : String

+getCreditCard() : String

Book

-author : String-title : StringClerk

+packOrder()

System

+register()+unregister()

1..*

0..*

1..*

SelectedProduct

-quantity : Integer

-books

Page 16: Towards Executable Aspect-Oriented UML Models 10th Int. Workshop on Aspect-Oriented Modeling (AOM), 6th Int. Conf. on Aspect-Oriented Software Development

Aspect model (AOEM Profile)

Joinpoint model

(1) Object creation and destruction; (2) The sending and reception of a message/method; (3) The throwing of an event; (4) The raising of an exception.

Suitable for being used with black-box components, services or legacy systems

Page 17: Towards Executable Aspect-Oriented UML Models 10th Int. Workshop on Aspect-Oriented Modeling (AOM), 6th Int. Conf. on Aspect-Oriented Software Development

Aspect model (AOEM Profile)

Persistence<<aspect>>

<<advice>>+persist()

<<component>>

PersistentIPersistence

(1) We create the Persistence aspect.

Page 18: Towards Executable Aspect-Oriented UML Models 10th Int. Workshop on Aspect-Oriented Modeling (AOM), 6th Int. Conf. on Aspect-Oriented Software Development

Aspect model (AOEM Profile)

(2) We specify the advice behaviour.

<<GetTarget>>

GetSettedComp

<<Literal>>

"Persistent"

<<CallBehavior>>

GetReference<<CallBehavior>>

persist

object

target

GetSource Returns a reference to the source of the intercepted message

GetTarget Returns a reference to the target of the intercepted message

Proceed Executes the intercepted behavior

GetArg(n) Returns the n-argument of the intercepted message

GetMessName Returns the name of the intercepted message

Page 19: Towards Executable Aspect-Oriented UML Models 10th Int. Workshop on Aspect-Oriented Modeling (AOM), 6th Int. Conf. on Aspect-Oriented Software Development

Aspect model (AOEM Profile)

(3) We model the pointcuts.

add*(..)

<<pointcut>>sd ShoppingCartUpdate

:ShoppingCart

<<joinpoint>>

{point = RECEIVE, time = AFTER}

{advice = Persistence.persist()}

Page 20: Towards Executable Aspect-Oriented UML Models 10th Int. Workshop on Aspect-Oriented Modeling (AOM), 6th Int. Conf. on Aspect-Oriented Software Development

Aspect weaving

• As the final behavior of base classes and aspects is expressed by means of activity diagrams, the weaving problem can be reduced to weaving activity diagrams.

• Two phases: joinpoint selection and aspect injection.

Joinpoint selection

• Pointcuts are processed to generate XPath expressions that are used to search selected joinpoints (UML models are serialized into XMI).

• Information required by the weaver is added to each selected joinpoint (e.g., advice to be injected).

Page 21: Towards Executable Aspect-Oriented UML Models 10th Int. Workshop on Aspect-Oriented Modeling (AOM), 6th Int. Conf. on Aspect-Oriented Software Development

Aspect weaving

CallOperation

arg1 arg2

target

result

O2 O3

O4

O1

arg1

arg2

result

Action1

Source Object Target Object

Action N

...

O5

O6

1

2

3

4

5

6

Advice injection(1) Select the place where the advice must be injected.(2) Translate special AO actions into UML plain actions.(3) Reroute control and object flows to ensure correctness of the composition

BEFORE AFTER AROUND

SEND 1 2 3

RECEIVE 4 5 6

Page 22: Towards Executable Aspect-Oriented UML Models 10th Int. Workshop on Aspect-Oriented Modeling (AOM), 6th Int. Conf. on Aspect-Oriented Software Development

Aspect weaving

Advice injection(1) Select the place where the advice must be injected.(2) Translate special AO actions into UML plain actions.(3) Reroute control and object flows to ensure correctness of the composition

<<structured>>

<<ReadSelf>>

ThisShoppingCart

target <<CallOperation>>

persist

argument

<<CallBehavior>>

GetReference

result

<<Literal>>

Persistence

<<WriteStructuralFeature>>

WriteQuantity

value

argument

<<ReadSelf>>

ThisShoppingCart

SelectedProduct<<CreateLinkObject>>newBook

bookcart

quantity : intbook : Book

C1

C2

Page 23: Towards Executable Aspect-Oriented UML Models 10th Int. Workshop on Aspect-Oriented Modeling (AOM), 6th Int. Conf. on Aspect-Oriented Software Development

Aspect weaving

Advice injection(1) Select the place where the advice must be injected.(2) Translate special AO actions into UML plain actions.(3) Reroute control and object flows to ensure correctness of the composition

<<structured>>

<<ReadSelf>>

ThisShoppingCart

target <<CallOperation>>

persist

argument

<<CallBehavior>>

GetReference

result

<<Literal>>

Persistence

<<WriteStructuralFeature>>

WriteQuantity

value

argument

<<ReadSelf>>

ThisShoppingCart

SelectedProduct<<CreateLinkObject>>newBook

bookcart

quantity : intbook : Book

C1

C2

Page 24: Towards Executable Aspect-Oriented UML Models 10th Int. Workshop on Aspect-Oriented Modeling (AOM), 6th Int. Conf. on Aspect-Oriented Software Development

Experiments and Future Work

• Lack of UML tools that – Execute models– Export/Import to XMI, including actions, adequately.

• UML2 de Eclipse for UML modeling• Telelogic Rhapsody for UML execution• Solution: Use UML2 and import manually the woven in

Rhapsody for validating the results.• As future work:

– Develop an academic UML execution engine for our own experimentation.

– Replace the current pointcut model by JPDD’s or similar.

Page 25: Towards Executable Aspect-Oriented UML Models 10th Int. Workshop on Aspect-Oriented Modeling (AOM), 6th Int. Conf. on Aspect-Oriented Software Development

Questions ?

Have I explained it clearly ?

Any question or suggestion ?

Thanks for your attention