public void run() { IFuture<T> fut = interpreter.scheduleStep(step); FutureFunctionality.connectDelegationFuture(ret, fut); } });
/** * Create intermediate of direct future. */ protected Future<?> createStepFuture(IComponentStep<?> step) { Future<?> ret; try { Method method = step.getClass().getMethod("execute", new Class[]{IInternalAccess.class}); Class<?> clazz = method.getReturnType(); // ret = FutureFunctionality.getDelegationFuture(clazz, new FutureFunctionality(getLogger())); // Must not be fetched before properties are available! ret = FutureFunctionality.getDelegationFuture(clazz, new FutureFunctionality(new IResultCommand<Logger, Void>() { public Logger execute(Void args) { return getLogger(); } })); } catch(Exception e) { throw new RuntimeException(e); } return ret; }
/** * Terminate the future. */ public void terminate(final Exception reason) { func.terminate(reason, new IResultListener<Void>() { public void resultAvailable(Void v) { DelegatingPullIntermediateDelegationFuture.super.terminate(reason); } public void exceptionOccurred(Exception exception) { // Hack!!! termination in functionality failed -> should change result of future to failure? func.getLogger().warning("Exception when terminating future: "+exception); DelegatingPullIntermediateDelegationFuture.super.terminate(reason); } }); }
final Future<Object> ret = (Future<Object>)FutureFunctionality.getDelegationFuture(method.getReturnType(), new FutureFunctionality((Logger)null)
final Future<T> ret = m!=null ? (Future<T>)FutureFunctionality.getDelegationFuture(m.getReturnType(), new FutureFunctionality((Logger)null)) : new Future<T>(); FutureFunctionality.connectDelegationFuture(ret, fut);
/** * */ public void addIntermediateResult(TupleResult result) { try { TupleResult res = (TupleResult)func.addIntermediateResult(result); DelegatingTupleFuture.super.addIntermediateResult(res); } catch(RuntimeException e) { DelegatingTupleFuture.super.setExceptionIfUndone(e); } }
/** * */ public boolean addIntermediateResultIfUndone(Object result) { boolean ret = false; try { Object res = func.addIntermediateResultIfUndone(result); ret = DelegatingTerminableIntermediateDelegationFuture.super.addIntermediateResultIfUndone(res); } catch(Exception e) { DelegatingTerminableIntermediateDelegationFuture.super.terminate(e); } return ret; }
/** * Get required services. * @return The services. */ protected <T> ITerminableIntermediateFuture<T> getRequiredServices(RequiredServiceInfo info, RequiredServiceBinding binding, boolean rebind, IAsyncFilter<T> filter) { // if(shutdowned) // { // return new TerminableIntermediateFuture<T>(new ComponentTerminatedException(id)); // } if(info==null) { TerminableIntermediateFuture<T> ret = new TerminableIntermediateFuture<T>(); ret.setException(new IllegalArgumentException("Info must not null.")); return ret; } IRequiredServiceFetcher fetcher = getRequiredServiceFetcher(info.getName()); ITerminableIntermediateFuture<T> fut = fetcher.getServices(info, binding, rebind, filter); return (ITerminableIntermediateFuture<T>)FutureFunctionality.getDelegationFuture(fut, new ComponentFutureFunctionality(getComponent())); }
/** * */ public void addIntermediateResult(Object result) { try { Object res = func.addIntermediateResult(result); DelegatingSubscriptionIntermediateDelegationFuture.super.addIntermediateResult(res); } catch(RuntimeException e) { DelegatingSubscriptionIntermediateDelegationFuture.super.terminate(e); } }
/** * */ public boolean addIntermediateResultIfUndone(TupleResult result) { boolean ret = false; try { TupleResult res = (TupleResult)func.addIntermediateResultIfUndone(result); ret = DelegatingTupleFuture.super.addIntermediateResultIfUndone(res); } catch(Exception e) { DelegatingTupleFuture.super.setExceptionIfUndone(e); } return ret; }
/** * Get required services. * @return The services. */ public <T> ITerminableIntermediateFuture<T> getRequiredServices(RequiredServiceInfo info, RequiredServiceBinding binding, boolean rebind, IRemoteFilter<T> filter) { if(shutdowned) { return new TerminableIntermediateFuture<T>(new ComponentTerminatedException(id)); } ITerminableIntermediateFuture<T> fut = super.getRequiredServices(info, binding, rebind, filter); return (ITerminableIntermediateFuture<T>)FutureFunctionality.getDelegationFuture(fut, new ComponentFutureFunctionality(instance.getExternalAccess(), adapter)); }
/** * Create intermediate of direct future. */ protected <T> Future<T> createStepFuture(IComponentStep<T> step) { Future<T> ret; try { Method method = step.getClass().getMethod("execute", new Class[]{IInternalAccess.class}); Class<?> clazz = method.getReturnType(); // ret = FutureFunctionality.getDelegationFuture(clazz, new FutureFunctionality(getLogger())); // Must not be fetched before properties are available! ret = (Future<T>)FutureFunctionality.getDelegationFuture(clazz, new FutureFunctionality(new IResultCommand<Logger, Void>() { public Logger execute(Void args) { return getComponent().getLogger(); } })); } catch(Exception e) { throw new RuntimeException(e); } return ret; }
public void customResultAvailable(Void result) { FutureFunctionality.connectDelegationFuture((Future<?>)fret, (IFuture<?>)sic.getResult()); } });
/** * Terminate the future. */ public void terminate(final Exception reason) { func.terminate(reason, new IResultListener<Void>() { public void resultAvailable(Void v) { DelegatingSubscriptionIntermediateDelegationFuture.super.terminate(reason); } public void exceptionOccurred(Exception exception) { // Hack!!! termination in functionality failed -> should change result of future to failure? func.getLogger().warning("Exception when terminating future: "+exception); DelegatingSubscriptionIntermediateDelegationFuture.super.terminate(reason); } }); }
/** * */ public void addIntermediateResult(Object result) { try { Object res = func.addIntermediateResult(result); DelegatingTerminableIntermediateDelegationFuture.super.addIntermediateResult(res); } catch(Exception e) { DelegatingTerminableIntermediateDelegationFuture.super.terminate(e); } }
/** * */ public boolean addIntermediateResultIfUndone(Object result) { boolean ret = false; try { Object res = func.addIntermediateResultIfUndone(result); ret = DelegatingIntermediateFuture.super.addIntermediateResultIfUndone(res); } catch(Exception e) { DelegatingIntermediateFuture.super.setExceptionIfUndone(e); } return ret; }
/** * Get all services of a type. * @param type The class. * @return Each service as an intermediate result and a collection of services as final result. */ public <T> ITerminableIntermediateFuture<T> searchServices(final Class<T> type, String scope) { // Todo: terminable? final TerminableIntermediateFuture<T> fut = new TerminableIntermediateFuture<T>(); SServiceProvider.getServices(getComponent(), type, scope).addResultListener(new IntermediateDelegationResultListener<T>(fut) { // Not necessary any longer // public void customIntermediateResultAvailable(Object result) // { // fut.addIntermediateResult((T)BasicServiceInvocationHandler.createRequiredServiceProxy(getComponent(), // (IService)result, null, new RequiredServiceInfo(type), null, Starter.isRealtimeTimeout(getComponent().getComponentIdentifier()))); // } }); return (ITerminableIntermediateFuture<T>)FutureFunctionality.getDelegationFuture(fut, new ComponentFutureFunctionality(getComponent())); }
final IServiceIdentifier sid, final IExternalAccess ea, final ITargetResolver tr, final int maxretries, final int cnt) final Future<Object> ret = (Future<Object>)FutureFunctionality.getDelegationFuture(sic.getMethod().getReturnType(), new FutureFunctionality((Logger)null));
public void customResultAvailable(Void result) { // if(sic.getMethod().getName().indexOf("test")!=-1) // System.out.println("connect: "+sic.getMethod().getName()); // if(method.getName().indexOf("calculate")!=-1) // System.out.println("connect: "+proxy+" "+sic); FutureFunctionality.connectDelegationFuture((Future<?>)fret, (IFuture<?>)sic.getResult()); } });
/** * Terminate the future. */ public void terminate(final Exception reason) { func.terminate(reason, new IResultListener<Void>() { public void resultAvailable(Void v) { DelegatingPullSubscriptionIntermediateDelegationFuture.super.terminate(reason); } public void exceptionOccurred(Exception exception) { // Hack!!! termination in functionality failed -> should change result of future to failure? func.getLogger().warning("Exception when terminating future: "+exception); DelegatingPullSubscriptionIntermediateDelegationFuture.super.terminate(reason); } }); }