Title: Atlas: An Example of Using Aspects to Express Architectural Configurations
1Atlas An Example of Using Aspects to Express
Architectural Configurations
- Gail Murphy
- University of British ColumbiaMik KerstenXerox
PARC
2Applications Today
- Increasing number of different kinds of devices
- Some applications need to run on multiple devices
(i.e., in different contexts)
News ClippingApplication
Desktop
Palm
Cellphone
3Possibilities
Separate code bases (and architectures?) to
support each context
Product-line different static variants of
basically same architecture and code base
One code base with dynamic choice of context
one architecture, multiple configurations
4Possibilities
Separate code bases (and architectures?) to
support each context
Product-line different static variants of
basically same architecture and code base
One code base with dynamic choice of context
one architecture, multiple configurations
5Overview
- Case study of supporting dynamic reconfiguration
between contexts in a web-based learning
environment from one code base - Managed complexity of reconfiguration in the code
using aspect-oriented programming
- Web-based learning environment
- Configurations
- Aspect-oriented Programming
- Aspects for Configurations
6Atlas Web-Based Learning Environment
- Must support concurrent access by thousands of
students - Register for courses
- Browse course material
- Interact with others online
- Performance is critical
- Size
- Over 10K loc
- 180 classes
- 17 aspects
7Multi-tier Architecture
- Multi-tier architecture
- Supports different tier configurations
- Single Server
- Application Server
- Parallel Servers
- Applet
8Tier Configuration
- Default configuration
- User accesses Atlas from a web browser
- Web server delegates request to the AtlasService
Servlet - Atlas service handles the request using the
UserDatabase
9Tier Configuration (continued)
10Changing Configurations
- The DSB is a generic utility, separate from
AtlasService - Change configurations by modifying connections
between
2
1
- DSBClient and DSBServer(s)
- DSBServer and AtlasService
- AtlasService and UserDatabase
3
2
1
3
2
11Distribution Support
- Some tier configurations resulted in AtlasService
running in a distributed context - Parts of AtlasService were not distribution-aware
- User Database local resource
- Course Registry local resource
- Accessing static web page content read from file
system - Printing web pages to browser need to buffer
print stream
12Quick Recap
- Code base must support dynamic changing to tier
configuration - Code base must be distribution aware (for some
configurations)
13Aspect-oriented Programming
- Modularize crosscutting concerns Kiczales et al
1997
- logging in org.apache.tomcat
- Slide courtesy of Xerox PARC AspectJ team
14AspectJ
- Extension to the Java programming language that
supports aspect-oriented programming in Java
developed at Xerox PARC - Join point model
- Well-defined points in the execution of a program
- Can execute code when a join point is reached
- Expose certain program values when a join points
is reached - Pointcuts and Advice
15PointCuts
- A pointcut specifies join points of interest
- Some examples
- Pointcut move() call (void Point.setx(int)
call (void
Line.setP1(Point) ) - call (public Figure.(..) )
- cflow (move())
16Advice
- Advice defines code to run when join points are
reached - Several different kinds
- before
- after
- around
- e.g.,after() returning move()
System.out.println(A figure has moved.) - Can expose some program values
17Aspects for Configuration
- To change between configurations have to change
code in numerous classes - Configuration aspects localize this code
- configure connections among remote and local
components - To do this we needed to
- hook into all the places where communication
occurs - add tier configuration code
18ParallelServer Context Code
aspect ParallelServer extends TierConfig
ServerRegistry registry new ServerRegistry()
advise DSBClient.handleRequest(
Servlet requestingService)
before registry.initForParallelMode()
handle(requestingService) . . .
. . .
19Distribution by Reassociation
- Could have refactored AtlasService to use the
Factory pattern to choose the appropriate
distribution-aware utility - Instead, reassociated the distribution-sensitive
utilities by advising the corresponding methods
to use distribution-aware utilities
20RemoteReader Aspect
- Aspect overrides member of a class with a
specialized instance
aspect RemoteReader advise
WebtopPageBuilder() after
pageReader (RemotePageReader)
Namespace.lookup(DSB_SERVER_IP
RemotePageReader)
21Summary
- Aspects facilitated the development of Atlas
- Modularized the tier configuration concern
- Distributed the AtlasService without refactoring
- Aspects separate the more complicated contexts
from the single server (default) context - Ease debugging
- Maintain clarity of base code
22Open Questions
- Will this successful experience of aspects for
different architectural configurations
generalize? - Can aspects help
- simplify the coding of other kinds of
architectures? - separate architectural information from
components to make components more reusable? - help make architecture more explicit in code?