changeset 907:9ad946f81619

JobConfigurator
author Devel 2
date Wed, 18 Apr 2018 14:39:38 +0200
parents 3ea8aca2c6a9
children 5eb7806d3416
files stress-tester/src/main/java/com/passus/st/config/JobConfigurator.java
diffstat 1 files changed, 45 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/stress-tester/src/main/java/com/passus/st/config/JobConfigurator.java	Wed Apr 18 14:39:38 2018 +0200
@@ -0,0 +1,45 @@
+package com.passus.st.config;
+
+import com.passus.commons.Assert;
+import com.passus.config.Configuration;
+import com.passus.config.ConfigurationContext;
+import com.passus.config.validation.Errors;
+
+public abstract class JobConfigurator {
+
+    protected Configuration config;
+
+    public Errors init(Configuration config) {
+        Assert.notNull(config, "config");
+        this.config = config;
+        return null;
+    }
+
+    private void ensureConfigLoaded() {
+        if (config == null) {
+            throw new IllegalStateException("Configuration not loaded.");
+        }
+    }
+
+    public final Errors validate(ConfigurationContext context) {
+        ensureConfigLoaded();
+        return doValidate(context);
+    }
+
+    public abstract Errors doValidate(ConfigurationContext context);
+
+    public final Errors configure(ConfigurationContext context) {
+        ensureConfigLoaded();
+        return doConfigure(context);
+    }
+
+    public abstract Errors doConfigure(ConfigurationContext context);
+
+    public final void destroy(ConfigurationContext context) {
+        ensureConfigLoaded();
+        doDestroy(context);
+    }
+
+    public abstract void doDestroy(ConfigurationContext context);
+
+}