From 586ba9394f2ca5206c03181fa0b16f974352d96e Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Fri, 11 Jan 2013 11:18:59 +0100 Subject: [PATCH] Set update interval on all created reactions. --- .../rhynodge/loader/ReactionLoader.java | 36 ++++++++++++++-------- 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/src/main/java/net/pterodactylus/rhynodge/loader/ReactionLoader.java b/src/main/java/net/pterodactylus/rhynodge/loader/ReactionLoader.java index 100e42f..10608d9 100644 --- a/src/main/java/net/pterodactylus/rhynodge/loader/ReactionLoader.java +++ b/src/main/java/net/pterodactylus/rhynodge/loader/ReactionLoader.java @@ -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 filters = new ArrayList(); - for (Part filterPart : chain.filters()) { - filters.add(ReactionLoader. 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 filters = new ArrayList(); + for (Part filterPart : chain.filters()) { + filters.add(ReactionLoader. 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; } // -- 2.7.4