Fixed issues when deployed in a diffeerent (non-jar) container.

This commit is contained in:
nathan 2016-03-13 20:43:27 +01:00
parent b1d4d1fc77
commit a7a3fa6091
6 changed files with 105 additions and 123 deletions

View File

@ -91,7 +91,7 @@ This project is **kept in sync** with the utilities library, so "jar hell" is no
<dependency> <dependency>
<groupId>com.dorkbox</groupId> <groupId>com.dorkbox</groupId>
<artifactId>Network</artifactId> <artifactId>Network</artifactId>
<version>1.6</version> <version>1.8</version>
</dependency> </dependency>
``` ```

View File

@ -22,7 +22,6 @@ import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.lang.reflect.Method;
import java.math.BigInteger; import java.math.BigInteger;
import java.net.InetAddress; import java.net.InetAddress;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
@ -143,23 +142,7 @@ class SocketUDT {
* @throws RuntimeException * @throws RuntimeException
*/ */
static { static {
boolean isNativeDeployed = false; // we are either from a jar or as source
try {
Class<?> exitClass = Class.forName("dorkbox.exit.Exit");
if (exitClass != null) {
Method nativeMethod = exitClass.getMethod("isNative");
Object invoke = nativeMethod.invoke(null);
if (invoke != null) {
isNativeDeployed = (Boolean) invoke;
}
}
} catch (Throwable t) {
}
// if we are natively deployed, we automatically load the native libraries as part of the startup procedure
// if we are not, we are either from a jar or as source
if (!isNativeDeployed) {
ProtectionDomain pDomain = SocketUDT.class.getProtectionDomain(); ProtectionDomain pDomain = SocketUDT.class.getProtectionDomain();
CodeSource cSource = pDomain.getCodeSource(); CodeSource cSource = pDomain.getCodeSource();
@ -167,13 +150,13 @@ class SocketUDT {
// jar:/X:/workspace/XYZ/jarname.jar when it's jar // jar:/X:/workspace/XYZ/jarname.jar when it's jar
URL loc = cSource.getLocation(); URL loc = cSource.getLocation();
final String path = loc.getPath(); final String path = loc.getPath();
final boolean isJar = path.endsWith(".jar"); final boolean isContainer = path.endsWith(".jar") || path.endsWith(".box");
final OsType os = OS.get(); final OsType os = OS.get();
String osName = os.getName(); String osName = os.getName();
boolean loaded = false; boolean loaded = false;
if (isJar) { if (isContainer) {
// have to extract our correct file to temp then load it, ONLY if we are not already loaded! // have to extract our correct file to temp then load it, ONLY if we are not already loaded!
try { try {
@ -287,7 +270,6 @@ class SocketUDT {
log.error("Failed to load UDT native library"); log.error("Failed to load UDT native library");
throw new RuntimeException("Failed to load UDT native library"); throw new RuntimeException("Failed to load UDT native library");
} }
}
try { try {
initClass0(); initClass0();

View File

@ -48,7 +48,7 @@ class Broadcast {
*/ */
public static public static
String getVersion() { String getVersion() {
return "1.6"; return "1.8";
} }
/** /**

View File

@ -66,7 +66,7 @@ class Client<C extends Connection> extends EndPointClient<C> implements Connecti
*/ */
public static public static
String getVersion() { String getVersion() {
return "1.6"; return "1.8";
} }
/** /**

View File

@ -104,7 +104,7 @@ class DnsClient {
*/ */
public static public static
String getVersion() { String getVersion() {
return "1.6"; return "1.8";
} }
/** /**

View File

@ -63,7 +63,7 @@ class Server<C extends Connection> extends EndPointServer<C> {
*/ */
public static public static
String getVersion() { String getVersion() {
return "1.6"; return "1.8";
} }
/** /**