SDA SE Wiki

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

User Tools

Site Tools


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: LogicAJ Demo Slides.

Before trying out the project, make sure your LogicAJ installation is up-to-date: See ROOTS update site.

Get the demo project from LogicAJDemoProject_0.5.zip (26.05.2009) 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 weave button. All necessary aspects are activated by default (they have all been added to the ''lajbuild'' file

Then execute the corresponding Main classes (see below) in the LogicAJDemo-output project.

Wiki-Viewer

Main class: /LogicAJDemo/src/wikiviewer/Main.java

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 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.


Plain Text View

Html View

HTML-to-Wiki converter

Main class: /LogicAJDemo/src/html2wiki/Main.java

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.

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 thhtml2wiki.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

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 here.

research/logicaj/demoproject.txt · Last modified: 2018/05/09 01:59 (external edit)

SEWiki, © 2023