- Timestamp:
- 07/06/13 03:51:11 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
java/main/src/main/java/com/framsticks/remote/RecursiveFetcher.java
r96 r97 1 1 package com.framsticks.remote; 2 2 3 import static com.framsticks.core.InstanceUtils.*; 3 import static com.framsticks.core.TreeOperations.*; 4 5 import com.framsticks.core.Mode; 4 6 import com.framsticks.core.Node; 5 7 import com.framsticks.core.Path; … … 7 9 import com.framsticks.params.CompositeParam; 8 10 import com.framsticks.params.FramsClass; 9 import com.framsticks.core. Instance;11 import com.framsticks.core.Tree; 10 12 import com.framsticks.util.dispatching.Future; 13 import com.framsticks.util.dispatching.FutureHandler; 14 import com.framsticks.util.dispatching.ThrowExceptionHandler; 11 15 import com.framsticks.util.FramsticksException; 12 16 import com.framsticks.util.Logging; 13 import com.framsticks.util.StateFunctor;14 17 import com.framsticks.util.Stopwatch; 15 18 import org.apache.log4j.Logger; … … 24 27 private final static Logger log = Logger.getLogger(RecursiveFetcher.class.getName()); 25 28 26 protected final Instance instance;27 protected final StateFunctor stateFunctor;29 protected final Tree tree; 30 protected final Future<Void> future; 28 31 protected int dispatched; 29 32 protected final Stopwatch stopwatch = new Stopwatch(); 30 33 31 public RecursiveFetcher( Instance instance, final Path path, StateFunctor stateFunctor) {32 this. instance = instance;33 this. stateFunctor = stateFunctor;34 public RecursiveFetcher(Tree tree, final Path path, Future<Void> future) { 35 this.tree = tree; 36 this.future = future; 34 37 dispatched = 1; 35 38 process(path); … … 37 40 38 41 protected void finished() { 39 assert instance.isActive();42 assert tree.isActive(); 40 43 log.info("recursively fetched in " + stopwatch); 41 stateFunctor.call();44 future.pass(null); 42 45 } 43 46 44 47 protected void process(final Path path) { 45 assert instance.isActive();48 assert tree.isActive(); 46 49 if (path == null || !path.isResolved()) { 47 50 log.warn("path " + path + " is not resolved - skipping"); … … 55 58 if (childPath.isResolved() && getInfoFromCache(childPath) != null) { 56 59 ++dispatched; 57 instance.dispatch(new RunAt<Instance>() {60 tree.dispatch(new RunAt<Tree>(ThrowExceptionHandler.getInstance()) { 58 61 @Override 59 p ublic void run() {62 protected void runAt() { 60 63 fetch(childPath); 61 64 } … … 64 67 } 65 68 ++dispatched; 66 instance.resolve(childPath, new Future<Path>(Logging.logger(log, "resolve", RecursiveFetcher.this)) {69 tree.resolve(childPath, new FutureHandler<Path>(Logging.logger(log, "resolve", RecursiveFetcher.this)) { 67 70 @Override 68 71 protected void result(Path result) { 69 assert instance.isActive();72 assert tree.isActive(); 70 73 fetch(result); 71 74 } … … 80 83 81 84 protected void fetch(final Path path) { 82 instance.fetchValues(path, new StateFunctor() { 85 tree.get(path, Mode.FETCH, new Future<Object>() { 86 83 87 @Override 84 88 public void handle(FramsticksException e) { … … 88 92 89 93 @Override 90 p ublic void call() {94 protected void result(Object object) { 91 95 process(path); 92 96 }
Note: See TracChangeset
for help on using the changeset viewer.