- Timestamp:
- 07/02/13 16:20:07 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
java/main/src/main/java/com/framsticks/dumping/FileInstance.java
r88 r90 7 7 import com.framsticks.params.annotations.ParamAnnotation; 8 8 import com.framsticks.util.dispatching.Future; 9 import com.framsticks.util.dispatching.RunAt; 9 10 import com.framsticks.util.io.Encoding; 10 11 … … 17 18 import java.io.InputStreamReader; 18 19 19 import javax.annotation.OverridingMethodsMustInvokeSuper;20 20 21 21 /** … … 23 23 */ 24 24 @FramsClassAnnotation 25 public class FileInstance extends LocalInstance {25 public abstract class FileInstance extends LocalInstance { 26 26 27 27 private static final Logger log = Logger.getLogger(Instance.class.getName()); … … 42 42 43 43 @Override 44 @OverridingMethodsMustInvokeSuper45 protected void firstTask() {46 assert isActive();47 super.firstTask();48 try {49 LoadStream stream = new LoadStream(this.getRootPath(), new BufferedReader(new InputStreamReader(new FileInputStream(file), Encoding.getFramsticksCharset())), this, new Future<Path>() {50 @Override51 public void result(Path result, Exception e) {52 if (e != null) {53 log.error("failed to load file instance " + FileInstance.this + ": " + e);54 fireRun(e);55 return;56 }57 log.info("loaded file instance " + FileInstance.this);58 fireRun(null);59 }60 });61 stream.load();62 } catch (IOException e) {63 log.error("io failure: " + e);64 fireRun(e);65 }66 }67 68 @Override69 44 public String toString() { 70 45 return "file@" + file.getName(); 71 46 } 72 47 48 @Override 49 protected void joinableStart() { 50 dispatch(new RunAt<Instance>() { 73 51 52 @Override 53 public void run() { 54 assert isActive(); 55 56 try { 57 LoadStream stream = new LoadStream(FileInstance.this.getRootPath(), new BufferedReader(new InputStreamReader(new FileInputStream(file), Encoding.getFramsticksCharset())), FileInstance.this, new Future<Path>() { 58 @Override 59 public void result(Path result, Exception e) { 60 if (e != null) { 61 log.error("failed to load file instance " + FileInstance.this + ": " + e); 62 fireRun(e); 63 return; 64 } 65 log.info("loaded file instance " + FileInstance.this); 66 fireRun(null); 67 } 68 }); 69 stream.load(); 70 } catch (IOException e) { 71 log.error("io failure: " + e); 72 fireRun(e); 73 } 74 } 75 76 }); 77 super.joinableStart(); 78 } 74 79 75 80 }
Note: See TracChangeset
for help on using the changeset viewer.