From b0f85ed76eb644a6dcca5bd5ab6dd0a4a4af823c Mon Sep 17 00:00:00 2001 From: Robert von Burg Date: Tue, 18 Dec 2018 14:32:12 +0100 Subject: [PATCH] [New] Added simple constructor for StrolchJob --- .../main/java/li/strolch/job/StrolchJob.java | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/li.strolch.agent/src/main/java/li/strolch/job/StrolchJob.java b/li.strolch.agent/src/main/java/li/strolch/job/StrolchJob.java index ad4fabb90..3a0d9b6b8 100644 --- a/li.strolch.agent/src/main/java/li/strolch/job/StrolchJob.java +++ b/li.strolch.agent/src/main/java/li/strolch/job/StrolchJob.java @@ -60,6 +60,18 @@ public abstract class StrolchJob implements Runnable { private ZonedDateTime lastExecution; private Exception lastException; + public StrolchJob(StrolchAgent agent) { + this.agent = agent; + this.mode = JobMode.Manual; + + this.initialDelay = 0; + this.initialDelayTimeUnit = TimeUnit.SECONDS; + this.delay = 0; + this.delayTimeUnit = TimeUnit.SECONDS; + + this.first = true; + } + public StrolchJob(StrolchAgent agent, JobMode jobMode, long initialDelay, TimeUnit initialDelayTimeUnit, long delay, TimeUnit delayTimeUnit) { this.agent = agent; @@ -134,8 +146,10 @@ public abstract class StrolchJob implements Runnable { * * @throws PrivilegeException * if the agent can not perform the action + * @throws Exception + * if anything else goes wrong during execution */ - protected void runAsAgent(PrivilegedRunnable runnable) throws PrivilegeException { + protected void runAsAgent(PrivilegedRunnable runnable) throws PrivilegeException, Exception { getContainer().getPrivilegeHandler().runAsAgent(runnable); } @@ -279,7 +293,7 @@ public abstract class StrolchJob implements Runnable { return this; } - protected abstract void execute(PrivilegeContext ctx); + protected abstract void execute(PrivilegeContext ctx) throws Exception; public JsonObject toJson() { JsonObject jsonObject = new JsonObject();