- Timestamp:
- 07/18/13 23:52:25 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
java/main/src/main/java/com/framsticks/remote/RemoteTree.java
r102 r103 17 17 import com.framsticks.params.types.ProcedureParam; 18 18 import com.framsticks.parsers.Loaders; 19 import com.framsticks.parsers.MultiParamLoader;20 19 import com.framsticks.util.*; 21 20 import com.framsticks.util.dispatching.AtOnceDispatcher; … … 29 28 import com.framsticks.util.dispatching.JoinableState; 30 29 import com.framsticks.util.dispatching.ThrowExceptionHandler; 31 import com.framsticks.util.lang.Casting;32 30 import com.framsticks.util.dispatching.RunAt; 33 31 import static com.framsticks.core.TreeOperations.*; … … 269 267 270 268 @Override 271 public void call(@Nonnull final Path path, @Nonnull final ProcedureParam procedure, @Nonnull Object[] arguments, final Future<Object> future) {269 public <R> void call(@Nonnull final Path path, @Nonnull final ProcedureParam procedure, @Nonnull Object[] arguments, final Class<R> resultType, final Future<R> future) { 272 270 assert isActive(); 273 271 assert path.isResolved(); … … 278 276 protected void processOk(Response response) { 279 277 assert isActive(); 280 // InstanceUtils.processFetchedValues(path, response.getFiles()); 281 future.pass(null); 278 279 if (response.getFiles().size() == 0) { 280 future.pass(null); 281 return; 282 } 283 if (response.getFiles().size() == 1) { 284 future.pass(AccessOperations.convert(resultType, response.getFiles().get(0), registry)); 285 return; 286 } 287 throw new FramsticksUnsupportedOperationException().msg("call result with multiple files"); 288 282 289 } 283 290 }); … … 303 310 protected void runAt() { 304 311 assert isActive(); 305 if (argumentType.equals(File.class)) { 306 listener.action(Casting.tryCast(argumentType, file)); 307 return; 308 } 309 // Access access = registry.createAccess(argumentType); 310 311 // log.info("executing event with argument {}", argumentType); 312 MultiParamLoader loader = new MultiParamLoader(); 313 loader.setNewSource(file.getContent()); 314 loader.addBreakCondition(MultiParamLoader.Status.AfterObject); 315 loader.setAccessProvider(registry); 316 // loader.addAccess(access); 317 loader.go(); 318 Object argument = loader.getLastAccess().getSelected(); 319 // Object argument = access.getSelected(); 320 if (argument == null) { 321 listener.action(null); 322 } 323 if (!argumentType.isInstance(argument)) { 324 throw new FramsticksException().msg("created argument is of wrong type").arg("expected", argumentType).arg("created", argument.getClass()); 325 } 326 listener.action(argumentType.cast(argument)); 312 313 listener.action(AccessOperations.convert(argumentType, file, registry)); 327 314 } 328 315 });
Note: See TracChangeset
for help on using the changeset viewer.