Presentation is loading. Please wait.

Presentation is loading. Please wait.

PPL 2004, Gamagori, AICHI1 Remote Pointcut - A Language Construct for Distributed AOP Muga Nishizawa (Tokyo Tech, Japan) Shigeru Chiba (Tokyo Tech, Japan)

Similar presentations


Presentation on theme: "PPL 2004, Gamagori, AICHI1 Remote Pointcut - A Language Construct for Distributed AOP Muga Nishizawa (Tokyo Tech, Japan) Shigeru Chiba (Tokyo Tech, Japan)"— Presentation transcript:

1 PPL 2004, Gamagori, AICHI1 Remote Pointcut - A Language Construct for Distributed AOP Muga Nishizawa (Tokyo Tech, Japan) Shigeru Chiba (Tokyo Tech, Japan) Michiaki Tatsubori (TRL, Japan IBM) To appear at AOSD ’ 04

2 PPL 2004, Gamagori, AICHI2 This Presentation  Our goal To modularize crosscutting concerns in distributed software  This presentation Background  AOP, crosscutting concern, AspectJ, … Motivating problem and example  A test code for distributed software Our solution  Remote pointcut  SPA ’ 04

3 PPL 2004, Gamagori, AICHI3 AOP (Aspect-Oriented Programming)  Separation of crosscutting concerns  What is a crosscutting concern? The implementation of the concern cuts across multiple modules Within confines of existing technology  E.g. OOP class Car { void start() { System.out.println(“start”); … … }} class Bike { void start() { System.out.println(“start”); … … }} Crosscutting concerns class Car { void start() { System.out.println(“start”); … … }} class Bike { void start() { System.out.println(“start”); … … }} aspect Log { before(): execution(void Car.start()) || execution(void Bike.start()) { System.out.println(“start”); }} exec

4 PPL 2004, Gamagori, AICHI4 AspectJ - General-purpose AOP Language for Java  Like event-driven model  Pointcut To identify join points Join poin (event)  Execution point in a program  E.g. method call, field access  Advice (action) Code that should be execute at each identified join point in pointcuts Before, after, and around aspect Log { before(): execution(void Car.start()) || execution(void Bike.start()) { System.out.println(“start”); }}

5 PPL 2004, Gamagori, AICHI5 Motivating Problem  Crosscutting concerns in distributed software AspectJ can separate them But, the implementation is NOT simple

6 PPL 2004, Gamagori, AICHI6 Test Code for Distributed Authentication Service  Confirm addUser() is executed on Database Client calls registerUser(), registerUser() calls addUser() Authenticator Database registerUser() Client addUser() Register a new user on a DB

7 PPL 2004, Gamagori, AICHI7 Ideal Design for Test Code  On Client, 1. flag = false. 2. call registerUser() on Authenticator. 3. if addUser() is executed on Database, then flag = true. 4. assert flag == true. Authenticator Database registerUser() addUser() Client

8 PPL 2004, Gamagori, AICHI8 Test Code in Java  Crosscutting concern Database code must be edited for test 1.Flag = false 2.Call registerUser() 3.assert flag == true class Database { void addUser() { invoke Callback … … add the user to the database } … … } Client Flag = true Callback Database Authenticator RMI (Remote Method Invocation) Crosscutting concern

