diff --git a/camel/pom.xml b/camel/pom.xml
index 4996590..048dd98 100644
--- a/camel/pom.xml
+++ b/camel/pom.xml
@@ -94,11 +94,6 @@
camel-jt400
3.14.7
-
- com.ibm.watson
- language-translator
- 10.1.0
-
org.apache.camel
camel-jackson
@@ -127,6 +122,12 @@
0.0.3
+
+ io.github.theprez
+ dotenv-java-ibmi
+ 0.0.1
+
+
org.apache.logging.log4j
@@ -190,29 +191,29 @@
maven-replacer-plugin
1.4.0
-
- process-sources
-
- replace
-
-
+
+ process-sources
+
+ replace
+
+
- Version.java.tpl
- src/main/java/com/github/theprez/manzan/Version.java
-
-
- @version@
- ${manzan.version}
-
-
-
- @timestamp@
- ${maven.build.timestamp}
-
-
+ Version.java.tpl
+ src/main/java/com/github/theprez/manzan/Version.java
+
+
+ @version@
+ ${manzan.version}
+
+
+
+ @timestamp@
+ ${maven.build.timestamp}
+
+
-
+
org.codehaus.mojo
diff --git a/camel/src/main/java/com/github/theprez/manzan/IBMiConnectionSupplier.java b/camel/src/main/java/com/github/theprez/manzan/IBMiConnectionSupplier.java
deleted file mode 100644
index 1f797da..0000000
--- a/camel/src/main/java/com/github/theprez/manzan/IBMiConnectionSupplier.java
+++ /dev/null
@@ -1,27 +0,0 @@
-package com.github.theprez.manzan;
-
-import java.io.IOException;
-
-import com.github.theprez.manzan.configuration.ApplicationConfig;
-import com.ibm.as400.access.AS400;
-import com.ibm.as400.access.AS400SecurityException;
-
-public class IBMiConnectionSupplier {
- private static boolean s_isIBMi = checkIsIBMi();
-
- private static boolean checkIsIBMi() {
- final String osName = System.getProperty("os.name", "Misty");
- return "os400".equalsIgnoreCase(osName) || "os/400".equalsIgnoreCase(osName);
- }
-
- public static AS400 getSystemConnection() throws IOException, AS400SecurityException {
- if (s_isIBMi) {
- return new AS400("localhost", "*CURRENT", "*CURRENT");
- }
- return ApplicationConfig.get().getRemoteConnection();
- }
-
- public static boolean isIBMi() {
- return s_isIBMi;
- }
-}
diff --git a/camel/src/main/java/com/github/theprez/manzan/ManzanMainApp.java b/camel/src/main/java/com/github/theprez/manzan/ManzanMainApp.java
index 80c5c18..f300416 100644
--- a/camel/src/main/java/com/github/theprez/manzan/ManzanMainApp.java
+++ b/camel/src/main/java/com/github/theprez/manzan/ManzanMainApp.java
@@ -19,6 +19,8 @@
import com.ibm.as400.access.CommandCall;
import com.ibm.as400.access.Job;
+import io.github.theprez.dotenv_ibmi.IBMiDotEnv;
+
/**
* A Camel Application that routes messages from an IBM i message queue to
* email.
@@ -35,7 +37,7 @@ public static void main(final String... _args) throws Exception {
final CamelContext context = new DefaultCamelContext();
System.out.println("Apache Camel version " + context.getVersion());
- final AS400 as400 = IBMiConnectionSupplier.getSystemConnection();
+ final AS400 as400 = IBMiDotEnv.getCachedSystemConnection(true);
as400.setGuiAvailable(false);
as400.validateSignon();
final AS400JDBCDataSource dataSource = new AS400JDBCDataSource(as400);
@@ -85,7 +87,7 @@ private static void printVersionInfo() {
System.exit(-1);
}
try {
- AS400 as400 = IBMiConnectionSupplier.getSystemConnection();
+ AS400 as400 = IBMiDotEnv.getCachedSystemConnection(true);
CommandCall cmd = new CommandCall(as400,
"CALL PGM(" + library.trim() + "/handler) PARM('*VERSION' '*VERSION')");
diff --git a/camel/src/main/java/com/github/theprez/manzan/WatchStarter.java b/camel/src/main/java/com/github/theprez/manzan/WatchStarter.java
index 2d57853..42f8bed 100644
--- a/camel/src/main/java/com/github/theprez/manzan/WatchStarter.java
+++ b/camel/src/main/java/com/github/theprez/manzan/WatchStarter.java
@@ -19,6 +19,8 @@
import com.ibm.as400.access.ProgramCall;
import com.ibm.as400.access.ProgramParameter;
+import io.github.theprez.dotenv_ibmi.IBMiDotEnv;
+
public class WatchStarter {
private final String m_command;
private final String m_stopCommand;
@@ -68,7 +70,7 @@ public void strwch()
public boolean isRunning()
throws AS400SecurityException, ErrorCompletingRequestException, IOException, InterruptedException,
PropertyVetoException, ObjectDoesNotExistException {
- AS400 as400 = IBMiConnectionSupplier.getSystemConnection();
+ AS400 as400 = IBMiDotEnv.getNewSystemConnection(true);
ProgramCall pc = new ProgramCall(as400);
final ProgramCall program = new ProgramCall(as400);
@@ -104,7 +106,7 @@ public boolean isRunning()
private static void runCmd(final String _command)
throws AS400SecurityException, ErrorCompletingRequestException, IOException, InterruptedException {
- AS400 as400 = IBMiConnectionSupplier.getSystemConnection();
+ AS400 as400 = IBMiDotEnv.getNewSystemConnection(true);
CommandCall cmd = new CommandCall(as400, _command);
boolean isSuccess = cmd.run();
diff --git a/camel/src/main/java/com/github/theprez/manzan/configuration/Config.java b/camel/src/main/java/com/github/theprez/manzan/configuration/Config.java
index 9f8492a..9a4f15f 100644
--- a/camel/src/main/java/com/github/theprez/manzan/configuration/Config.java
+++ b/camel/src/main/java/com/github/theprez/manzan/configuration/Config.java
@@ -7,12 +7,16 @@
import org.ini4j.InvalidFileFormatException;
import com.github.theprez.jcmdutils.StringUtils;
-import com.github.theprez.manzan.IBMiConnectionSupplier;
public abstract class Config {
+
+ protected static boolean isIBMi() {
+ final String osName = System.getProperty("os.name", "Misty");
+ return "os400".equalsIgnoreCase(osName) || "os/400".equalsIgnoreCase(osName);
+ }
protected static File getConfigFile(final String _name) throws IOException {
- final File configDir = IBMiConnectionSupplier.isIBMi() ? new File("/QOpenSys/etc/manzan") : new File(".").getAbsoluteFile();
+ final File configDir = isIBMi() ? new File("/QOpenSys/etc/manzan") : new File(".").getAbsoluteFile();
if (!configDir.isDirectory()) {
if (!configDir.mkdirs()) {
throw new IOException("Cound not create configuration directory " + configDir.getAbsolutePath());