- Timestamp:
- 06/22/13 21:51:33 (11 years ago)
- Location:
- java/main
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
java/main
-
Property
svn:ignore
set to
target
-
Property
svn:ignore
set to
-
java/main/src/main/java/com/framsticks/dumping/FileInstance.java
r78 r84 2 2 3 3 import com.framsticks.core.LocalInstance; 4 import com.framsticks.core.Parameters;5 4 import com.framsticks.core.Path; 6 import com.framsticks.params.FramsClass;7 5 import com.framsticks.core.Instance; 8 import com.framsticks.util.*; 9 import com.framsticks.util.UnsupportedOperationException; 6 import com.framsticks.util.dispatching.Future; 7 8 import org.apache.commons.configuration.Configuration; 10 9 import org.apache.log4j.Logger; 11 10 … … 20 19 public class FileInstance extends LocalInstance { 21 20 22 private static final Logger LOGGER= Logger.getLogger(Instance.class.getName());23 protected finalFile file;21 private static final Logger log = Logger.getLogger(Instance.class.getName()); 22 protected File file; 24 23 25 public FileInstance(Parameters parameters) { 26 super(parameters); 27 file = new File(config.getString("filename")); 28 } 24 public FileInstance() { 25 } 29 26 30 @Override 31 public void run() { 32 assert isActive(); 33 super.run(); 34 try { 35 FileReader fileReader = new FileReader(file); 36 LoadStream stream = new LoadStream(new Path(this, "/"), new BufferedReader(fileReader), this, new Future<Path>() { 37 @Override 38 public void result(Path result, Exception e) { 39 if (e != null) { 40 LOGGER.error("failed to load file instance " + FileInstance.this + ": " + e); 41 fireRun(e); 42 return; 43 } 44 LOGGER.info("loaded file instance " + FileInstance.this); 45 fireRun(null); 46 } 47 }); 48 stream.load(); 49 } catch (IOException e) { 50 LOGGER.error("io failure: " + e); 51 fireRun(e); 52 } 53 } 27 @Override 28 public void configure(Configuration config) { 29 super.configure(config); 30 file = new File(config.getString("filename")); 31 } 54 32 55 @Override 56 public String toString() { 57 return "file@" + file.getName(); 58 } 33 @Override 34 public void run() { 35 assert isActive(); 36 super.run(); 37 try { 38 FileReader fileReader = new FileReader(file); 39 LoadStream stream = new LoadStream(this.getRootPath(), new BufferedReader(fileReader), this, new Future<Path>() { 40 @Override 41 public void result(Path result, Exception e) { 42 if (e != null) { 43 log.error("failed to load file instance " + FileInstance.this + ": " + e); 44 fireRun(e); 45 return; 46 } 47 log.info("loaded file instance " + FileInstance.this); 48 fireRun(null); 49 } 50 }); 51 stream.load(); 52 } catch (IOException e) { 53 log.error("io failure: " + e); 54 fireRun(e); 55 } 56 } 57 58 @Override 59 public String toString() { 60 return "file@" + file.getName(); 61 } 59 62 60 63
Note: See TracChangeset
for help on using the changeset viewer.