- Timestamp:
- 07/04/13 20:29:50 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
java/main/src/main/java/com/framsticks/core/ObjectInstance.java
r90 r96 5 5 import com.framsticks.params.AccessInterface; 6 6 import com.framsticks.params.CompositeParam; 7 import com.framsticks.params.FramsClass; 7 8 import com.framsticks.params.Param; 9 import com.framsticks.params.ValueParam; 8 10 import com.framsticks.params.annotations.AutoAppendAnnotation; 9 11 import com.framsticks.params.annotations.FramsClassAnnotation; 12 import com.framsticks.util.UnsupportedOperationException; 10 13 import com.framsticks.params.types.ProcedureParam; 11 14 import com.framsticks.util.FramsticksException; 12 15 import com.framsticks.util.StateFunctor; 16 import com.framsticks.util.dispatching.Future; 17 // import static com.framsticks.core.InstanceUtils.*; 13 18 14 19 @FramsClassAnnotation 15 public class ObjectInstance extends Instance {20 public class ObjectInstance extends AbstractInstance { 16 21 private static final Logger log = Logger.getLogger(ObjectInstance.class); 17 22 … … 20 25 registry.registerAndBuild(object.getClass()); 21 26 AccessInterface access = registry.createAccess(object.getClass()); 22 setRoot( Param.build().forAccess(access).id(getName()).finish(CompositeParam.class), object);27 setRoot(new Node(Param.build().forAccess(access).id(getName()).finish(CompositeParam.class), object)); 23 28 } 24 29 … … 43 48 log.debug("requesting: " + path); 44 49 fireFetch(path); 45 stateFunctor.call( null);50 stateFunctor.call(); 46 51 } 47 52 48 53 @Override 49 public void fetchValue(Path path, Param param, StateFunctor stateFunctor) {54 public void fetchValue(Path path, ValueParam param, StateFunctor stateFunctor) { 50 55 assert isActive(); 51 56 fireFetch(path); 52 stateFunctor.call( null);57 stateFunctor.call(); 53 58 } 54 59 55 60 @Override 56 public void call(Path path, ProcedureParam param, Object[] arguments, StateFunctor stateFunctor) {61 public void call(Path path, ProcedureParam param, Object[] arguments, Future<Object> future) { 57 62 assert isActive(); 58 63 try { 59 bindAccess(path).call(param, arguments); 60 stateFunctor.call(null); 64 future.pass(InstanceUtils.bindAccess(path).call(param, arguments)); 61 65 } catch (FramsticksException e) { 62 stateFunctor.call(e);66 future.handle(e); 63 67 } 64 68 } 69 70 @Override 71 public void fetchInfo(Path path, Future<FramsClass> future) { 72 assert isActive(); 73 Path p = path.tryResolveIfNeeded(); 74 Class<?> javaClass = p.getTopObject().getClass(); 75 FramsClass framsClass = registry.registerReflectedIfNeeded(javaClass); 76 if (framsClass != null) { 77 future.pass(framsClass); 78 } else { 79 future.handle(new FramsticksException().msg("failed to find info for class").arg("java class", javaClass)); 80 } 81 } 82 83 @Override 84 public void resolve(Path path, Future<Path> future) { 85 assert isActive(); 86 assert path.isOwner(this); 87 if (path.getTop().getObject() != null) { 88 future.pass(path); 89 return; 90 } 91 AccessInterface access = InstanceUtils.bindAccess(this, path.getUnder()); 92 Object object = access.get(path.getTop().getParam(), Object.class); 93 if (object == null) { 94 future.pass(path); 95 return; 96 } 97 future.pass(path.appendResolution(object)); 98 } 99 100 @Override 101 public void storeValue(Path path, ValueParam param, Object value, final StateFunctor stateFunctor) { 102 assert isActive(); 103 stateFunctor.handle(new UnsupportedOperationException()); 104 } 105 106 @Override 107 public Path create(Path path) { 108 assert isActive(); 109 assert !path.isResolved(); 110 throw new UnsupportedOperationException(); 111 } 112 65 113 }
Note: See TracChangeset
for help on using the changeset viewer.