联系方式

  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-23:00
  • 微信:codinghelp2

您当前位置:首页 >> Java编程Java编程

日期:2021-02-06 11:35

COMP-533 Model-Driven Software Development

Assignment 1

Logging Implementation

(25% of final grade)

January 27, 2021

Introduction

Logging is probably one of the most common recurring development concerns. During development, logging the execution

of important operations, or the sending of remote messages, or the modification of state, or the handling of exceptions,

can significantly streamline understanding, testing and debugging. Nowadays, many deployed systems also make heavy

use of logging for auditing purpose.

The goal of assignment 1 is to get a feeling of the connection between low-level design models and code (task 1),

and then to gain experience in using aspect-oriented technology at the programming level to modularize the logging

functionality in a reusable way (tasks 2 and 3). Finally, you are going to demonstrate the reusability of your logging

aspect(s) by submitting some other code of your choice that reuses your logging aspect(s).

Task 1: Installing TouchCORE and Java Code Generation

The goal of task 1 is to use the modelling tool we are going to use in this class called TouchCORE to generate the Java

code of a simple banking application that you are going to modularize using aspects in tasks 2 and 3. There is no hand-in

required for task 1. Here are the steps:

? Download TouchCORE (version 7.0.3), the concern-oriented modelling tool used for this assignment from myCourses.

To run TouchCORE you need to first install Java 81

.

? Download the BankWithLogging concern from myCourses.

? Run TouchCORE2

. You can edit the “Settings.txt” file to change the size of the TouchCORE window or toggle

between windowed and full screen mode. This file is read during startup, so any changes you make only take effect

when you restart the application.

? Open the BankWithLogging concern. You will see a circular menu in the top right corner of the screen3

. Click on

the “Open Concern” button (button with a folder icon). Then navigate to the BankWithLogging concern folder and

select the BankWithLogging.core file. You will now see the main concern edit screen, with one BankWithLogging

feature (a white rectangle) in the centre. Click-and-hold on the feature, then select “Open Realizing Design Model”

from the popup menu that appears. This opens the design class diagram of the BankWithLogging application.

1You might be lucky and will be able to run TouchCORE 7.0.3 with more advanced versions of Java, but for instance on Macs (I own several

of them) running Catalina or Big Sur it seems to only run with Java 8. You can install Java 8 from the command line using brew as follows:

brew tap AdoptOpenJDK/openjdk

brew install –cask adoptopenjdk8

On some high resolution Windows systems some students have experienced display problems that were resolved by disabling retina / virtual

scaling mode / virtual pixel zoom.

If the above does not help, please post your problem in the corresponding discussion group on myCourses.

2Type java -jar TouchCORE.jar on the command line, or on some operating systems simply double-click the jar file.

3Clicking-and-holding on the center of the menu will display explaining text for each button.

1

? Optional: You can explore the class diagram (panning is done by right-clicking and dragging on the background).

You can look at the behaviour of the public operations of the design classes by click-and-holding on a public operation

and then choosing the “Go to Message View” button (icon that looks like a sequence diagram without “*”). Hit the

“Back” button (icon that looks like a left arrow) at the top left of the screen to navigate from the sequence diagram

back to the class diagram.

? Generate the Java code. To generate the Java code of the BankWithLogging application, click on the “Weave All”

button (icon that looks like a net) in the circular menu on the top right. This will generate a new class diagram

called “woven_BankWithLogging”. Now click on the “Generate” button (icon that looks like a gear). Select “Java”

from the popup menu. Then choose a folder into which you would like to generate the application code.

? Compile the code, then run it. You should see a simple GUI that allows you to create customers, create accounts

for the customers, and deposit and withdraw money from the accounts. Whenever a customer or account object is

instantiated, or deposit or withdraw is executed, a log message is displayed in the console.

Task 2: Install AspectJ and Separating Logging

For task 2 and 3 you are required to use AspectJ, an aspect-oriented extension of Java. AspectJ is an Eclipse project, but

you don’t need to use Eclipse to run AspectJ.

