diff --git a/agent/pom.xml b/agent/pom.xml
index a1cff2027d..0d3c386718 100644
--- a/agent/pom.xml
+++ b/agent/pom.xml
@@ -129,6 +129,10 @@
com.fasterxml.jackson.datatype
jackson-datatype-jdk8
+
+ com.fasterxml.jackson.datatype
+ jackson-datatype-jsr310
+
com.google.code.findbugs
jsr305
diff --git a/agent/src/main/java/com/walmartlabs/concord/agent/Agent.java b/agent/src/main/java/com/walmartlabs/concord/agent/Agent.java
index cbf69159d1..c2c1e5c04f 100644
--- a/agent/src/main/java/com/walmartlabs/concord/agent/Agent.java
+++ b/agent/src/main/java/com/walmartlabs/concord/agent/Agent.java
@@ -37,18 +37,13 @@
import org.slf4j.LoggerFactory;
import javax.inject.Inject;
-import javax.inject.Named;
-import javax.inject.Singleton;
import java.io.IOException;
-import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.*;
import java.util.concurrent.atomic.AtomicBoolean;
-@Named
-@Singleton
public class Agent {
private static final Logger log = LoggerFactory.getLogger(Agent.class);
diff --git a/agent/src/main/java/com/walmartlabs/concord/agent/AgentModule.java b/agent/src/main/java/com/walmartlabs/concord/agent/AgentModule.java
new file mode 100644
index 0000000000..376083f01f
--- /dev/null
+++ b/agent/src/main/java/com/walmartlabs/concord/agent/AgentModule.java
@@ -0,0 +1,81 @@
+package com.walmartlabs.concord.agent;
+
+/*-
+ * *****
+ * Concord
+ * -----
+ * Copyright (C) 2017 - 2023 Walmart Inc.
+ * -----
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * =====
+ */
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.google.inject.Binder;
+import com.google.inject.Module;
+import com.typesafe.config.Config;
+import com.walmartlabs.concord.agent.cfg.*;
+import com.walmartlabs.concord.agent.executors.runner.DefaultDependencies;
+import com.walmartlabs.concord.agent.executors.runner.ProcessPool;
+import com.walmartlabs.concord.agent.remote.ApiClientFactory;
+import com.walmartlabs.concord.agent.remote.QueueClientProvider;
+import com.walmartlabs.concord.server.queueclient.QueueClient;
+import com.walmartlabs.ollie.config.ConfigurationProcessor;
+import com.walmartlabs.ollie.config.Environment;
+import com.walmartlabs.ollie.config.EnvironmentSelector;
+
+import javax.inject.Named;
+
+import static com.google.inject.Scopes.SINGLETON;
+
+@Named
+public class AgentModule implements Module {
+
+ private final Config config;
+
+ public AgentModule() {
+ this(loadDefaultConfig());
+ }
+
+ public AgentModule(Config config) {
+ this.config = config;
+ }
+
+ @Override
+ public void configure(Binder binder) {
+ binder.bind(ObjectMapper.class).toProvider(ObjectMapperProvider.class);
+ binder.bind(Config.class).toInstance(config);
+
+ binder.bind(AgentConfiguration.class).in(SINGLETON);
+ binder.bind(DockerConfiguration.class).in(SINGLETON);
+ binder.bind(GitConfiguration.class).in(SINGLETON);
+ binder.bind(ImportConfiguration.class).in(SINGLETON);
+ binder.bind(PreForkConfiguration.class).in(SINGLETON);
+ binder.bind(RepositoryCacheConfiguration.class).in(SINGLETON);
+ binder.bind(RunnerV1Configuration.class).in(SINGLETON);
+ binder.bind(RunnerV2Configuration.class).in(SINGLETON);
+ binder.bind(ServerConfiguration.class).in(SINGLETON);
+
+ binder.bind(DefaultDependencies.class).in(SINGLETON);
+ binder.bind(ProcessPool.class).in(SINGLETON);
+ binder.bind(ApiClientFactory.class).in(SINGLETON);
+ binder.bind(QueueClient.class).toProvider(QueueClientProvider.class).in(SINGLETON);
+
+ binder.bind(Agent.class).in(SINGLETON);
+ }
+
+ private static Config loadDefaultConfig() {
+ Environment env = new EnvironmentSelector().select();
+ return new ConfigurationProcessor("concord-agent", env, null, null).process();
+ }
+}
diff --git a/agent/src/main/java/com/walmartlabs/concord/agent/ObjectMapperProvider.java b/agent/src/main/java/com/walmartlabs/concord/agent/ObjectMapperProvider.java
index 857544fc15..e54760d6c1 100644
--- a/agent/src/main/java/com/walmartlabs/concord/agent/ObjectMapperProvider.java
+++ b/agent/src/main/java/com/walmartlabs/concord/agent/ObjectMapperProvider.java
@@ -20,18 +20,34 @@
* =====
*/
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.SerializationFeature;
+import com.fasterxml.jackson.datatype.guava.GuavaModule;
+import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
+import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
-import javax.inject.Named;
import javax.inject.Provider;
-import javax.inject.Singleton;
-@Named
-@Singleton
public class ObjectMapperProvider implements Provider {
@Override
public ObjectMapper get() {
- return new ObjectMapper();
+ ObjectMapper mapper = new ObjectMapper()
+ .registerModule(new Jdk8Module())
+ .registerModule(new GuavaModule())
+ .registerModule(new JavaTimeModule());
+
+ // Write dates as ISO-8601
+ mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
+
+ // Ignore unknown properties
+ mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
+
+ // Ignore nulls
+ mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
+
+ return mapper;
}
}
diff --git a/agent/src/main/java/com/walmartlabs/concord/agent/cfg/AgentConfiguration.java b/agent/src/main/java/com/walmartlabs/concord/agent/cfg/AgentConfiguration.java
index eadd5478fc..4c5c99a486 100644
--- a/agent/src/main/java/com/walmartlabs/concord/agent/cfg/AgentConfiguration.java
+++ b/agent/src/main/java/com/walmartlabs/concord/agent/cfg/AgentConfiguration.java
@@ -25,8 +25,6 @@
import org.slf4j.LoggerFactory;
import javax.inject.Inject;
-import javax.inject.Named;
-import javax.inject.Singleton;
import java.nio.file.Path;
import java.time.Duration;
import java.util.List;
@@ -37,8 +35,6 @@
import static com.walmartlabs.concord.agent.cfg.Utils.getOrCreatePath;
import static com.walmartlabs.concord.agent.cfg.Utils.getStringOrDefault;
-@Named
-@Singleton
public class AgentConfiguration {
private static final Logger log = LoggerFactory.getLogger(AgentConfiguration.class);
diff --git a/agent/src/main/java/com/walmartlabs/concord/agent/cfg/ConfigProvider.java b/agent/src/main/java/com/walmartlabs/concord/agent/cfg/ConfigProvider.java
deleted file mode 100644
index efa3b9947e..0000000000
--- a/agent/src/main/java/com/walmartlabs/concord/agent/cfg/ConfigProvider.java
+++ /dev/null
@@ -1,41 +0,0 @@
-package com.walmartlabs.concord.agent.cfg;
-
-/*-
- * *****
- * Concord
- * -----
- * Copyright (C) 2017 - 2019 Walmart Inc.
- * -----
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * =====
- */
-
-import com.typesafe.config.Config;
-import com.walmartlabs.ollie.config.ConfigurationProcessor;
-import com.walmartlabs.ollie.config.Environment;
-import com.walmartlabs.ollie.config.EnvironmentSelector;
-
-import javax.inject.Named;
-import javax.inject.Provider;
-import javax.inject.Singleton;
-
-@Named
-@Singleton
-public class ConfigProvider implements Provider {
-
- @Override
- public Config get() {
- Environment env = new EnvironmentSelector().select();
- return new ConfigurationProcessor("concord-agent", env).process();
- }
-}
diff --git a/agent/src/main/java/com/walmartlabs/concord/agent/cfg/DockerConfiguration.java b/agent/src/main/java/com/walmartlabs/concord/agent/cfg/DockerConfiguration.java
index 90fde7f7f9..da7bc9cca4 100644
--- a/agent/src/main/java/com/walmartlabs/concord/agent/cfg/DockerConfiguration.java
+++ b/agent/src/main/java/com/walmartlabs/concord/agent/cfg/DockerConfiguration.java
@@ -23,13 +23,9 @@
import com.typesafe.config.Config;
import javax.inject.Inject;
-import javax.inject.Named;
-import javax.inject.Singleton;
import java.util.List;
import java.util.concurrent.TimeUnit;
-@Named
-@Singleton
public class DockerConfiguration {
private final String dockerHost;
diff --git a/agent/src/main/java/com/walmartlabs/concord/agent/cfg/GitConfiguration.java b/agent/src/main/java/com/walmartlabs/concord/agent/cfg/GitConfiguration.java
index 6dcce8e6e4..85bdcab673 100644
--- a/agent/src/main/java/com/walmartlabs/concord/agent/cfg/GitConfiguration.java
+++ b/agent/src/main/java/com/walmartlabs/concord/agent/cfg/GitConfiguration.java
@@ -29,8 +29,6 @@
import static com.walmartlabs.concord.agent.cfg.Utils.getStringOrDefault;
-@Named
-@Singleton
public class GitConfiguration {
private final String token;
diff --git a/agent/src/main/java/com/walmartlabs/concord/agent/cfg/ImportConfiguration.java b/agent/src/main/java/com/walmartlabs/concord/agent/cfg/ImportConfiguration.java
index 7cde1f8ca7..f1f5756ba0 100644
--- a/agent/src/main/java/com/walmartlabs/concord/agent/cfg/ImportConfiguration.java
+++ b/agent/src/main/java/com/walmartlabs/concord/agent/cfg/ImportConfiguration.java
@@ -23,14 +23,10 @@
import com.typesafe.config.Config;
import javax.inject.Inject;
-import javax.inject.Named;
-import javax.inject.Singleton;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
-@Named
-@Singleton
public class ImportConfiguration {
private final Set disabledProcessors;
diff --git a/agent/src/main/java/com/walmartlabs/concord/agent/cfg/PreForkConfiguration.java b/agent/src/main/java/com/walmartlabs/concord/agent/cfg/PreForkConfiguration.java
index 68758b065c..de38930cee 100644
--- a/agent/src/main/java/com/walmartlabs/concord/agent/cfg/PreForkConfiguration.java
+++ b/agent/src/main/java/com/walmartlabs/concord/agent/cfg/PreForkConfiguration.java
@@ -23,12 +23,8 @@
import com.typesafe.config.Config;
import javax.inject.Inject;
-import javax.inject.Named;
-import javax.inject.Singleton;
import java.util.concurrent.TimeUnit;
-@Named
-@Singleton
public class PreForkConfiguration {
private final boolean enabled;
diff --git a/agent/src/main/java/com/walmartlabs/concord/agent/cfg/RepositoryCacheConfiguration.java b/agent/src/main/java/com/walmartlabs/concord/agent/cfg/RepositoryCacheConfiguration.java
index 81ef969da0..c1454e31a1 100644
--- a/agent/src/main/java/com/walmartlabs/concord/agent/cfg/RepositoryCacheConfiguration.java
+++ b/agent/src/main/java/com/walmartlabs/concord/agent/cfg/RepositoryCacheConfiguration.java
@@ -23,15 +23,11 @@
import com.typesafe.config.Config;
import javax.inject.Inject;
-import javax.inject.Named;
-import javax.inject.Singleton;
import java.nio.file.Path;
import java.time.Duration;
import static com.walmartlabs.concord.agent.cfg.Utils.getOrCreatePath;
-@Named
-@Singleton
public class RepositoryCacheConfiguration {
private final Path cacheDir;
diff --git a/agent/src/main/java/com/walmartlabs/concord/agent/cfg/RunnerV1Configuration.java b/agent/src/main/java/com/walmartlabs/concord/agent/cfg/RunnerV1Configuration.java
index 90246a638f..dc57172c37 100644
--- a/agent/src/main/java/com/walmartlabs/concord/agent/cfg/RunnerV1Configuration.java
+++ b/agent/src/main/java/com/walmartlabs/concord/agent/cfg/RunnerV1Configuration.java
@@ -23,11 +23,7 @@
import com.typesafe.config.Config;
import javax.inject.Inject;
-import javax.inject.Named;
-import javax.inject.Singleton;
-@Named
-@Singleton
public class RunnerV1Configuration extends AbstractRunnerConfiguration {
@Inject
diff --git a/agent/src/main/java/com/walmartlabs/concord/agent/cfg/RunnerV2Configuration.java b/agent/src/main/java/com/walmartlabs/concord/agent/cfg/RunnerV2Configuration.java
index 1f12aee1a6..8128b7dd67 100644
--- a/agent/src/main/java/com/walmartlabs/concord/agent/cfg/RunnerV2Configuration.java
+++ b/agent/src/main/java/com/walmartlabs/concord/agent/cfg/RunnerV2Configuration.java
@@ -23,11 +23,7 @@
import com.typesafe.config.Config;
import javax.inject.Inject;
-import javax.inject.Named;
-import javax.inject.Singleton;
-@Named
-@Singleton
public class RunnerV2Configuration extends AbstractRunnerConfiguration {
@Inject
diff --git a/agent/src/main/java/com/walmartlabs/concord/agent/cfg/ServerConfiguration.java b/agent/src/main/java/com/walmartlabs/concord/agent/cfg/ServerConfiguration.java
index eabe02609c..5e6bfb4523 100644
--- a/agent/src/main/java/com/walmartlabs/concord/agent/cfg/ServerConfiguration.java
+++ b/agent/src/main/java/com/walmartlabs/concord/agent/cfg/ServerConfiguration.java
@@ -25,14 +25,10 @@
import org.slf4j.LoggerFactory;
import javax.inject.Inject;
-import javax.inject.Named;
-import javax.inject.Singleton;
import java.util.concurrent.TimeUnit;
import static com.walmartlabs.concord.agent.cfg.Utils.getStringOrDefault;
-@Named
-@Singleton
public class ServerConfiguration {
private static final Logger log = LoggerFactory.getLogger(ServerConfiguration.class);
diff --git a/agent/src/main/java/com/walmartlabs/concord/agent/executors/runner/DefaultDependencies.java b/agent/src/main/java/com/walmartlabs/concord/agent/executors/runner/DefaultDependencies.java
index 70ad0e3387..4c5d88f5e2 100644
--- a/agent/src/main/java/com/walmartlabs/concord/agent/executors/runner/DefaultDependencies.java
+++ b/agent/src/main/java/com/walmartlabs/concord/agent/executors/runner/DefaultDependencies.java
@@ -23,8 +23,6 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import javax.inject.Named;
-import javax.inject.Singleton;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
@@ -37,8 +35,6 @@
import java.util.stream.Collectors;
import java.util.stream.Stream;
-@Named
-@Singleton
public class DefaultDependencies {
private static final Logger log = LoggerFactory.getLogger(DefaultDependencies.class);
diff --git a/agent/src/main/java/com/walmartlabs/concord/agent/executors/runner/ProcessPool.java b/agent/src/main/java/com/walmartlabs/concord/agent/executors/runner/ProcessPool.java
index a389be7e8d..54dd575a65 100644
--- a/agent/src/main/java/com/walmartlabs/concord/agent/executors/runner/ProcessPool.java
+++ b/agent/src/main/java/com/walmartlabs/concord/agent/executors/runner/ProcessPool.java
@@ -29,16 +29,12 @@
import org.slf4j.LoggerFactory;
import javax.inject.Inject;
-import javax.inject.Named;
-import javax.inject.Singleton;
import java.io.IOException;
import java.nio.file.Path;
import java.util.*;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
-@Named
-@Singleton
public class ProcessPool {
private static final Logger log = LoggerFactory.getLogger(ProcessPool.class);
diff --git a/agent/src/main/java/com/walmartlabs/concord/agent/remote/ApiClientFactory.java b/agent/src/main/java/com/walmartlabs/concord/agent/remote/ApiClientFactory.java
index 92e2fde99b..0b2403c212 100644
--- a/agent/src/main/java/com/walmartlabs/concord/agent/remote/ApiClientFactory.java
+++ b/agent/src/main/java/com/walmartlabs/concord/agent/remote/ApiClientFactory.java
@@ -30,8 +30,6 @@
import com.walmartlabs.concord.common.IOUtils;
import javax.inject.Inject;
-import javax.inject.Named;
-import javax.inject.Singleton;
import java.io.IOException;
import java.nio.file.Path;
import java.util.HashMap;
@@ -39,8 +37,6 @@
import java.util.Map;
import java.util.concurrent.TimeUnit;
-@Named
-@Singleton
public class ApiClientFactory {
private static final String SESSION_COOKIE_NAME = "JSESSIONID";
diff --git a/agent/src/main/java/com/walmartlabs/concord/agent/remote/QueueClientProvider.java b/agent/src/main/java/com/walmartlabs/concord/agent/remote/QueueClientProvider.java
index 789a565b8a..63f6945bd2 100644
--- a/agent/src/main/java/com/walmartlabs/concord/agent/remote/QueueClientProvider.java
+++ b/agent/src/main/java/com/walmartlabs/concord/agent/remote/QueueClientProvider.java
@@ -26,13 +26,9 @@
import com.walmartlabs.concord.server.queueclient.QueueClientConfiguration;
import javax.inject.Inject;
-import javax.inject.Named;
import javax.inject.Provider;
-import javax.inject.Singleton;
import java.net.URISyntaxException;
-@Named
-@Singleton
public class QueueClientProvider implements Provider {
private final AgentConfiguration agentCfg;