Changeset 9 for profileconnection
- Timestamp:
- 11/28/19 14:40:48 (5 years ago)
- Location:
- profileconnection
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
profileconnection/pom.xml
r6 r9 6 6 <groupId>geniusweb</groupId> 7 7 <artifactId>profileconnection</artifactId> 8 <version>1. 0.0</version>8 <version>1.1.0</version> 9 9 <packaging>jar</packaging> 10 10 … … 16 16 <basedir>.</basedir> 17 17 <passwd>${env.ARTIFACTORY_PASS}</passwd> 18 <jackson-2-version>2.9. 6</jackson-2-version>18 <jackson-2-version>2.9.10</jackson-2-version> 19 19 </properties> 20 20 … … 31 31 <groupId>geniusweb</groupId> 32 32 <artifactId>profile</artifactId> 33 <version>1. 0.0</version>33 <version>1.1.0</version> 34 34 </dependency> 35 35 -
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.