In this example, we have a system that creates an email as a primary object and applying the decorator pattern we can add new characteristics (responsibilities) to the object (in our case Email) at run time. This capability of being able to attach new responsibilities to the object is a flexible alternative to subclassing.
The example shows how a user can easily add a disclaimer to the email, scan it for viruses, add email addresses to BCC or remove them before sending it.
We use Apache Maven to compile and run this project.
You need to install Apache Maven (https://maven.apache.org/) on your system.
Type on the command line:
mvn clean compile
mvn clean compile assembly:single
java -classpath target/Example-1-1.0-SNAPSHOT-jar-with-dependencies.jar edu.bu.met.cs665.Main
or
run.sh
To see bug detail using the Findbugs GUI, use the following command "mvn findbugs:gui"
Or you can create a XML report by using
mvn findbugs:gui
or
mvn findbugs:findbugs
CheckStyle code styling configuration files are in config/ directory. Maven checkstyle plugin is set to use google code style. You can change it to other styles like sun checkstyle.
To analyze this example using CheckStyle run
mvn checkstyle:check
This will generate a report in XML format
target/checkstyle-checker.xml
target/checkstyle-result.xml
and the following command will generate a report in HTML format that you can open it using a Web browser.
mvn checkstyle:checkstyle
target/site/checkstyle.html