170 likes | 275 Views
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
E N D
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 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 • Hotel Service Example
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 Connector for each Service Invocation • Code Example 1 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 Billing Aspect to bill each time a service is invoked • Code Example 2 class BillingPerUse { hook BillingHook { private int total = 0; private int cost = 0; public void setCost(int aCost){ cost = aCost; } private void pay(){ total = total + cost; } BillingHook(method (Date d1,Date d2,CityCode cc)) { call(method); } after() { pay(); } } } Billing hook Service Management: Billing Aspect
Web Services Management Layer Same connector before, now extended with billing hook • Code Example 2 static connector HotelServiceC_listHotels { … BillingPerUse.BillingHook billPerUse = new BillingPerUse.BillingHook (List listHotels(args)); billPerUse.setCost(2); redirectionhook.replace(); billPerUse.after(); } Instantiation of the billing hook Service Management: Billing Aspect
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