For task 2 you are asked to refactor the BankWithLogging Java code. You are to use AspectJ to modularize the logging

functionality in such a way that the Account and Customer classes in the end only contain business logic, and do no longer

make explicit logging-related calls. The Logging module does not have to be reusable, i.e., the Logging code is allowed to

directly refer to the Account and Customer classes.

Make sure that the logging output printed to the console looks exactly like before. When done, keep a copy of your

code (for submission on myCourses).

Task 3: Reusable Logging

For task 3 you are asked to elaborate a reusable Logging module. It should provide generic logging functionality for

recording constructor executions and operation executions. The Logging module is not allowed to have any dependencies

on the Account and Customer classes.

Then refactor the BankWithLogging code to use the generic logging module. For this, you need to write a bank-specific

composition specification that tells the system that you want to log the creation of customers and accounts, as well as the

withdraw and deposit operation executions. You can declare additional aspects to do this, or you can add annotations to

the business classes, if necessary. You are not allowed, though, to make explicit calls from business classes to the generic

logging module.

Again, make sure that when you run your code the logging output printed to the console looks exactly like before.

When done, keep a copy of your code (for submission on myCourses).

Task 4: Demonstrating Reuse

Write some other Java code (or take some existing Java code you have previously worked on), and configure it to reuse

the Logging module you developed in task 3. The application can be super simple. The aim of this task is simply to

demonstrate that your Logging concern is indeed reusable. Submit your code together with a readme file that explains

how to compile and run your code from the command line.

Hand-In

As discussed in class, there will be 2 phases for this assignment.

2

Phase 1, due Friday February 5th

During the first phase, each student works on the assignment tasks 1, 2 and 3 individually. Each student must hand in a

solution for task 2 and a solution for task 3 by Friday February 5th 11:59pm. Late hand-ins are not accepted.

? Please create a folder for task 2 named Task 2 containing the complete code for task 2 (aspect(s) and Java code).

Add a readme file explaining how to compile and run your code from the command line.

? Create a folder for task 3 named Task 3 containing the complete code for task 3 (aspect(s) and Java code), and a

“readme” file explaining how a user of your Logging module has to customize your reusable module to his needs (i.e.,

how to specify the application-specific composition specification). Please also explain how to compile and run your

code from the command line in the readme file.

? Compress the two folders into one .zip file and upload it to MyCourses as a submission to assignment 1.

Phase 2, due Friday February 12th

Only students who submitted phase 1 of the assignment will be allowed to participate in phase 2. On Saturday February

6th I will form random groups of 6 students from the pool of students that submitted to phase 1. Each student should

then present their individual solutions to the group. There will be no class on Monday February 8th. Use that time to

meet your group members and discuss your individual solutions. Your goal is to determine a solution for task 2 and task

3 that you will submit as a group by Friday February 12th, 11:59pm. Late hand-ins are not accepted. The solution you

submit can be one of the initial solutions submitted by an individual student, but you can also take the best ideas from

each individual solution and come up with a new one that you submit. Additionally, for phase 2, you must also hand in

a solution for task 4 (i.e., the small sample application that reuses your generic Logging module you submit for Task 3).

? Please create a folder for task 2 named Task 2 containing the complete code for task 2 (aspect(s) and Java code).

Add a readme file explaining how to compile and run your code from the command line.

? Create a folder for task 3 named Task 3 containing the complete code for task 3 (aspect(s) and Java code), and a

readme file explaining how a user of your Logging module has to customize your reusable module to his needs (i.e.,

how to specify the application-specific composition specification). Please also explain how to compile and run your

code from the command line in the readme file.

? Create a folder for task 4 containing the complete code for task 4 (aspect(s) and Java code), together with a readme

file explaining how to compile and run your code from the command line.

Compress the 3 folders into one zip file and submit it on MyCourses as a submission to group assignment 1.

3


版权所有:留学生编程辅导网 2018 All Rights Reserved 联系方式:QQ:99515681 电子信箱:99515681@qq.com
免责声明:本站部分内容从网络整理而来,只供参考!如有版权问题可联系本站删除。