Programming Assignment
BlueJ Extension - Compile Logger
Write a BlueJ extension to log compile events. Follow the Basic
PSP script.
Every time the user invokes the compiler within BlueJ, the extension
should add a
log entry to a file that contains the date, time, filename, and a
message as shown below.
A sample logfile:
2008.03.30 13:41:14 Compile Started (1 file) HelloWorld.java
... compile succeeded.
2008.03.30 13:41:23 Compile Started (1 file) HelloWorld.java
... compile failed.
2008.03.30 13:41:26 Compile Started (1 file) HelloWorld.java
... compile succeeded.
2008.03.30 13:41:34 Compile Started (3 files)
HelloWorld.java,HiWorld.java,ByeWorld.java
... compile succeeded.
The Extension Details window should show the version number, a
description that gives the name of the
log file, and the URL of this page.
The Preferences -> Extensions tab should have a text field where the
user can specify the name
of the logfile. (When the user changes this value, it is acceptable to
have this not take effect
until the next time they start BlueJ.)
Implementation Constraints
The extension is named CompileLogger.
The Logfile name should be saved as a property in the BlueJ Properties
file using the methods provided
by the Extensions API (get/setExtensionPropertyString).
The default log file name is 'bluej-compilelog.txt'. The
log file must be saved in the User Config Directory.
Be sure to use the platform dependent filename separator character from
java.lang.System.
Use the SimpleDateFormat class to format the date and time portion of
the log message.
Note in the sample log above that a BlueJ CompileEvent may have
multiple files, in which
case the names of all the files must appear in the log message.
Also note one subtle feature:
the log message says "file" for a single file, but makes the
grammatical adjustment to the
plural "files" for multiple files.
The isCompatible() method may simply return true.
Depending on how you decide to manage the file output, the file
contents may not actually
be written until the file is closed. It is acceptable to have the
log file contents not be written
until BlueJ terminates normally.
Attention Eclipse Users:
When working with Eclipse, the first line you type into
the IDE gets compiled, so count it as compile time.
If you don't write your code on paper or in a text editor
before you enter it into Eclipse, then there is no
coding phase. If you go straight from design to
typing in Eclipse, then enter 0 for the coding phase
and put a comment "Entering/compiling code in Eclipse".
Assignment Submission
- Follow the class coding standard.
- Follow the
class guidelines for printouts.
- Print the source code to your extension.
- Print a sample BlueJ compile log file created by your
extension.
- Print the BlueJ properties file showing a user specified logfile
name of "mycompilelog.txt".
- Login
to vogon.csc.calpoly.edu using the Secure Shell Client program
(or your favorite equivalent).
- Change
to the directory containing the source code file for your extension.
- Use
the following handin
command
handin
graderjd 309P2
CompileLogger.java
- Submit your printouts and PSP forms to the instructor on or
before the
due date.
FAQ
Q:
In the preferences window, if the user deletes the name of compile logfile,
then closes the preferences window,
the filename will be saved as empty or blank.
When the extension loads, should there be a check for a blank filename,
and then use the default file name instead?
A:Yes.