diff --git a/.classpath b/.classpath new file mode 100644 index 0000000..fbd4ecd --- /dev/null +++ b/.classpath @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/.project b/.project new file mode 100644 index 0000000..40e4d23 --- /dev/null +++ b/.project @@ -0,0 +1,18 @@ + + + tictactoe + + + + + + org.eclipse.ajdt.core.ajbuilder + + + + + + org.eclipse.jdt.core.javanature + org.eclipse.ajdt.ui.ajnature + + diff --git a/edu.tictactoe/build.gradle b/edu.tictactoe/build.gradle index 563ef57..07bf937 100644 --- a/edu.tictactoe/build.gradle +++ b/edu.tictactoe/build.gradle @@ -4,6 +4,7 @@ plugins { // Apply the java plugin. id 'java' + id("io.freefair.aspectj") version "9.2.0" } java { @@ -26,6 +27,16 @@ dependencies { implementation("org.aspectj:aspectjrt:1.9.25") } +jar { + manifest { + attributes 'Automatic-Module-Name':'edu.tictactoe', + 'Main-Class': 'edu.tictactoe.App', + 'Class-Path': 'edu.tictactoe org.aspectj.runtime' + } + duplicatesStrategy = DuplicatesStrategy.EXCLUDE + from { configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } } +} + tasks.named('jar') { manifest { attributes( diff --git a/edu.tictactoe/src/main/java/edu/tictactoe/Board.java b/edu.tictactoe/src/main/java/edu/tictactoe/Board.java index 91de0d1..db51292 100644 --- a/edu.tictactoe/src/main/java/edu/tictactoe/Board.java +++ b/edu.tictactoe/src/main/java/edu/tictactoe/Board.java @@ -84,7 +84,7 @@ public final class Board { } } - protected ResultEnum checkGamePlay() { + public ResultEnum checkGamePlay(BoardButton[] buttons) { if ((buttons[0].played && buttons[4].played && buttons[8].played) && @@ -166,7 +166,7 @@ public final class Board { synchronized protected void PlayEventUpdate() { long delay = 0L; - ResultEnum checkplays = checkGamePlay(); + ResultEnum checkplays = checkGamePlay(buttons); if (ResultEnum.winner == checkplays) { diff --git a/edu.tictactoe/src/main/java/edu/tictactoe/Referee.aj b/edu.tictactoe/src/main/java/edu/tictactoe/Referee.aj new file mode 100644 index 0000000..76ed17f --- /dev/null +++ b/edu.tictactoe/src/main/java/edu/tictactoe/Referee.aj @@ -0,0 +1,19 @@ +package edu.tictactoe; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public aspect Referee { // call the plays. + pointcut PlayEventUpdate(): execution(public * edu.tictactoe.Board.*(..)); + + ResultEnum around(BoardButton[] buttons): execution(public * edu.tictactoe.Board.checkGamePlay(BoardButton[])) && args(buttons) && if(buttons!=null) + { + ResultEnum oval = proceed(buttons); + + Logger logger = LoggerFactory.getLogger(Board.class); + + logger.info(String.format("Checking Board play: %s ", oval)); + return oval; + } + +} diff --git a/edu.tictactoe/src/main/java/edu/tictactoe/Validator.java b/edu.tictactoe/src/main/java/edu/tictactoe/Validator.java deleted file mode 100644 index a2b2809..0000000 --- a/edu.tictactoe/src/main/java/edu/tictactoe/Validator.java +++ /dev/null @@ -1,8 +0,0 @@ -package edu.tictactoe; - -import org.aspectj.lang.annotation.Aspect; - -@Aspect -public class Validator { - -}