java 12 changes

Changes used to compile on java 12. Should be changed to a maven profile to allow selecting java 8 or higher... but appears to work. I do see some Illegal reflective access
warnings that appear harmless, for instance: Illegal reflective access by org.apache.ws.commons.schema.utils.DOMUtil
This commit is contained in:
bhlowe
2019-07-10 09:35:37 -07:00
parent ff9839c099
commit 67a68f2ffc
6 changed files with 87 additions and 10 deletions

3
.gitignore vendored
View File

@@ -16,6 +16,9 @@ bin/**
*.swp
*.swo
.idea/**
.idea
local.properties
.classpath
.settings/

View File

@@ -56,6 +56,36 @@
<version>3.4</version>
</dependency>
<!-- Java 9+ javax dependencies -->
<dependency>
<groupId>com.sun.activation</groupId>
<artifactId>javax.activation</artifactId>
<version>${javax.activation.version}</version>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>${jaxb.api.version}</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-core</artifactId>
<version>${jaxb.api.version}</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>${jaxb.api.version}</version>
</dependency>
</dependencies>
</project>

View File

@@ -117,7 +117,7 @@ public class OnvifDevice {
Socket socket = null;
try {
SocketAddress sockaddr = new InetSocketAddress(ip, new Integer(port));
SocketAddress sockaddr = new InetSocketAddress(ip, Integer.parseInt(port));
socket = new Socket();
socket.connect(sockaddr, 5000);

View File

@@ -1,21 +1,22 @@
package org.onvif.client;
import de.onvif.soap.OnvifDevice;
import org.apache.commons.io.FileUtils;
import org.onvif.ver10.schema.MediaUri;
import org.onvif.ver10.schema.PTZPreset;
import org.onvif.ver20.ptz.wsdl.PTZ;
import javax.xml.soap.SOAPException;
import java.io.File;
import java.io.FileInputStream;
import java.net.ConnectException;
import java.net.URL;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Properties;
import javax.xml.soap.SOAPException;
import org.apache.commons.io.FileUtils;
import org.onvif.ver10.schema.MediaUri;
import de.onvif.soap.OnvifDevice;
public class SimpleTest {
// This test reads connection params from a properties file and take a
@@ -25,7 +26,11 @@ public class SimpleTest {
final Map<String, String> onvifCamerasTokens = new HashMap<>();
final String propFileRelativePath = "src/test/resources/onvif.properties";
final Properties config = new Properties();
config.load(new FileInputStream(new File(propFileRelativePath)));
final File f = new File(propFileRelativePath);
if (!f.exists()) throw new Exception("fnf: "+f.getAbsolutePath());
javax.jws.WebService foo=null;
config.load(new FileInputStream(f));
String firstCamId = null;
for (Entry<Object, Object> entry : config.entrySet()) {
String deviceName = (String) entry.getKey();
@@ -60,6 +65,18 @@ public class SimpleTest {
MediaUri sceenshotUri = firstCam.getMedia().getSnapshotUri(profileToken);
File tempFile = File.createTempFile("tmp", ".jpg");
FileUtils.copyURLToFile(new URL(sceenshotUri.getUri()), tempFile);
System.out.println("snapshot: "+tempFile.getAbsolutePath()+" length:"+tempFile.length());
PTZ ptz = firstCam.getPtz();
if (ptz!=null)
{
List<PTZPreset> presets = ptz.getPresets(profileToken);
if (presets!=null && !presets.isEmpty())
{
System.out.println("Found "+presets.size()+" presets");
}
}
}

View File

@@ -24,6 +24,22 @@
<artifactId>cxf-rt-transports-http-jetty</artifactId>
<version>${cxf.version}</version>
</dependency>
<!-- BHL -->
<dependency>
<groupId>javax.xml.ws</groupId>
<artifactId>jaxws-api</artifactId>
<version>2.3.1</version>
</dependency>
<dependency>
<groupId>javax.jws</groupId>
<artifactId>javax.jws-api</artifactId>
<version>1.1</version>
</dependency>
<!-- <dependency> -->
<!-- <groupId>org.apache.cxf</groupId> -->
<!-- <artifactId>cxf-rt-ws-addr</artifactId> -->

13
pom.xml
View File

@@ -7,10 +7,18 @@
<packaging>pom</packaging>
<properties>
<java.version>1.8</java.version>
<java.version>1.12</java.version>
<cxf.version>3.1.10</cxf.version>
<javax.activation.version>1.2.0</javax.activation.version>
<jaxb.api.version>2.3.0</jaxb.api.version> <!-- 2.3.0, 2.3.1 or 2.4.0-b180830.0359 -->
</properties>
<modules>
<module>onvif-ws-client</module>
<module>onvif-java</module>
@@ -29,4 +37,7 @@
</plugin>
</plugins>
</build>
</project>