Changeset 88 for trunk/EventBenchConsole


Ignore:
Timestamp:
06/23/11 14:52:42 (13 years ago)
Author:
sherbold
Message:

+ added commands save and load that saves, respectively loads the internal data

Location:
trunk/EventBenchConsole/src/de/ugoe/cs/eventbench
Files:
2 added
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/EventBenchConsole/src/de/ugoe/cs/eventbench/data/GlobalDataContainer.java

    r1 r88  
    11package de.ugoe.cs.eventbench.data; 
    22 
     3import java.io.IOException; 
     4import java.io.ObjectInputStream; 
     5import java.io.ObjectOutputStream; 
     6import java.io.Serializable; 
    37import java.util.HashMap; 
    48import java.util.Map; 
    59 
    6 public class GlobalDataContainer { 
     10public class GlobalDataContainer implements Serializable { 
    711         
    8         private static GlobalDataContainer theInstance= null; 
     12        /** 
     13         * Id for object serialization. 
     14         */ 
     15        private static final long serialVersionUID = 1L; 
     16 
     17        transient private static GlobalDataContainer theInstance = null; 
    918         
    1019        private Map<String, Object> dataObjects; 
     
    1423                        theInstance = new GlobalDataContainer(); 
    1524                } 
     25                return theInstance; 
     26        } 
     27         
     28        private void writeObject(ObjectOutputStream s) throws IOException { 
     29                s.defaultWriteObject(); 
     30                s.writeObject(dataObjects); 
     31        } 
     32         
     33        @SuppressWarnings("unchecked") 
     34        private void readObject(ObjectInputStream s) throws IOException, ClassNotFoundException { 
     35                s.defaultReadObject(); 
     36                if( theInstance==null ) { 
     37                        theInstance = new GlobalDataContainer(); 
     38                } 
     39                theInstance.dataObjects = (Map<String, Object>) s.readObject(); 
     40        } 
     41         
     42        private Object readResolve() { 
    1643                return theInstance; 
    1744        } 
Note: See TracChangeset for help on using the changeset viewer.