diff --git a/nbproject/project.properties b/nbproject/project.properties index 8976072..35adc9e 100644 --- a/nbproject/project.properties +++ b/nbproject/project.properties @@ -39,8 +39,8 @@ javac.compilerargs= javac.deprecation=false javac.processorpath=\ ${javac.classpath} -javac.source=1.7 -javac.target=1.7 +javac.source=1.8 +javac.target=1.8 javac.test.classpath=\ ${javac.classpath}:\ ${build.classes.dir} diff --git a/src/kademlia/Kademlia.java b/src/kademlia/Kademlia.java index d9b2856..859a88c 100644 --- a/src/kademlia/Kademlia.java +++ b/src/kademlia/Kademlia.java @@ -61,7 +61,7 @@ public class Kademlia private final transient DHT dht; private final transient Timer timer; private final int udpPort; - private KadConfiguration config; + private transient KadConfiguration config; /* Factories */ private final transient MessageFactory messageFactory; @@ -123,7 +123,8 @@ public class Kademlia public Kademlia(String ownerId, NodeId defaultId, int udpPort) throws IOException { - this(ownerId, new Node(defaultId, InetAddress.getLocalHost(), udpPort), udpPort, new DHT(ownerId, new DefaultConfiguration()), new DefaultConfiguration()); + this(ownerId, new Node(defaultId, InetAddress.getLocalHost(), udpPort), udpPort, + new DHT(ownerId, new DefaultConfiguration()), new DefaultConfiguration()); } /** @@ -185,7 +186,7 @@ public class Kademlia din = new DataInputStream(new FileInputStream(getStateStorageFolderName(ownerId, iconfig) + File.separator + "dht.kns")); DHT idht = new JsonDHTSerializer().read(din); - return new Kademlia(ownerId, inode, ikad.getPort(), idht, ikad.getCurrentConfiguration()); + return new Kademlia(ownerId, inode, ikad.getPort(), idht, iconfig); } /** diff --git a/src/kademlia/core/DefaultConfiguration.java b/src/kademlia/core/DefaultConfiguration.java index f244c05..7cbfad4 100644 --- a/src/kademlia/core/DefaultConfiguration.java +++ b/src/kademlia/core/DefaultConfiguration.java @@ -19,6 +19,14 @@ public class DefaultConfiguration implements KadConfiguration private final static int STALE = 1; private final static String LOCAL_FOLDER = "kademlia"; + /** + * Default constructor to support Gson Serialization + */ + public DefaultConfiguration() + { + + } + @Override public long restoreInterval() { diff --git a/src/kademlia/core/KadConfiguration.java b/src/kademlia/core/KadConfiguration.java index d02b63c..99a305f 100644 --- a/src/kademlia/core/KadConfiguration.java +++ b/src/kademlia/core/KadConfiguration.java @@ -8,7 +8,7 @@ package kademlia.core; */ public interface KadConfiguration { - + /** * @return Interval in milliseconds between execution of RestoreOperations. */ diff --git a/src/kademlia/core/KadServer.java b/src/kademlia/core/KadServer.java index 0935ad9..2da0282 100644 --- a/src/kademlia/core/KadServer.java +++ b/src/kademlia/core/KadServer.java @@ -31,7 +31,7 @@ public class KadServer private static final int DATAGRAM_BUFFER_SIZE = 64 * 1024; // 64KB /* Basic Kad Objects */ - private final KadConfiguration config; + private final transient KadConfiguration config; /* Server Objects */ private final int udpPort; diff --git a/src/kademlia/dht/DHT.java b/src/kademlia/dht/DHT.java index f30780c..ccb10d6 100644 --- a/src/kademlia/dht/DHT.java +++ b/src/kademlia/dht/DHT.java @@ -9,7 +9,6 @@ import java.io.FileOutputStream; import java.io.IOException; import java.util.List; import java.util.NoSuchElementException; -import kademlia.core.DefaultConfiguration; import kademlia.core.GetParameter; import kademlia.core.KadConfiguration; import kademlia.exceptions.ContentExistException; @@ -27,8 +26,8 @@ public class DHT { private transient StorageEntryManager entriesManager; - private transient final JsonSerializer contentSerializer; - private final KadConfiguration config; + private final transient JsonSerializer contentSerializer; + private final transient KadConfiguration config; private final String ownerId;