Changeset 9 for profileconnection/src/main/java/geniusweb
- Timestamp:
- 11/28/19 14:40:48 (5 years ago)
- Location:
- profileconnection/src/main/java/geniusweb/profileconnection
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
profileconnection/src/main/java/geniusweb/profileconnection/FileProfileConnector.java
r2 r9 10 10 11 11 import geniusweb.profile.Profile; 12 import tudelft.utilities.listener.DefaultListenable; 12 13 13 14 /** 14 15 * ProfileInterface based on a plain filesystem UTF8 file. 15 16 */ 16 public class FileProfileConnector implements ProfileInterface { 17 public class FileProfileConnector extends DefaultListenable<Profile> 18 implements ProfileInterface { 17 19 private final static ObjectMapper jackson = new ObjectMapper(); 18 20 private final Profile profile; … … 25 27 public FileProfileConnector(String filename) throws IOException { 26 28 Path path = new File(filename).toPath(); 27 String serialized = new String(Files.readAllBytes(path), StandardCharsets.UTF_8); 29 String serialized = new String(Files.readAllBytes(path), 30 StandardCharsets.UTF_8); 28 31 profile = jackson.readValue(serialized, Profile.class); 29 32 } -
profileconnection/src/main/java/geniusweb/profileconnection/ProfileInterface.java
r1 r9 2 2 3 3 import geniusweb.profile.Profile; 4 import tudelft.utilities.listener.Listenable; 4 5 5 6 /** 6 7 * A container holding a modifyable profile. This interface allows testing. 7 8 */ 8 public interface ProfileInterface {9 public interface ProfileInterface extends Listenable<Profile> { 9 10 10 11 /** -
profileconnection/src/main/java/geniusweb/profileconnection/WebsocketProfileConnector.java
r1 r9 15 15 16 16 import geniusweb.profile.Profile; 17 import tudelft.utilities.listener.DefaultListenable; 17 18 import tudelft.utilities.logging.Reporter; 18 19 … … 21 22 */ 22 23 @ClientEndpoint 23 public class WebsocketProfileConnector implements ProfileInterface { 24 public class WebsocketProfileConnector extends DefaultListenable<Profile> 25 implements ProfileInterface { 24 26 private final static ObjectMapper jackson = new ObjectMapper(); 25 27 private static final int TIMEOUT_MS = 2000; … … 56 58 // this will be called every time the profile changes. 57 59 logger.log(Level.FINE, "Received profile: " + message); 58 this.profile = jackson.readValue(message, Profile.class); 60 profile = jackson.readValue(message, Profile.class); 61 notifyListeners(profile); 59 62 } 60 63
Note:
See TracChangeset
for help on using the changeset viewer.