Skip to content

Commit

Permalink
Update of plc4x version to 0.11.0-connectorio-2.
Browse files Browse the repository at this point in the history
A default constructor for OsgiDriverManager which might help with unit tests.

Signed-off-by: Łukasz Dywicki <luke@code-house.org>
  • Loading branch information
splatch committed Nov 1, 2023
1 parent 8af0f92 commit f0f9b7e
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,12 @@

import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import org.apache.plc4x.java.DefaultPlcDriverManager;
import org.apache.plc4x.java.api.PlcConnectionManager;
import org.apache.plc4x.java.api.PlcDriver;
import org.apache.plc4x.java.api.exceptions.PlcConnectionException;
Expand All @@ -35,6 +38,10 @@ public class OsgiDriverManager implements PlcDriverManager {
private final PlcConnectionManager connectionManager;
private final List<PlcDriver> drivers;

public OsgiDriverManager() {
this(lookup());
}

public OsgiDriverManager(List<PlcDriver> drivers) {
this.connectionManager = new OsgiConnectionManager(this);
this.drivers = drivers;
Expand Down Expand Up @@ -78,4 +85,17 @@ public PlcDriver getDriver(String url) throws PlcConnectionException {
void close() {
}

private static List<PlcDriver> lookup() {
DefaultPlcDriverManager driverManager = new DefaultPlcDriverManager();
List<PlcDriver> drivers = new ArrayList<>();
for (String driver : driverManager.listDrivers()) {
try {
drivers.add(driverManager.getDriver(driver));
} catch (PlcConnectionException e) {
throw new RuntimeException(e);
}
}
return drivers;
}

}
7 changes: 6 additions & 1 deletion parent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
<description>Parent for ConnectorIO supplied extensions to Apache PLC4X.</description>

<properties>
<plc4x.version>0.11.0-connectorio-1</plc4x.version>
<plc4x.version>0.11.0-connectorio-2</plc4x.version>
<karaf.version>4.3.9</karaf.version>

<bucket4j.version>8.3.0</bucket4j.version>
Expand Down Expand Up @@ -137,6 +137,11 @@
<artifactId>plc4j-driver-ads</artifactId>
<version>${plc4x.version}</version>
</dependency>
<dependency>
<groupId>org.apache.plc4x</groupId>
<artifactId>plc4j-driver-can</artifactId>
<version>${plc4x.version}</version>
</dependency>
<dependency>
<groupId>org.apache.plc4x</groupId>
<artifactId>plc4j-driver-canopen</artifactId>
Expand Down

0 comments on commit f0f9b7e

Please sign in to comment.