From predrag@ccs.neu.edu Mon May 10 14:02:17 1999 Received: from speer.ccs.neu.edu (predrag@speer.ccs.neu.edu [129.10.116.214]) by amber.ccs.neu.edu (8.9.1a/8.9.1) with ESMTP id OAA15407 for ; Mon, 10 May 1999 14:02:16 -0400 (EDT) Date: Mon, 10 May 1999 02:57:50 -0400 (EDT) From: Predrag Petkovic To: Karl Lieberherr Subject: project description Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Status: R Goal of this project is to have an implementation of aspectual components that is very easy to use by Java programmers at the cost of being slow and not as general as it could be. We are assuming that we have source files for both components and application classes. Components are written as nested classes: class Log { abstract class DataToLog { abstract void doSomething(); // expected void replaced_doSomething() { doSomething(); System.out.println("Something done"); } } and we have application classes: class Point { .... public void draw() {....} .... } Idea is to instrument Java program to fire event every time some method is executed. class Point { static public MethodInvoker invoker = new MethodInvoker(); private void hidden_draw() { ....//body from draw method } public void draw () { MethodEvent event = new MethodEvent(this,"hidden_draw", args); invoker.receiveMethodEvent(event); } .... // same change for every public method } class MethodInvoker { ... // register/unregister methods for Before/After listeners boolean around; void receiveMethodEvent(MethoEvent evt) { around = false; fireBefore(evt); if (!around) invokeMethod(evt); fireAfter(); } } Behavior of application class after instrumentation will not change. It will only allow connecting components to it. Components will need to be changed in similar manner: class Log { class DataToLog { protected MethodTransceiver visitor = new MethodTransceiver(); void doSomething() { MethoEvent event = new MethodEvent(this, "doSomething", args); visitor.receiveMethodEvent(event); } void replaced_doSomethong() { doSomething(); System.out.println("Something done"); } } } class MethodVisitor { void receiveMethodEvent(evt) { ... propagateMethodEvent(evt); ... } void propagateMethodEvent(evt) { fireMethodEvent(evt); // notify all MethodListeners } } Now when both application classes and components fire we can connect them. First some restrictions: 1) there is only 1-1 mapping between method from application class and component's participant 2) expected method have to be mapped to method of application, method body can not be provided in connector Connecting : We will need one static class (library) that will keep track of all connections in system, AspectConnector. After connection is established this class will be responsible for translating up and down MethodEvents and activating required methods in components. Description of deployment will be in file (a.deploy) that describes connection: Component: Log Classes: Point Log.DataToLog to Point { doSomething to draw } In program connection will be established by one line call: AspectConnector.connect("a.deploy"); If participants graph have more then one classes, then we can use in deployment edge mapping: " A,b,B --> from A via B to C " Steps in implementation: 1. instrument Java program 2. translate up and down, activating required methods in component 3. map one participant into several classes 4. edge-Map, using AC library --Predrag PS Please forward this to everyone interesting in it.