Make reaction available when retrieving output from trigger.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Mon, 7 Jan 2013 09:25:21 +0000 (10:25 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Mon, 7 Jan 2013 09:25:21 +0000 (10:25 +0100)
src/main/java/net/pterodactylus/reactor/Trigger.java
src/main/java/net/pterodactylus/reactor/engine/Engine.java
src/main/java/net/pterodactylus/reactor/triggers/AlwaysTrigger.java
src/main/java/net/pterodactylus/reactor/triggers/FileExistenceTrigger.java
src/main/java/net/pterodactylus/reactor/triggers/FileStateModifiedTrigger.java
src/main/java/net/pterodactylus/reactor/triggers/NewTorrentTrigger.java

index fbd9d07..277eeb6 100644 (file)
@@ -46,8 +46,10 @@ public interface Trigger {
         * Returns the output of this trigger. This will only return a meaningful
         * value if {@link #triggers(State, State)} returns {@code true}.
         *
+        * @param reaction
+        *            The reaction being triggered
         * @return The output of this trigger
         */
-       Output output();
+       Output output(Reaction reaction);
 
 }
index fe57b33..f14d3d7 100644 (file)
@@ -192,7 +192,7 @@ public class Engine extends AbstractExecutionThreadService {
                        logger.debug(String.format("Trigger was hit: %s.", triggerHit));
                        if (triggerHit) {
                                logger.info("Executing Action...");
-                               nextReaction.action().execute(trigger.output());
+                               nextReaction.action().execute(trigger.output(nextReaction));
                        }
 
                }
index 928d213..5971553 100644 (file)
@@ -17,6 +17,7 @@
 
 package net.pterodactylus.reactor.triggers;
 
+import net.pterodactylus.reactor.Reaction;
 import net.pterodactylus.reactor.State;
 import net.pterodactylus.reactor.Trigger;
 import net.pterodactylus.reactor.output.DefaultOutput;
@@ -41,7 +42,7 @@ public class AlwaysTrigger implements Trigger {
         * {@inheritDoc}
         */
        @Override
-       public Output output() {
+       public Output output(Reaction reaction) {
                return new DefaultOutput("true").addText("text/plain", "true").addText("text/html", "<div>true</div>");
        }
 
index f3464e9..a285843 100644 (file)
@@ -17,6 +17,7 @@
 
 package net.pterodactylus.reactor.triggers;
 
+import net.pterodactylus.reactor.Reaction;
 import net.pterodactylus.reactor.State;
 import net.pterodactylus.reactor.Trigger;
 import net.pterodactylus.reactor.output.DefaultOutput;
@@ -50,7 +51,7 @@ public class FileExistenceTrigger implements Trigger {
         * {@inheritDoc}
         */
        @Override
-       public Output output() {
+       public Output output(Reaction reaction) {
                return new DefaultOutput("File appeared/disappeared").addText("text/plain", "File appeared/disappeared").addText("text/html", "<div>File appeared/disappeared</div>");
        }
 
index a598a53..39044c3 100644 (file)
@@ -18,6 +18,7 @@
 package net.pterodactylus.reactor.triggers;
 
 import static com.google.common.base.Preconditions.checkState;
+import net.pterodactylus.reactor.Reaction;
 import net.pterodactylus.reactor.State;
 import net.pterodactylus.reactor.Trigger;
 import net.pterodactylus.reactor.output.DefaultOutput;
@@ -48,7 +49,7 @@ public class FileStateModifiedTrigger implements Trigger {
         * {@inheritDoc}
         */
        @Override
-       public Output output() {
+       public Output output(Reaction reaction) {
                return new DefaultOutput("File modified").addText("text/plain", "File modified").addText("text/html", "<div>File modified</div>");
        }
 
index 19268e9..f97002a 100644 (file)
@@ -21,6 +21,7 @@ import static com.google.common.base.Preconditions.checkState;
 
 import java.util.List;
 
+import net.pterodactylus.reactor.Reaction;
 import net.pterodactylus.reactor.State;
 import net.pterodactylus.reactor.Trigger;
 import net.pterodactylus.reactor.output.DefaultOutput;
@@ -70,7 +71,7 @@ public class NewTorrentTrigger implements Trigger {
         * {@inheritDoc}
         */
        @Override
-       public Output output() {
+       public Output output(Reaction reaction) {
                DefaultOutput output = new DefaultOutput(String.format("Found %d new Torrent(s)!", torrentFiles.size()));
                output.addText("text/plain", getPlainTextList(torrentFiles));
                output.addText("text/html", getHtmlTextList(torrentFiles));