Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to use IBMiDotEnv package to get system connections #108

Merged
merged 1 commit into from
Jun 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 26 additions & 25 deletions camel/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,6 @@
<artifactId>camel-jt400</artifactId>
<version>3.14.7</version>
</dependency>
<dependency>
<groupId>com.ibm.watson</groupId>
<artifactId>language-translator</artifactId>
<version>10.1.0</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-jackson</artifactId>
Expand Down Expand Up @@ -127,6 +122,12 @@
<version>0.0.3</version>
</dependency>

<dependency>
<groupId>io.github.theprez</groupId>
<artifactId>dotenv-java-ibmi</artifactId>
<version>0.0.1</version>
</dependency>

<!-- logging -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
Expand Down Expand Up @@ -190,29 +191,29 @@
<artifactId>maven-replacer-plugin</artifactId>
<version>1.4.0</version>
<executions>
<execution>
<phase>process-sources</phase>
<goals>
<goal>replace</goal>
</goals>
</execution>
<execution>
<phase>process-sources</phase>
<goals>
<goal>replace</goal>
</goals>
</execution>
</executions>
<configuration>
<file>Version.java.tpl</file>
<outputFile>src/main/java/com/github/theprez/manzan/Version.java</outputFile>
<replacements>
<replacement>
<token>@version@</token>
<value>${manzan.version}</value>
</replacement>

<replacement>
<token>@timestamp@</token>
<value>${maven.build.timestamp}</value>
</replacement>
</replacements>
<file>Version.java.tpl</file>
<outputFile>src/main/java/com/github/theprez/manzan/Version.java</outputFile>
<replacements>
<replacement>
<token>@version@</token>
<value>${manzan.version}</value>
</replacement>

<replacement>
<token>@timestamp@</token>
<value>${maven.build.timestamp}</value>
</replacement>
</replacements>
</configuration>
</plugin>
</plugin>
<!-- Allows the example to be run via 'mvn compile exec:java' -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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);
Expand Down Expand Up @@ -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')");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down