250 likes | 352 Views
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.
E N D
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 adaptiveif 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 Centro de Informática - UFPE
Problems… Adaptability may involve many system elements… … and several aspects Centro de Informática - UFPE
Dictionary Example Basic Functionalities Centro de Informática - UFPE
Adaptability use cases Centro de Informática - UFPE
Code scattering and tangling … Centro de Informática - UFPE
How? How can we structure adaptive applications separating concerns and with a high degree of flexibility? Using AOP and AOM Centro de Informática - UFPE
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) Centro de Informática - UFPE
AspectJ Language Pointcut • pointcut showingScreen(): • execution (publicvoid • showScreen(byte)) ; • before(): showingScreen(){ • System.out.println( • "A screen will be shown"); • } • public static final byte A. • REGISTRATION_SCREEN=-3; Advice Inter-type declarations Centro de Informática - UFPE
Adaptive behavior with AspectJ Centro de Informática - UFPE
Customizing using Aspects Centro de Informática - UFPE
And for the dynamic adaptations… Use Adaptive Object Models Centro de Informática - UFPE
AOM Use Application Metadata Application behavior or characteristic represented as instances of EntityTypes, Entities, PropertyTypes, Properties and StrategyObject Centro de Informática - UFPE
Providing Dynamic Adaptability Obtain AOM information, interpret it into application new behavior and change the application using Aspects Prepare metadata (e.g. XML) representing dynamic application behavior Make this information available Centro de Informática - UFPE
AdapPE Pattern Overview Core Application functionalities Crosscut the application changing its behavior Monitors the context Adaptability implementation to be plugged to the application Provides data for dynamic adaptations Centro de Informática - UFPE
AdapPE Dynamics: Scenario I Centro de Informática - UFPE
Scenario II Centro de Informática - UFPE
AdapPE Example: J2ME Dictionary Centro de Informática - UFPE
Adaptability Aspects • Customization • Screens • Internationalization • Resources Monitoring Centro de Informática - UFPE
Interaction Between Pattern Elements Centro de Informática - UFPE
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 Centro de Informática - UFPE
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) Centro de Informática - UFPE
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 Centro de Informática - UFPE
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 Centro de Informática - UFPE
Structuring Adaptive Applications using AspectJ and AOM Ayla Dantas and Paulo Borba {add, phmb}@cin.ufpe.br Centro de Informática - UFPE