9 PPL 2004, Gamagori, AICHI9 Test Code in Java and AspectJ  The concern is separated Database code is not edited 1.Flag = false 2.Call registerUser() 3.Assert flag == true Client Flag = true Callback class Database { void addUser() { … … add the user to the database } Database aspect DatabaseTest { before(): execution(void addUser()){ invoke Callback } DatabaseTest RMI

10 PPL 2004, Gamagori, AICHI10 This Design is Not Satisfactory  When writing the test code, we must consider two concerns: Test Distribution  It requires to divide the code into three sub-modules  Network processing (RMI) and deployment 1. flag = false. 2. call registerUser() on Authenticator. 3. if addUser() is invoked on Database, flag = true. 4. Assert flag == ture Three distributed sub-modules Don’t consider this!

11 PPL 2004, Gamagori, AICHI11 Our Solution - Remote Pointcut  To identify join points in a program on a remote host To run advice on a different host from the host where join points are pointcut Like RMI for distributed OOP class Database { void addUser() { … … } Remote pointcut aspect Log { before() : execution(void addUser()) { System.out.println(“addUser”); } Identified join point

12 PPL 2004, Gamagori, AICHI12 Test Code using a Remote Pointcut  Test program is a single non-distributed module Authenticator 1. flag = false 2. call registerUser() 3. assert flag == true before(): cflow(call(void registerUser())) &&execution(void addUser()){ flag = true } call addUser() Remote Pointcut class Database { void addUser() { } … … } Database AuthenticatorTest (Aspect) call registerUser()

13 PPL 2004, Gamagori, AICHI13 Test Code Implementation aspect AuthenticatorTest extends TestCase { boolean flag; void testRegisterUser() { flag = false; String userId = "muga", password = "xxx"; Authenticator auth = (Authenticator) Naming.lookup("auth"); auth.registerUser(userId, password); assertTrue(flag); } before(): // remote pointcut cflow(call(void Authenticator.registerUser())) && execution(void Database.addUser()) { flag = true; }} When addUser() is executed, the flag is set to true Confirms the flag is true Calls registerUser() Declares and initializes the flag

14 PPL 2004, Gamagori, AICHI14 DJcutter - Distributed AOP Language  It’s an extension of AspectJ language Remote pointcut Remote inter-type declaration  Load-time weaving Aspect weaving in DJcutter is performed at load-time

15 PPL 2004, Gamagori, AICHI15 DJcutter Language Specification  Pointcut DJcutter provides pointcut designators in AspectJ  Call, execution, within, target, … Hosts(Host, …)  The join points in execution on the hosts Cflow(Pointcut)  All join points that occur between the entry and exit of each join point specified by Pointcut  Advice Before, after, and around

16 PPL 2004, Gamagori, AICHI16 Remote Inter-type Declaration  To declare methods and fields in classes on a remote host Database aspect AuthenticatorTest { boolean Database.containsUser(String userId) { // If the user entry specified by userId is found // in the database. } boolean containsUser(); Append at load-time AuthenticatorTest

17 PPL 2004, Gamagori, AICHI17 Use of Remote Inter-type Declaration aspect AuthenticatorTest extends TestCase { void testRegisterUser() { String userId = "muga", password = "xxx"; Authenticator auth = (Authenticator) Naming.lookup("auth"); Database db = (Database) Naming.lookup(“db”); assertFalse(!db.containsUser(userId); auth.registerUser(userId, password); assertTrue(db.containsUser(userId)); } boolean Database.containsUser(String userId) { // If the user entry specified by userId is // found in the database. }} Confirms that the user entry

18 PPL 2004, Gamagori, AICHI18 DJcutter Implementation  Compiler To generate Java-bytecodes representing aspects  Runtime infrastructure To implement load-time weaving

19 PPL 2004, Gamagori, AICHI19 Load-time Weaving Aspect source file Java bytecode Compiler Aspect Server Class Loader entry Distributed software weave deploy Runtime Infrastructure

20 PPL 2004, Gamagori, AICHI20 Related Work 1  Middleware for automatic distribution E.g. J-Orchestra and Addistant They completely hide distribution concern Conbination of AspectJ and them We are not sure they are good for Tomcat, Oracle, …

21 PPL 2004, Gamagori, AICHI21 Related Work 2  Other distributed AOP languages E.g. D language framework JAC (Java Aspect Componenets) To modularize functional crosscutting concerns  DJcutter Remote pointcut To modularize non-functional crosscutting concerns

22 PPL 2004, Gamagori, AICHI22 Conclusion  Remote pointcut To transparently identify join points on remote hosts  Like RMI for distributed OOP To run advice on a different host from the host where join points are pointcut  Without consideration of distribution concern  DJcutter – Distributed AOP Language Remote pointcut Extension of AspectJ language

23 PPL 2004, Gamagori, AICHI23 The End  Thanks

24 PPL 2004, Gamagori, AICHI24

25 PPL 2004, Gamagori, AICHI25

26 PPL 2004, Gamagori, AICHI26 Even if writing RMI is very easy,  We still have a question: Why the test code consists of three sub- modules? Because of not test but distribution concern 1. flag = false. 2. call registerUser() on Authenticator. 3. if addUser() is invoked on Database, flag = true. 4. Assert flag == ture Design Problem

27 PPL 2004, Gamagori, AICHI27 DJcutter Implementation  Compiler To generate a Java-bytecode representing an aspect  Runtime infrastructure To implement load-time weaving  Aspect server  Extended class loader

28 PPL 2004, Gamagori, AICHI28

29 PPL 2004, Gamagori, AICHI29 Our Solution  To run advice on a different host from the host where join points are pointcut  Implementing a single module without consideration of distribution  That is, it can separate distribution concern from the test code Non-distributed sub-modules, Automatic deployment, And separation of crosscutting concerns

30 PPL 2004, Gamagori, AICHI30 Remote Pointcut  To identify join points in a program flow on remote host transparently Corresponding to RMI for distributed OOP Extends to pointcut designators in AspectJ  A single non-distributed module on a single host class Database { void addUser() { System.out.println(“addUser”); … … } Database Remote pointcut aspect Log { before() : execution(void addUser()) { System.out.println(“addUser”); } Log

31 PPL 2004, Gamagori, AICHI31 Three Distributed Sub-modules  Ideally, a concern should be described a non-distributed single module We want to write without consideration of distribution  The test code is written with consideration of distribution As a result, sub-modules, complicated network processing, deployment 1. flag = false. 2. call registerUser() on Authenticator. 3. if addUser() is invoked on Database, flag = true. 4. Assert flag == ture

32 PPL 2004, Gamagori, AICHI32 Three Distributed Sub-modules  Idealy, a concern should be described as a non-distributed single module on a single host  この test code は、分散した sub-modules に なっている Separated, but far from the ideal test code Remote method invocation among sub-modules Deployment Client Callback DatabaseTest RMI DatabaseTest Client Callback DatabaseTest

33 PPL 2004, Gamagori, AICHI33 Related Work

34 PPL 2004, Gamagori, AICHI34 Ideal Test Code  In the test code, we declare a flag for comfirming that addUser() was executed AuthenticatorTest Program call registerUser() 1. Sets flag to false 2. Remotely calls registerUser() 3. Confirms that flag is ture Flag is set to true, when addUser() is executed Main part for testing call addUser() class DbServer { void addUser() { … … } Database

35 PPL 2004, Gamagori, AICHI35 実際に実装する AuthServer DbServer AuthServerTest 1.registerUser() 呼出 2.addUser() 呼出 class AuthServerTest extends TestCase { boolean wasAddUserCalled; void testRegisterUser() { Naming.rebind("test", new RecieverImpl()); wasAddUserCalled = false; String userId = "muga", password = "xxx"; AuthServer auth = (AuthServer) Naming.lookup("auth"); auth.registerUser(userId, password); assertTrue(wasAddUserCalled); } class ReceiverImpl extends UnicastRemoteObject implements NotificationReceiver { void confirmCall() { wasAddUserCalled = true; } } interface NotificationReceiver { void confirmCall(); } aspect Notification { before(): execution(void DbServer.addUser()){ NotificationReceiver test = (NotificationReceiver) Naming.lookup("test"); test.confirmCall(); }} RMI

36 PPL 2004, Gamagori, AICHI36 Experimental Results


Download ppt "PPL 2004, Gamagori, AICHI1 Remote Pointcut - A Language Construct for Distributed AOP Muga Nishizawa (Tokyo Tech, Japan) Shigeru Chiba (Tokyo Tech, Japan)"

Similar presentations


Ads by Google