Presentation is loading. Please wait.

Presentation is loading. Please wait.

A Distributed Aspect-Oriented System for J2EE Applications Muga Nishizawa and Shigeru Chiba (Tokyo Institute of Technology, Japan) Background - As benefits.

Similar presentations


Presentation on theme: "A Distributed Aspect-Oriented System for J2EE Applications Muga Nishizawa and Shigeru Chiba (Tokyo Institute of Technology, Japan) Background - As benefits."— Presentation transcript:

1 A Distributed Aspect-Oriented System for J2EE Applications Muga Nishizawa and Shigeru Chiba (Tokyo Institute of Technology, Japan) Background - As benefits of AOP are getting recognized, a few AOP systems for J2EE have been developed before e.g. JBoss AOP, Spring AOP - J2EE is a distributed component framework for Java - However, they don’t provide new mechanisms specially developed for J2EE Motivating Example: Test code for distributed authentication service AuthTest (AspectBean) Authenticator DbAccess Deploy Deliver pointcut Load&weave - Once the user deploys an aspect, DJcutter … 1. acquires the pointcut information of the aspect 2. automatically delivers the information to each DJcutter 3. each DJcutter registers the information itself - Then the user orders DJcutter “weave”, DJcutter … 1. passes the operation to each DJcutter 2. Each DJcutter weave distributed software and aspect Client > Authenticator > DbAccess - One of the test programs confirms setUser () is actually executed on DbAccess if a client remotely calls registerUser () * The test includes a distributed crosscutting concern - DJcutter has a mechanism dedicated only for J2EE * Remote pointcut * Distributed weaving * It is implemented as one of services (MBean) on top of JBoss 4.0.0 RC 1 Proposal DJcutter: A distributed AO system for J2EE Contribution 1: Remote Pointcut - Identifies join points in a program on a remote host - Advice is run on a host different from the host where join points are pointcut - Transparently - Like RMI for distributed OOP - For instance … aspect AuthTest implements AspectBean { 1. flag = false 2. calls registerUser() 3. assert flag == true before(): execution(void setUser()) { flag = true; }} class DbAccess implements SessionBean { void setUser() { … … } Contribution 2: Distributed Weaving Authenticator We could write the test program as a single non-distributed module on the client side DJcutter (MBean) EJB Container JBoss Deliver pointcut The users of DJcutter do not have to manually deliver the compiled aspects to every host Authenticator class DbAccess implements SessionBean { void setUser() { … … } class AuthTest 1. flag = false 2. calls registerUser() 3. assert flag == true class Callback Implements EntityBean flag = true aspect Notification { before(): execution(void setUser()) { invoke Callback; } DJcutter (MBean) EJB Container JBoss DJcutter (MBean) EJB Container JBoss registerUser () setUser () Remote Access Register a new user on a DB Problems - These AOP systems don’t support mechanisms for dealing with distributed crosscutting concerns - Concretely * the aspect separating such a concern consists of several distributed sub-components * Delivering software components to participating hosts is a bothersome work Remote pointcut The test concern is separated but, Three distributed sub-components Receiving a client request Adding the new user’s information on a DB - If the user writes the test program in existing AOP systems, …

2 Preplaned Dynamic Weaving Muga Nishizawa and Shigeru Chiba (Tokyo Institute of Technology, Japan) Background: Dynamic Weaving - Aspects can be composed, updated and removed into application at runtime - Benefits * Is that Aspects can be woven without restarting application * Improves efficiency of software development e.g.) Reduces downtime of web application Motivating Example: Unit Test for Client of server-side CustomerManager CustomerManager Motivation - Existing mechanisms for dynamic weaving are not acceptable for industry: low performance, lack of transparency, no-safety(?) e.g. * Using JPDA [Popovici ’03] * JVM’s extension [Bockisch ’04] - We want to use dynamic weaving more easily and simply +register(String): void Client @Aspect class Aspect1 { @Refine(“CustomerManager”) class A { void register(String name) { return ; }}} @Aspect class Aspect2 { @Refine(“CustomerManager”) class A { void register(String name) { throw new Exception(“existing”); }}} void testRegisterNewCustomer() { //register a customer that does not already exist boolean couldRegister = new Client().register(NEW_CUSTOMER); assertTrue(couldRegister); } void testRegisterExistingCustomer() { //register a customer that does exist boolean couldNotRegister = ! new Client().register(EXISTING_CUSTOMER); assertTrue(couldNotRegister); } - By using dynamic weaving, we want to replace real collaborators’ implementations with mock implementations dynamically class Client { CustomerManager mgr; boolean register(String name) { try{ mgr.register(name); return true; } catch(Exception e) { return false; }}} - Replaces the real CustomerManager with mock objects - Changes the mock objects with respect to each test-method => dynamic weaving Overview of Our Aspects - Aspects can dynamically define/redefine/undefine fields and methods of other objects (similar to inter-type declarations) - The following aspects redefine method register() defined in CustomerManager @Deploy(“Aspect1”) void testRegisterNewCustomer() { // do something … } @Deploy(“Aspect2”) void testRegisterExistingCustomer() { // do something … } class CustomerManager { // load-time weaving void register(String name) { switch(Weaver.getDeployed()) { // returns a hash code value case Aspect1’s hash : Aspect1_$$_register(name); return; case Aspect2’s hash : Aspect2_$$_register(name); return; default: original_$$_register(name); return; }} void Aspect1_$$_register(String name) { /* method body defined in Aspect1 class */ } void Aspect2_$$_register(String name) { /* method body defined in Aspect2 class */ } void original_$$_register(String name) { /* original method body */ } } - Traditional test driver’s code for this client Contribution - We proposed efficient dynamic weaving by using only bytecode transformation (without using other tools) (Note that, the aspects must be known at load-time) - These inter-type declarations allow us to redefine/extend implementations simply e.g. redefining mock implementations - Future work is to implement the mechanism for pointcut-advice, other inter-type declarations Implementation Within the ctl-flow of testRegNew() execution, Aspect1 is deployed Each register method Is used in a mock object for testing - By using @Deploy, Aspect is dynamically deployed within the control flow of the execution of method annotated by it Registers a new customer How to test client’s register(..) - Aspects allow dynamically changing the behavior of software - but, those are woven into the rest of application at load-time for efficiency - Weavable aspects must be known before running application (but NOT a problem in practice) Proposal: Preplaned Dynamic Weaving TestDriver Calls the client actually


Download ppt "A Distributed Aspect-Oriented System for J2EE Applications Muga Nishizawa and Shigeru Chiba (Tokyo Institute of Technology, Japan) Background - As benefits."

Similar presentations


Ads by Google