1 package com.opensymphony.user.provider.file; 2 3 import java.io.File ; 4 import java.io.FileOutputStream ; 5 import java.io.ObjectInputStream ; 6 import java.io.ObjectOutputStream ; 7 8 class SerializablePropertySetCache extends FilePropertySetCache { 9 10 public SerializablePropertySetCache(String storeFile, String storeFileType) { 11 super(storeFile, storeFileType); 12 load(); 13 } 14 17 public boolean load() { 18 try { 19 ObjectInputStream ois = new ObjectInputStream (getInputStreamFromStoreFile()); 20 SerializablePropertySetCache ps = (SerializablePropertySetCache) ois.readObject(); 21 22 propertySets = ps.propertySets; 24 25 return true; 26 } catch (Exception e) { 27 log.fatal("cannot load from file " + storeFile + ". Create a new blank store.", e); 28 } 29 30 return false; 31 } 32 33 public boolean store() { 34 try { 35 FileOutputStream fos = new FileOutputStream (new File (storeFile)); 36 ObjectOutputStream oos = new ObjectOutputStream (fos); 37 oos.writeObject(this); 38 fos.close(); 39 40 return true; 41 } catch (Exception e) { 42 log.fatal("cannot store in file " + storeFile + ".", e); 43 } 44 45 return false; 46 } 47 } | Popular Tags |