- Timestamp:
- 07/14/13 23:20:04 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
java/main/src/main/java/com/framsticks/remote/RemoteTree.java
r100 r101 7 7 import com.framsticks.communication.queries.SetRequest; 8 8 import com.framsticks.core.AbstractTree; 9 import com.framsticks.core.ListChange; 9 10 import com.framsticks.core.Path; 11 import com.framsticks.core.ValueChange; 10 12 import com.framsticks.params.*; 11 13 import com.framsticks.params.EventListener; 12 import com.framsticks.params.annotations.AutoAppendAnnotation;13 14 import com.framsticks.params.annotations.FramsClassAnnotation; 14 15 import com.framsticks.params.annotations.ParamAnnotation; … … 17 18 import com.framsticks.parsers.Loaders; 18 19 import com.framsticks.parsers.MultiParamLoader; 19 import com.framsticks.core.Tree;20 20 import com.framsticks.util.*; 21 21 import com.framsticks.util.dispatching.AtOnceDispatcher; 22 22 import com.framsticks.util.dispatching.Dispatching; 23 import com.framsticks.util.dispatching.Dispatching.DispatcherWaiter;24 23 import com.framsticks.util.dispatching.DispatchingFuture; 25 24 import com.framsticks.util.dispatching.ExceptionResultHandler; … … 52 51 53 52 public RemoteTree() { 53 bufferedDispatcher.setBuffer(true); 54 registry.registerAndBuild(ListChange.class); 55 registry.registerAndBuild(ValueChange.class); 54 56 } 55 57 56 58 @ParamAnnotation 57 59 public void setAddress(String address) { 58 setConnection(Connection.to(new ClientSideManagedConnection(), new Address(address))); 59 } 60 61 @ParamAnnotation 60 this.connection = Connection.to(new ClientSideManagedConnection(), new Address(address)); 61 this.connection.setExceptionHandler(this); 62 this.connection.setNeedFileAcceptor(this); 63 } 64 65 @ParamAnnotation(flags = ParamFlags.USERREADONLY) 62 66 public String getAddress() { 63 67 return connection == null ? "<disconnected>" : connection.getAddress().toString(); 64 }65 66 @AutoAppendAnnotation67 public void setConnection(final ClientSideManagedConnection connection) {68 this.connection = connection;69 this.connection.setExceptionHandler(this);70 68 } 71 69 … … 219 217 super.joinableStart(); 220 218 221 dispatch(new RunAt<RemoteTree>(ThrowExceptionHandler.getInstance()) {219 bufferedDispatcher.getTargetDispatcher().dispatch(new RunAt<RemoteTree>(ThrowExceptionHandler.getInstance()) { 222 220 @Override 223 221 protected void runAt() { 224 final DispatcherWaiter<Tree, Tree> waiter = new DispatcherWaiter<Tree, Tree>(RemoteTree.this); 225 226 connection.send(new InfoRequest().path("/"), waiter, new ClientSideResponseFuture(this) { 222 223 connection.send(new InfoRequest().path("/"), bufferedDispatcher.getTargetDispatcher(), new ClientSideResponseFuture(this) { 227 224 @Override 228 225 protected void processOk(Response response) { 229 226 FramsClass framsClass = processFetchedInfo(RemoteTree.this, response.getFiles().get(0)); 230 227 assignRootParam(Param.build().name("Tree").id(RemoteTree.this.getName()).type("o " + framsClass.getId()).finish(CompositeParam.class)); 228 bufferedDispatcher.setBuffer(false); 231 229 } 232 230 }); 233 231 234 waiter.waitFor();235 232 } 236 233 }); … … 295 292 protected void runAt() { 296 293 assert isActive(); 297 if (argumentType.equals( Object.class)) {294 if (argumentType.equals(File.class)) { 298 295 listener.action(Casting.tryCast(argumentType, file)); 299 296 return; 300 297 } 301 Access access = registry.createAccess(argumentType); 302 Object argument = access.createAccessee(); 303 access.select(argument); 304 if (!argumentType.isInstance(argument)) { 305 throw new FramsticksException().msg("created argument is of wrond type").arg("expected", argumentType).arg("created", argument.getClass()); 306 } 307 A typedArgument = argumentType.cast(argument); 298 // Access access = registry.createAccess(argumentType); 308 299 309 300 // log.info("executing event with argument {}", argumentType); … … 311 302 loader.setNewSource(file.getContent()); 312 303 loader.addBreakCondition(MultiParamLoader.Status.AfterObject); 313 loader.addAccess(access); 304 loader.setAccessProvider(registry); 305 // loader.addAccess(access); 314 306 loader.go(); 315 316 listener.action(typedArgument); 307 Object argument = loader.getLastAccess().getSelected(); 308 // Object argument = access.getSelected(); 309 if (argument == null) { 310 listener.action(null); 311 } 312 if (!argumentType.isInstance(argument)) { 313 throw new FramsticksException().msg("created argument is of wrong type").arg("expected", argumentType).arg("created", argument.getClass()); 314 } 315 listener.action(argumentType.cast(argument)); 317 316 } 318 317 });
Note: See TracChangeset
for help on using the changeset viewer.