[vlma-devel] commit: data.xml: Nicer formatting. (Adrien Grand )
git version control
git at videolan.org
Sat Sep 20 11:40:00 CEST 2008
vlma | branch: master | Adrien Grand <jpountz at videolan.org> | Sat Sep 20 11:42:29 2008 +0200| [0eaa2165cf5d885e9bff408e64e8307f9026efdf] | committer: Adrien Grand
data.xml: Nicer formatting.
> http://git.videolan.org/gitweb.cgi/vlma.git/?a=commit;h=0eaa2165cf5d885e9bff408e64e8307f9026efdf
---
.../java/org/videolan/vlma/dao/VLMaDaoImpl.java | 27 ++++++++++++-------
1 files changed, 17 insertions(+), 10 deletions(-)
diff --git a/vlma-core/src/main/java/org/videolan/vlma/dao/VLMaDaoImpl.java b/vlma-core/src/main/java/org/videolan/vlma/dao/VLMaDaoImpl.java
index 644849f..6b132f1 100644
--- a/vlma-core/src/main/java/org/videolan/vlma/dao/VLMaDaoImpl.java
+++ b/vlma-core/src/main/java/org/videolan/vlma/dao/VLMaDaoImpl.java
@@ -85,6 +85,7 @@ public class VLMaDaoImpl implements VLMaDao {
xstream.alias("directMulticastStreamWatcher", DirectMulticastStreamWatcher.class);
xstream.alias("streamingStrategy", StreamingStrategy.class);
xstream.alias("announcement", StreamingStrategy.Announcement.class);
+ xstream.alias("data", DataContainer.class);
xstream.setMode(XStream.XPATH_ABSOLUTE_REFERENCES);
}
@@ -311,12 +312,18 @@ public class VLMaDaoImpl implements VLMaDao {
}
}
+ private static class DataContainer {
+ public List<Satellite> satellites;
+ public List<Server> servers;
+ public List<Media> medias;
+ }
+
synchronized public void saveToDisk(){
long start = System.currentTimeMillis();
- List<List> saveList = new ArrayList<List>();
- saveList.add(getSatellites());
- saveList.add(getServers());
- saveList.add(getMedias());
+ DataContainer data = new DataContainer();
+ data.satellites = getSatellites();
+ data.servers = getServers();
+ data.medias = getMedias();
String vlmaData = configuration.getString("vlma.data");
@@ -324,7 +331,7 @@ public class VLMaDaoImpl implements VLMaDao {
FileOutputStream f;
try {
f = new FileOutputStream(dataFile);
- xstream.toXML(saveList, f);
+ xstream.toXML(data, f);
try {
f.close();
logger.debug("Data saved in " + (System.currentTimeMillis() - start) + "ms");
@@ -343,8 +350,8 @@ public class VLMaDaoImpl implements VLMaDao {
File dataFile = new File(vlmaData, DATA_FILE);
FileInputStream f = new FileInputStream(dataFile);
- List<List> loadList;
- loadList = (List<List>) xstream.fromXML(f);
+ DataContainer data;
+ data = (DataContainer) xstream.fromXML(f);
try {
f.close();
} catch (IOException e) {
@@ -353,19 +360,19 @@ public class VLMaDaoImpl implements VLMaDao {
synchronized (satellites) {
satellites = new HashMap<Integer, Satellite>();
- for (Satellite satellite : (List<Satellite>) loadList.get(0)) {
+ for (Satellite satellite : (List<Satellite>) data.satellites) {
satellites.put(satellite.getId(), satellite);
}
}
synchronized (servers) {
servers = new HashMap<Integer, Server>();
- for (Server server : (List<Server>) loadList.get(1)) {
+ for (Server server : (List<Server>) data.servers) {
servers.put(server.getId(), server);
}
}
synchronized (medias) {
medias = new HashMap<Integer, Media>();
- for (Media media : (List<Media>) loadList.get(2)) {
+ for (Media media : (List<Media>) data.medias) {
medias.put(media.getId(), media);
}
}
More information about the vlma-devel
mailing list