Structuring Adaptive Applications using AspectJ and AOM

25
Structuring Adaptive Applications using AspectJ and AOM Ayla Dantas and Paulo Borba {add, phmb}@cin.ufpe.br Centro de Informática - UFPE

description

Structuring Adaptive Applications using AspectJ and AOM. Ayla Dantas and Paulo Borba {add, phmb}@cin.ufpe.br. Centro de Informática - UFPE. Motivation. “A program is called adaptive if it changes its behavior automatically according to its context.” WAAS’95. - PowerPoint PPT Presentation

Transcript of Structuring Adaptive Applications using AspectJ and AOM

Page 1: Structuring Adaptive Applications using AspectJ  and AOM

Structuring Adaptive Applications using

AspectJ and AOM

Ayla Dantas and Paulo Borba{add, phmb}@cin.ufpe.br

Centro de Informática - UFPE

Page 2: Structuring Adaptive Applications using AspectJ  and AOM

Centro de Informática - UFPE 2

Motivation“A program is called adaptive if it

changes its behavior automatically according to its context.” WAAS’95

“The shift toward ubiquitous computing poses multiple novel technical, social, and organizational challenges, which

include analyzing new families of nonfunctional requirements (such as

configurability and adaptability).” CACM Dec 02

Page 3: Structuring Adaptive Applications using AspectJ  and AOM

Centro de Informática - UFPE 3

Problems…Adaptability may involve many system Adaptability may involve many system elements…elements…

… … and several aspectsand several aspects

Page 4: Structuring Adaptive Applications using AspectJ  and AOM

Centro de Informática - UFPE 4

Dictionary ExampleBasic FunctionalitiesBasic Functionalities

Page 5: Structuring Adaptive Applications using AspectJ  and AOM

Centro de Informática - UFPE 5

Adaptability use cases

Page 6: Structuring Adaptive Applications using AspectJ  and AOM

Centro de Informática - UFPE 6

Code scattering and tangling

Page 7: Structuring Adaptive Applications using AspectJ  and AOM

Centro de Informática - UFPE 7

How?How can we How can we

structure adaptive structure adaptive applications applications

separating concerns separating concerns and with a high and with a high

degree of flexibility? degree of flexibility?

Using AOP and AOM

Page 8: Structuring Adaptive Applications using AspectJ  and AOM

Centro de Informática - UFPE 8

Using AOP AOP is a technology intended to provide clear

separation of concerns Particular execution points (join points) can be

identified using AOP Actions can be taken at those points, and may be

defined in a modular unit of crosscutting implementation (aspect)

Page 9: Structuring Adaptive Applications using AspectJ  and AOM

Centro de Informática - UFPE 9

AspectJ Language

pointcut showingScreen(): execution (public void showScreen(byte)) ;

before(): showingScreen(){ System.out.println( "A screen will be shown");

}

public static final byte A. REGISTRATION_SCREEN=-3;

Pointcut

Advice

Inter-type declarations

Page 10: Structuring Adaptive Applications using AspectJ  and AOM

Centro de Informática - UFPE 10

Adaptive behavior with AspectJ

Page 11: Structuring Adaptive Applications using AspectJ  and AOM

Centro de Informática - UFPE 11

Customizing using Aspects

Page 12: Structuring Adaptive Applications using AspectJ  and AOM

Centro de Informática - UFPE 12

And for the dynamic adaptations…Use Adaptive Object ModelsUse Adaptive Object Models

Page 13: Structuring Adaptive Applications using AspectJ  and AOM

Centro de Informática - UFPE 13

AOM Use

Application Metadata

Application behavior or characteristic represented as instances of EntityTypes,

Entities, PropertyTypes, Properties and StrategyObject

Page 14: Structuring Adaptive Applications using AspectJ  and AOM

Centro de Informática - UFPE 14

Providing Dynamic Adaptability

Prepare metadata (e.g. XML)

representing dynamic

application behavior

Make this information

available

Obtain AOM information,

interpret it into application new

behavior and change the

application using Aspects

Page 15: Structuring Adaptive Applications using AspectJ  and AOM

Centro de Informática - UFPE 15

AdapPE Pattern OverviewCore

Application functionalitie

s

Monitors the

context

Provides data for dynamic

adaptations

Crosscut the

application changing

its behavior

Adaptability implementation to be plugged

to the application

Page 16: Structuring Adaptive Applications using AspectJ  and AOM

Centro de Informática - UFPE 16

AdapPE Dynamics: Scenario I

Page 17: Structuring Adaptive Applications using AspectJ  and AOM

Centro de Informática - UFPE 17

Scenario II

Page 18: Structuring Adaptive Applications using AspectJ  and AOM

Centro de Informática - UFPE 18

AdapPE Example: J2ME J2ME DictionaryDictionary

Page 19: Structuring Adaptive Applications using AspectJ  and AOM

Centro de Informática - UFPE 19

Adaptability Aspects

Customization Screens Internationalization Resources Monitoring

Page 20: Structuring Adaptive Applications using AspectJ  and AOM

Centro de Informática - UFPE 20

Interaction Between Pattern Elements

Page 21: Structuring Adaptive Applications using AspectJ  and AOM

Centro de Informática - UFPE 21

And what about AOM and patterns? Most AspectJ actions can be replaced by the

Decorator(Wrapper) or the Adapter patterns Sometimes, a lot of refactoring is necessary in

order to compose concerns A pure OO solution can lead to redudancy if we

want flexibility As the number of adaptive concerns increase, in

order to combine concerns, the system complexity will increase

The code size (LOC) is bigger than for an AspectJ solution

Page 22: Structuring Adaptive Applications using AspectJ  and AOM

Centro de Informática - UFPE 22

However…

The use of AOP requires learning a new language, but in the case of AspectJ, just some new constructions as it is an extension for Java.

In our experiment, the solution using aspects generates an executable file which is 16% bigger than a pure OO solution using GoF patterns.

The execution time is sometimes bigger too (12.53% for the most used method)

Page 23: Structuring Adaptive Applications using AspectJ  and AOM

Centro de Informática - UFPE 23

Conclusions We have good modularization with AspectJ Pure OO solutions generally require more

changes, and can lead to complex systems AspectJ increases the bytecode size, but it is

an acceptable increase Flexibility x Code Size The use of auxiliary classes is important

Page 24: Structuring Adaptive Applications using AspectJ  and AOM

Centro de Informática - UFPE 24

Conclusions

The necessity of refactoring still exists Aspects reuse can be explored AOM helps in providing dynamic adaptations J2ME and AspectJ Applicability for other platforms

Page 25: Structuring Adaptive Applications using AspectJ  and AOM

Structuring Adaptive Applications using

AspectJ and AOM

Ayla Dantas and Paulo Borba{add, phmb}@cin.ufpe.br

Centro de Informática - UFPE