Modularizing Web Services Management with AOP

Download Report

Transcript Modularizing Web Services Management with AOP

ECOOP Workshop
Modularizing Web Services
Management with AOP
María Agustina Cibrán, Bart Verheecke
{ Maria.Cibran, Bart.Verheecke}@vub.ac.be
System and Software Engineering Lab
Vrije Universiteit Brussel
Overview
• Introduction
– Web Services
– Aspect Oriented Programming
• Web Services Management Layer
– Architecture
– JAsCo Technology
– Redirection Mechanism and Hot Swapping
– Service Management
• Conclusions
Introduction
• Web Services
– Independent modules
• Described, published, localised and invoked over a
network using XML-standards
– Integrated in client-applications using the
Wrapper Approach
• Automatically generate client-stub and treat
service as an internal component
• Used in Visual Studio.NET, Bea Web Logic, etc
Introduction
• Problem Statement
– Services are hard-wired in application
• How to adapt to changes?
• What if service or network fails?
• How to deal with other service related issues?
– Checking of availability, switching to other services,
dealing with billing, security, logging, etc
– Needs to be provided manually by the programmer
– Results scattered and tangled in the application
 Use AOP to achieve better separation of concerns
Introduction
• Aspect Oriented Programming (AOP)
– Tyranny of the dominant decomposition
• Impossible to modularize some concerns (e.g. logging) using
current software engineering methodologies such as OO.
• As a result code gets scattered all over the system
• AOP Concepts
– Modularize these concerns in Aspects
– An aspect defines a set of join points
– Weavers to weave aspect logic in the core application
Web Services Management Layer
The Wrapper Approach
Web Services Management Layer
WSML
Web Service
E-business
application
Web Service
Web Service
Introducing the WSML to decouple Web Services
from the client-application
Web Services Management Layer
Use the WSML to deal with all web service related issues
Web Services Management Layer
• Core Functionality
– Decoupling of Services from application
• Redirection of application requests to service invocations
– Hot-Swapping
• Switch between services at runtime
– Advanced Service Selection and Monitoring
• Select services based on business driven requirements
– Service Management
• Security, logging, billing, transaction management, etc
Web Services Management Layer
• Use of JAsCo Technology
– Dynamic Aspect Oriented Language
– Introduces two new concepts:
• Aspect Beans:
– specify crosscutting behaviour in a reusable manner:
» When the normal execution of a method should be
intercepted
» what extra behaviour should be executed at those
points.
• Connectors:
– Specify deployment details:
» where the crosscutting behaviour should be deployed.
Web Services Management Layer
Web Services Management Layer
• Hotel Service Example
Class Application {
…
asi.HotelServiceASI.listHotels(args)
…
}
Class HotelServiceASI {
…
public List listHotels(args)
…
}
Legenda
C
Deactivated connector
C
Activated connector
Redirection
Aspect
Ca
Web Service A
Cb
Web Service B
Cc
Web Service C
Web Services Management Layer
• Code Example 1
One Aspect for each request
1. Class ListAvailableHotelsAspect {
2.
hook RedirectionHook {
3.
RedirectionHook(method(..args)){
4.
execute(method);
5.
}
6.
replace() {
7.
return specificMethod(args);
8.
}
9.
abstract public String specificMethod(args);
10. }
11. }
Hook specifying to replace
method (..args) with
specificMethod (args)
specificMethod is specified in
the connector
Redirection Aspect for the request ListHotels
Web Services Management Layer
• Code Example 1
Connector for each Service
Invocation
Hook instantiation
1. static connector HotelServiceC_listHotels {
2.
ListAvailableHotelsAspect.RedirectionHook redirectionhook = new
3.
ListAvailableHotelsAspect.RedirectionHook(List listHotels(args)){
4.
public String specificMethod(args) {
5.
try {
6.
Stub stub = new Stub (WebServiceC);
7.
result = stub.listAvailableHotels(args);
8.
return result;
9.
}
10.
catch (ServiceUnavailableException e) {
11.
WSML.failureNotification ("WebServiceC");
12.
return asi.HotelServiceASI.listHotels (args);
13.
}
14.
}
15.
}
16.
redirectionhook.replace();
17. }
Connector for WebService C
specificMethod with
actual service call
Web Services Management Layer
• Code Example 2
Billing Aspect to bill each time a
service is invoked
1. class BillingPerUse {
hook BillingHook {
2.
private int total = 0;
3.
private int cost = 0;
4.
public void setCost(int aCost){
5.
cost = aCost;
6.
}
7.
private void pay(){
8.
total = total + cost;
9.
10. }
11. BillingHook(method (Date d1,Date d2,CityCode cc)) {
call(method);
12.
13. }
14.
15.after() {
pay();
16.
17. }
18. }
19.}
Service Management: Billing Aspect
Billing hook
Web Services Management Layer
• Code Example 2
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
Same connector before, now
extended with billing hook
static connector HotelServiceC_listHotels {
…
BillingPerUse.BillingHook billPerUse = new
BillingPerUse.BillingHook (List listHotels(args));
billPerUse.setCost(2);
redirectionhook.replace();
billPerUse.after();
}
Service Management: Billing Aspect
Instantiation of the
billing hook
Conclusions
• AOP is suited to modularize Web Service
related issues
• Use JAsCo to dynamically hot-swap
between services and allow runtime
management
• More flexible applications that can easily
adapt to changes in the environment