Upload
bridget-moody
View
213
Download
0
Embed Size (px)
Citation preview
Using AOP to Ease Evolution
Presented by David Shepherd (QLI & UD)
Co-Authors: Thomas Roper (QLI) and Lori Pollock (UD)
2
Making a Distributed Database Application
Issue: Stale Data
DB
DB
DB
Delaware
Hawaii
North CarolinaReq
uest
Data
Request Data
Data
Data
Detective
DMV
Update
?notify
Motivation for Evolution in the Field
Databases with
Records Of Cars
Detective App.Non-Trivial Data Mining
Clerk App.Update car data
3
Desired Evolution Task
Notification Scheme
DMV App DB Server
DetectApp
Interesting Update
Return Results Send Primary Keys
Return Results
Query DB
Can a database support this functionality?
Who is interested in
these records?
No
4
Software Evolution Problem
Open Source Software X
AdditionalFeature(s)
Have
Open-Source Software (OSS) App
Need to Modify Application
Adding Feature(s)
Issues
OSS evolves independently
Injection of feature
Maintenance of feature
Potential Solutions
OOP vs. Aspect-Oriented Programming (AOP)
5
Overview of Evolution Process
Original Open
Source Software
Augmented Open
Source Software
Original Open
Source Software
Feature
Augmented New Version
OSS
NewVersion
OSS
Feature
Aug-mented
New VersionOSS2
NewVersionOSS2
Feature
OOP Process
AOP Process
1
1
2
2
New Version of OSS Available
6
Possible OOP Solution
DBObserverexecutes
notifies Notifies
listeners
Add Code into method Add Code into method Add methods
Add interface Add implementation of interface
try{ // Evaluate the sql query Table result = sql_executor. execute(db_conn, query); query.notifyObservers(result); error = false; return t;}
public class SQLQuery implements Subject{ ... public void notifyObservers(Table result){ //Get the primary keys, table, etc. ResultInfo resultInfo =... //Get query info from the query QueryInfo queryInfo =... //update all ... } public SQLQuery(){ addObserver(DatabaseDistributedNotifier. getInstance()); ... }
SQLQuery
notifyObservers
getQuery
addObserver
SQLQuery
addVar
Clear …
DbServerexecuteQuery
openConnection
parseQuery
commitQuery
Public interface DBObserver{……}
Public class MckoiDBObserver implements DBObserver {……}
Original OSS CodeOriginal OSS Code New Feature Code
7
2 packages
3 classes
*needs to be added here
Crosscutting Concern (CCC)
An Outcome of OOP Solution
This represents one .java fileTaller = Longer file
Blue lines representour feature’s implementation
9
Pointcut
Pointcut
AOP Solution
ObserverProtocolSQLQueryexecute
Prepare
SQLQuery
Pointcut SubjectChange
Pointcut updateObserver
Pointcut registration
DBObserverProtocol
Pointcut subjectChange
Pointcut updateObserver
Pointcut registration
Declare Subject
Declare Observer
DBObserver
update
Feature Implementation
Original CodeBase
Key Feature:
Only loosely coupled with Original OSS
Key Feature 2:
Observer concern
modularized
Pointcut
10
Finding Code Insertion Points
Database Codebase
A First Step in implementation (for both methods)
11
Finding Insertion Point – A Closer Look
Statement “Select”’s evaluate method /** * Evaluates the select statement with the given Database context. */ public Table evaluate() throws DatabaseException {
DatabaseQueryContext context = new DatabaseQueryContext(database);
// Check the permissions for this user to select from the tables in the // given plan. checkUserSelectPermissions(context, user, plan);
boolean error = true; try {
Table t = plan.evaluate(context); error = false; return t; }
Snippet from JDBCDatabaseInterface’s execQuery method . . .… try {
// Evaluate the sql query.
Table result = sql_executor.execute(database_connection, query);
// Put the result in the result cache... This will lock this object // until it is removed from the result set cache. Returns an id that // uniquely identifies this result set in future communication. // NOTE: This locks the roots of the table so that its contents // may not be altered. result_set_info = new ResultSetInfo(query, result); result_id = addResultSet(result_set_info);
}…
Which place is better?
12
OOP Process – Find Insertion Point
1Insert in most likely place2 Test – Fail3 Remove Code
We removed an extra statement
Causing two errors
4Continue Cutting and Pasting . . .
5Answer Co-Worker’s
Question About Another Project
Ponder, where was I?(what is my working set)
13
AOP Process – Find Insertion Point
1Set Pointcut to Most Likely Place2 Test – Fail3 Change Pointcut4
Continue Changing Pointcut . . .
5Answer Co-Worker’s
Question About Another Project
Only working with one file: Easy to remember working set
14
New OSS Version Available
Original Open
Source Software
Augmented Open
Source Software
Original Open
Source Software
Feature
Augmented New Version
OSS
NewVersion
OSS
Feature
Aug-mented
New VersionOSS2
NewVersionOSS2
Feature
OOP Process
AOP Process
2
2
15
OOP Solution another outcome
Database Codebase
Process with OOP1. Find Feature Code
2. Extract Feature Code
3. Find new insertion points
4. Insert Feature code
New Database Codebase
16
Evolution of Codebase: AOP Solution
Database Codebase
New Code Well-Modularized Separate from main code base
Refers to main code base
New Database Codebase
AOP: At worst, realign pointcut
references
17
Concluding Remarks - Lessons Learned
AOP saves effort when adapting an open-source project
Eases Initial Maintenance Task - Add New Feature Non-Invasive Change
Maintaining Working Set
Eases Evolution - Adapt to OSS Change Finding the Feature
Only Re-Align Pointcuts
Status Working Implementation
Continue to use in ongoing industry research
AOP is AOK!
20
AOP Process – Find Insertion Point
Snippet from JDBCDatabaseInterface’s execQuery method . . .… try {
// Evaluate the sql query. Table result = sql_executor.execute(database_connection, query); query.notification(result); error=false; // Put the result in the result cache... This will lock this object // until it is removed from the result set cache. Returns an id that // uniquely identifies this result set in future communication. // NOTE: This locks the roots of the table so that its contents // may not be altered. result_set_info = new ResultSetInfo(query, result); result_id = addResultSet(result_set_info);
}…
22
com.m
ckoicom.m
ckoi.database
com.m
ckoi.database.control
com.m
ckoi.toolscom.m
ckoi.util
com.m
ckoi.store
com.m
ckoi.runtime
com.m
ckoi.jfccontrols
com.m
ckoi.debug
com.m
ckoi.database.sql
com.m
ckoi.database.regexbridge
com.m
ckoi.database.procedure
com.m
ckoi.database.jdbcserver
com.m
ckoi.database.jdbc
com.m
ckoi.database.interpret
com.m
ckoi.database.global
com.mckoi
com.mckoi.database
com.mckoi.database.control
com.mckoi.database.global
com.mckoi.database.interpret
com.mckoi.database.jdbc
com.mckoi.database.jdbcserver
com.mckoi.database.procedure
com.mckoi.database.regexbridge
com.mckoi.database.sql
com.mckoi.debugc
om.mckoi.jfccontrols
com.mckoi.runtime
com.mckoi.store
com.mckoi.tools
com.mckoi.util
23
Possible Solutions
Can a database support this functionality?
DbServer
executeQuery
openConnection
parseQuery
commitQuery
…
try{ // Evaluate the sql query Table result = sql_executor.execute(db_conn, query); query.notifyObservers(result); error = false; return t;}
public class SQLQuery implements Subject{ ... public void notifyObservers(Table result){ //Get the primary keys, table, etc. from results ResultInfo resultInfo =... //Get query info from the query QueryInfo queryInfo =... for(Iterator e = observers.iterator(); e.hasNext(); ){ ((DBObserver)e.next()). update(resultInfo,queryInfo); } } public SQLQuery(){ addObserver(DatabaseDistributedNotifier. getInstance()); ... }
SQLQuery
notifyObservers
getQuery
addObserver
removerObserver
SQLQuery
addVar
translateObjectType
clear
…
24
Quantum Leap Innovations – Business Model
What We Do We create pioneering technologies that are used by our partners to build innovative products and services.
How We Do It We support our partners as a team member by providing our unique IP, software technologies and people.
Gov’t Agencies Partners
Technology Differentiated
Products &Services
ResearchPrograms
End Users
PioneeringSoftware
Technologies
Tom, am I allowed to show this? It was from the Template.ppt in J:\Presentations.