Software Engineering for Smart Data Analytics & Smart Data Analytics for Software Engineering

User Tools

Site Tools


This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
research:logicaj:demoproject [2010/01/06 20:34] external edit
research:logicaj:demoproject [2018/05/09 01:59] (current)
Line 1: Line 1:
 +===== LogicAJ Demo Project =====
 +The LogicAJ demo project contains two small applications using a range of aspects that implement different concerns (generic visitor and decorator patterns, mock objects and contract checking). For an introduction to basic ideas behind the aspects used in the demo see: 
 +{{:​research:​logicaj:​logicajdemoslides.pdf|LogicAJ Demo Slides}}.
 +Before trying out the project, make sure your LogicAJ installation is up-to-date: See [[installation|ROOTS update site]].
 +Get the demo project from {{:​research:​logicaj:​| (26.05.2009)}}
 +/* [[http://​​research/​logicaj/​downloads/​src/​| (21.05.2008)]] */
 +and extract it into your workspace. Then import the project into your Eclipse Workspace via ''​File->​Import...->​Existing Projects''​
 +To execute the applications weave the aspects by opening an aspect (or any file in the demo project) and clicking the {{:​research:​logicaj:​logicaj.weave.gif|weave}} button.
 +All necessary aspects are activated by default (they have all been added to ++the ''​lajbuild''​ file | (The ''​lajbuild''​ file 
 +is found on the top-level of each LogicAJ project. By adding or commenting ​
 +out lines of this file you can activate or deactivate aspects as you like.).++
 +Then execute the corresponding Main classes (see below) in the **''​LogicAJDemo-output''​ project**.
 +==== Wiki-Viewer ====
 +Main class: ''/​LogicAJDemo/​src/​wikiviewer/​''​
 +Opens a Swing application window with two buttons, one showing in the left-hand-side pane the original wiki text,
 +the second intended to show the text as html.
 +However, in the base application the second button also shows the orginal wiki text.
 +Once the DecoratorAspect and the StreamReaderDecorator aspect are woven
 +the wiki text output is //​decorated//​ with HTML tags. Since the left-hand-side pane is a HTML viewer, the output is formated accordingly.
 +See the {{:​research:​logicaj:​logicajdemoslides.pdf|slides}} and the code of ''​aspects.AbstractDecorator''​ for details how the decorator
 +pattern is implemented generically in LogicAJ and ''​aspects.StreamReaderDecorator''​ for its concretization as a StreamReaderDecorator.
 +<table style="​border-spacing:​20px;​color:​grey">​
 +  <td class="​centeralign"​ style="​border=10pt"> ​
 +   <​img src="/​_media/​research/​logicaj/​wiki_viewer_plain_text.jpg"></​img>​ <​br/> ​ <​b>​Plain Text View</​b>​
 + </​td>​
 +  <td class="​centeralign">  ​
 +     <​img src="/​_media/​research/​logicaj/​wiki_viewer_html_view.jpg"></​img>​ <br/> <​b>​Html View</​b>​
 +  </td>
 +==== HTML-to-Wiki converter ====
 +Main class: ''/​LogicAJDemo/​src/​html2wiki/​''​
 +This application takes an URL string and puts out corresponding ​
 +JSP wiki syntax on the console. To achieve this, it uses an aspect-generated visitor that traverses the 
 +HTML abstract syntax tree (toplevel class is ''​HtmlElement''​). An "​accept"​ method is introduced to all 
 +elements of the HTML syntax tree as part of a generic Visitor Pattern implementation.
 +Be aware that the base application is not functional without the woven aspects, since it
 +++references visitor classes and methods generated by LogicAJ aspects.| In order to let the LogicAJ compiler graciously ​
 +accept forward references to types or methods that will only come into life during weaving, ​
 +LogicAJ offers a new feature called //​non-oblivious call//. It is supported by the
 +overloaded method call(..) in the class logicaj.NO (NO for "​Non-Oblivious"​).
 +By now you have to include this class with every base program (this limitation
 +will be removed in the future). See the Java-Doc for usage details.++
 +Since the base code for LogicAJ must be pure Java code that does //not// anticipate code
 +introduced by aspects we introduced a new feature called //​non-oblivious call// which is supported by the
 +overloaded method call(..) in the class logicaj.NO (Non-oblivious).
 +By now you have to include this class with every base program (this limitation
 +will be removed in the future).
 +//​Non-oblivious calls// allow the reference to classes or methods introduced in the weaving process.
 +See the Java-Doc for usage details.
 +=== ConcreteVisitorAspect and AbstractVisitorAspect ===
 +The aspects used for this example are the ConcreteVisitorAspect and AbstractVisitorAspect described below. Their main 
 +effects are illustrated in the image:
 +  * Creation of a new class ''​HtmlElement$Visitor''​ containing ''​visit(<​ElementType>​ elem){}''​ methods for all subtypes of th''​html2wiki.parser.internal.node.HtmlElement''​.
 +  * Declaration that the base class ''​Html2WikiVisitor''​ extends the generated ''​HtmlElement$Visitor''​
 +  * Introduction of ''​accept(HtmlVisitor v) {  v.visit(this);​... }''​ methods to all subtypes of ''​HtmlElement''​
 +{{:​research:​logicaj:​logicaj-demo-visitor-aspect.png?​600|LogicAJ Visitor Aspect Example}}
 +=== MockAspect ===
 +This optional aspect can be use to parse a local html file (test.html) instead of loading the file from the given URL.
 +For details on the mock aspect see [[https://​​research/​logicaj/​examples#​mock_objects|here]].
research/logicaj/demoproject.txt · Last modified: 2018/05/09 01:59 (external edit)

SEWiki, © 2019