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>
<groupId>com.dorkbox</groupId>
<artifactId>Network</artifactId>
<version>1.6</version>
<version>1.8</version>
</dependency>
```

View File

@ -22,7 +22,6 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.Method;
import java.math.BigInteger;
import java.net.InetAddress;
import java.net.InetSocketAddress;
@ -143,23 +142,7 @@ class SocketUDT {
* @throws RuntimeException
*/
static {
boolean isNativeDeployed = false;
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) {
// we are either from a jar or as source
ProtectionDomain pDomain = SocketUDT.class.getProtectionDomain();
CodeSource cSource = pDomain.getCodeSource();
@ -167,13 +150,13 @@ class SocketUDT {
// jar:/X:/workspace/XYZ/jarname.jar when it's jar
URL loc = cSource.getLocation();
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();
String osName = os.getName();
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!
try {
@ -287,7 +270,6 @@ class SocketUDT {
log.error("Failed to load UDT native library");
throw new RuntimeException("Failed to load UDT native library");
}
}
try {
initClass0();

View File

@ -48,7 +48,7 @@ class Broadcast {
*/
public static
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
String getVersion() {
return "1.6";
return "1.8";
}
/**

View File

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

View File

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