Set update interval on all created reactions.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 11 Jan 2013 10:18:59 +0000 (11:18 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 11 Jan 2013 10:18:59 +0000 (11:18 +0100)
src/main/java/net/pterodactylus/rhynodge/loader/ReactionLoader.java

index 100e42f..10608d9 100644 (file)
@@ -56,28 +56,40 @@ public class ReactionLoader {
                        throw new IllegalArgumentException("Chain is not enabled.");
                }
 
+               Reaction reaction;
+
                /* create action. */
                Action action = createObject(chain.action().name(), "net.pterodactylus.rhynodge.actions", extractParameters(chain.action().parameters()));
 
                /* do we have a reaction defined? */
                if (chain.watcher() != null) {
+
+                       /* create watcher. */
                        Watcher watcher = createObject(chain.watcher().name(), "net.pterodactylus.rhynodge.watchers", extractParameters(chain.watcher().parameters()));
-                       return new Reaction(chain.name(), watcher.query(), watcher.filters(), watcher.trigger(), action);
-               }
 
-               /* create query. */
-               Query query = createObject(chain.query().name(), "net.pterodactylus.rhynodge.queries", extractParameters(chain.query().parameters()));
+                       /* create reaction. */
+                       reaction = new Reaction(chain.name(), watcher.query(), watcher.filters(), watcher.trigger(), action);
 
-               /* create filters. */
-               List<Filter> filters = new ArrayList<Filter>();
-               for (Part filterPart : chain.filters()) {
-                       filters.add(ReactionLoader.<Filter> createObject(filterPart.name(), "net.pterodactylus.rhynodge.filters", extractParameters(filterPart.parameters())));
-               }
+               } else {
+
+                       /* create query. */
+                       Query query = createObject(chain.query().name(), "net.pterodactylus.rhynodge.queries", extractParameters(chain.query().parameters()));
 
-               /* create trigger. */
-               Trigger trigger = createObject(chain.trigger().name(), "net.pterodactylus.rhynodge.triggers", extractParameters(chain.trigger().parameters()));
+                       /* create filters. */
+                       List<Filter> filters = new ArrayList<Filter>();
+                       for (Part filterPart : chain.filters()) {
+                               filters.add(ReactionLoader.<Filter> createObject(filterPart.name(), "net.pterodactylus.rhynodge.filters", extractParameters(filterPart.parameters())));
+                       }
+
+                       /* create trigger. */
+                       Trigger trigger = createObject(chain.trigger().name(), "net.pterodactylus.rhynodge.triggers", extractParameters(chain.trigger().parameters()));
+
+                       /* create reaction. */
+                       reaction = new Reaction(chain.name(), query, filters, trigger, action);
+               }
 
-               return new Reaction(chain.name(), query, filters, trigger, action).setUpdateInterval(TimeUnit.SECONDS.toMillis(chain.updateInterval()));
+               reaction.setUpdateInterval(TimeUnit.SECONDS.toMillis(chain.updateInterval()));
+               return reaction;
        }
 
        //