Providing Support for Extracting Concerns towards JAsCo Artifacts in the Concern Manipulation Environment
Type: Apprenticeship and Thesis
Assistant(s): Wim Vanderperren, Davy Suvee
Supervisor: Viviane Jonckers
Student(s)
Karel Bernolet
Program: Licentiaat Toegepaste Informatica
E-mail: kbernole@vub.ac.be
Apprenticeship
Description
The purpose of the apprenticeship is to support the extraction of concerns in the CME 1) towards JAsCo 2).
Since the CME itself has no support yet for extraction, the main goal is to provide a framework to extract concerns. The CME will be used to identify and encapsulate a concern. Those concerns will be extracted towards JAsCo artifacts.
Len Feremans, an other student, provides support for JAsCo artifacts within the CME.
Current Status
Subject | Detailed Work | ||
---|---|---|---|
begin October | JAsCo plugin for Eclipse 3.0 | porting the Eclipse 2.1 plugin to Eclipse 3.0 purpose is to gain experience with the Eclipse API's |
|
middle of October | Literature | reading information about the CME and JAsCo | |
end of October | Exploring the CME | playing around with the tools and looking to the finished code | |
middle of November | Developping the Tool | exploring the internal CME objects algorithmically | |
end of November | adapting the existing JascoCodeGenerator from the \\eclipse plugin | ||
begin of December | resolving unresolved variablis in the aspect originated by the refactoring |
||
middle of December | physically manipulating the original code: generating getMethods\\removing the crosscutting concern\\moving certain variables to the aspect |
||
end of December | The apprenticeship is finished. | writing the report |
Result
Scenario
Here a simple scenario is demonstrated:
- We start with a regular java class containg a crosscutting concern.
package stock; import logging.Logger; public class Stock { public int counter; public Stock(int begin) { counter = begin; } public void add(int num) { counter += num; Logger.log("added " + num + counter); } public void remove(int num) { counter -= num; Logger.log("removed " + num + counter); } public int getStock() { int tmptmp = 3; int tmp = 20 + tmptmp; Logger.log("tmp var is:" + tmp+ " requested counter is: "+counter); return counter; } }
- The CME query engine is used to identify all artifacts of the concern:
- and to construct the concern:
- the context menu of the concern is expanded with an option to extract the concern to JasCo artifacts:
- next a wizard pops up, allowing the developper to name the aspect, connector and a prefix of the generated hooks:
- the result of the refactoring is the same old class without the crosscutting concern:
package stock; import logging.Logger; public class Stock { public int counter; public Stock(int begin) { counter = begin; } public void add(int num) { counter += num; } public void remove(int num) { counter -= num; } public int getStock() { return counter; } public int getCounter() { return counter; } }
- a connector describing where the aspect has to be applied:
static connector LogConnector { LogAspect.LogHook0 hook0 = new LogAspect.LogHook0(int stock.Stock.getStock()); LogAspect.LogHook1 hook1 = new LogAspect.LogHook1(void stock.Stock.remove(int)); LogAspect.LogHook2 hook2 = new LogAspect.LogHook2(void stock.Stock.add(int)); hook0.after(); hook1.after(); hook2.after(); }
- and the aspect itself:
package aspects; class LogAspect { hook LogHook0 { LogHook0(method(..args)) { execute(method); } after() { int tmptmp = 3; int tmp = 20 + tmptmp; Logger.log( "tmp var is:" + tmp + " requested calledobject.getCounter() is: " + calledobject.getCounter()); } } hook LogHook1 { LogHook1(method(..args)) { execute(method); } after() { Logger.log( "removed " + arg[0] + calledobject.getCounter()); } } hook LogHook2 { LogHook2(method(..args)) { execute(method); } after() { Logger().log( "added " + arg[0] + calledobject.getCounter()); } } }
shortcomings
- since the CME query engine only supports artifacts of 1 line, this system is limited to 1 line concerns as well
- at the moment only method calls are supported as an artifact
- the system only generates after() advices no matter where the concern is situated in the original code
- when a variable is and needed in the advice and needed in the original code, the system causes code duplication
Dissertation
Description
Not yet available
Current Status
Not yet available
Presentations or other documents
Links
- Original proposal (in Dutch)