/** * 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; }
/** * 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; }
final Future<Object> ret = (Future<Object>)FutureFunctionality.getDelegationFuture(method.getReturnType(), new FutureFunctionality((Logger)null)
/** * 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)); }
/** * 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())); }
/** * 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())); }
/** * Get one service of a type. * @param type The class. * @return The corresponding service. */ public <T> IFuture<T> searchService(final Class<T> type) { final Future<T> fut = new Future<T>(); SServiceProvider.getService(getComponent(), type).addResultListener(new DelegationResultListener<T>(fut) { // Not necessary any longer // public void customResultAvailable(Object result) // { // fut.setResult((T)BasicServiceInvocationHandler.createRequiredServiceProxy(getComponent(), // (IService)result, null, new RequiredServiceInfo(type), null, Starter.isRealtimeTimeout(getComponent().getComponentIdentifier()))); // } }); return FutureFunctionality.getDelegationFuture(fut, new ComponentFutureFunctionality(getComponent())); }
Future<?> fut = FutureFunctionality.getDelegationFuture((IFuture<?>)res, func); sic.setResult(fut);
/** * 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) { // Todo: terminable? final TerminableIntermediateFuture<T> fut = new TerminableIntermediateFuture<T>(); SServiceProvider.getServices(getComponent(), type).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())); }
/** * Get one service of a type. * @param type The class. * @return The corresponding service. */ public <T> IFuture<T> searchService(final Class<T> type, String scope) { // if(type.getName().toLowerCase().indexOf("environment")!=-1) // System.out.println("dghfhj"); final Future<T> fut = new Future<T>(); SServiceProvider.getService(getComponent(), type, scope).addResultListener(new DelegationResultListener<T>(fut)); // { // // Not necessary any longer // public void customResultAvailable(Object result) // { // fut.setResult((T)BasicServiceInvocationHandler.createRequiredServiceProxy(getComponent(), // (IService)result, null, new RequiredServiceInfo(type), null, Starter.isRealtimeTimeout(getComponent().getComponentIdentifier()))); // } // }); return FutureFunctionality.getDelegationFuture(fut, new ComponentFutureFunctionality(getComponent())); }
/** * Get one service of a type from a specific component. * @param type The class. * @param cid The component identifier of the target component. * @return The corresponding service. */ public <T> IFuture<T> searchService(final Class<T> type, IComponentIdentifier cid) { final Future<T> fut = new Future<T>(); SServiceProvider.getService(getComponent(), cid, type).addResultListener(new DelegationResultListener<T>(fut)); // { // // Not necessary any longer (done in SServiceProvider) // public void customResultAvailable(Object result) // { // fut.setResult((T)BasicServiceInvocationHandler.createRequiredServiceProxy(getComponent(), // (IService)result, null, new RequiredServiceInfo(type), null, Starter.isRealtimeTimeout(getComponent().getComponentIdentifier()))); // } // }); return FutureFunctionality.getDelegationFuture(fut, new ComponentFutureFunctionality(getComponent())); }
final Future<T> ret = m!=null ? (Future<T>)FutureFunctionality.getDelegationFuture(m.getReturnType(), new FutureFunctionality((Logger)null)) : new Future<T>();
Future<?> fut = FutureFunctionality.getDelegationFuture((IFuture<?>)res, func); sic.setResult(fut);
return (IFuture<T>)FutureFunctionality.getDelegationFuture(fut, new ComponentFutureFunctionality(instance.getExternalAccess(), adapter));
/** * Get all services of a type. * @param type The class. * @return The corresponding services. */ public <T> IIntermediateFuture<T> searchServices(final Class<T> type, String scope) { if(shutdowned) { return new IntermediateFuture<T>(new ComponentTerminatedException(id)); } final IntermediateFuture<T> fut = new IntermediateFuture<T>(); SServiceProvider.getServices(this, type, scope).addResultListener(new IntermediateDelegationResultListener(fut) { public void customIntermediateResultAvailable(Object result) { if(shutdowned) { fut.setException(new ComponentTerminatedException(id)); } else { fut.addIntermediateResult((T)BasicServiceInvocationHandler.createRequiredServiceProxy(instance, instance.getExternalAccess(), adapter, (IService)result, null, new RequiredServiceInfo(type), null, realtime)); } } }); return (IIntermediateFuture<T>)FutureFunctionality.getDelegationFuture(fut, new ComponentFutureFunctionality(instance.getExternalAccess(), adapter)); }
/** * Get all services of a type. * @param type The class. * @return The corresponding services. */ public <T> IIntermediateFuture<T> searchServices(final Class<T> type) { if(shutdowned) { return new IntermediateFuture<T>(new ComponentTerminatedException(id)); } final IntermediateFuture<T> fut = new IntermediateFuture<T>(); SServiceProvider.getServices(this, type).addResultListener(new IntermediateDelegationResultListener(fut) { public void customIntermediateResultAvailable(Object result) { if(shutdowned) { fut.setException(new ComponentTerminatedException(id)); } else { fut.addIntermediateResult((T)BasicServiceInvocationHandler.createRequiredServiceProxy(instance, instance.getExternalAccess(), adapter, (IService)result, null, new RequiredServiceInfo(type), null, realtime)); } } }); return (IIntermediateFuture<T>)FutureFunctionality.getDelegationFuture(fut, new ComponentFutureFunctionality(instance.getExternalAccess(), adapter)); }
/** * Get one service of a type. * @param type The class. * @return The corresponding service. */ public <T> IFuture<T> searchService(final Class<T> type, String scope) { if(shutdowned) { return new Future<T>(new ComponentTerminatedException(id)); } final Future<T> fut = new Future<T>(); SServiceProvider.getService(this, type, scope).addResultListener(new DelegationResultListener(fut) { public void customResultAvailable(Object result) { if(shutdowned) { fut.setException(new ComponentTerminatedException(id)); } else { fut.setResult((T)BasicServiceInvocationHandler.createRequiredServiceProxy(instance, instance.getExternalAccess(), adapter, (IService)result, null, new RequiredServiceInfo(type), null, realtime)); } } }); return (IFuture<T>)FutureFunctionality.getDelegationFuture(fut, new ComponentFutureFunctionality(instance.getExternalAccess(), adapter)); }
/** * Get one service of a type and only search upwards (parents). * @param type The class. * @return The corresponding service. */ public <T> IFuture<T> searchServiceUpwards(final Class<T> type) { if(shutdowned) { return new Future<T>(new ComponentTerminatedException(id)); } final Future<T> fut = new Future<T>(); SServiceProvider.getServiceUpwards(this, type).addResultListener(new DelegationResultListener(fut) { public void customResultAvailable(Object result) { if(shutdowned) { fut.setException(new ComponentTerminatedException(id)); } else { fut.setResult((T)BasicServiceInvocationHandler.createRequiredServiceProxy(instance, instance.getExternalAccess(), adapter, (IService)result, null, new RequiredServiceInfo(type), null, realtime)); } } }); return (IFuture<T>)FutureFunctionality.getDelegationFuture(fut, new ComponentFutureFunctionality(instance.getExternalAccess(), adapter)); }
/** * Get a required service. * @return The service. */ public <T> IFuture<T> getRequiredService(RequiredServiceInfo info, RequiredServiceBinding binding, boolean rebind, IRemoteFilter<T> filter) { if(shutdowned) { return new Future<T>(new ComponentTerminatedException(id)); } if(info.getMultiplexType()!=null) { T ms = getMultiService(info.getName(), (Class<T>)info.getMultiplexType().getType(instance.getClassLoader())); return new Future<T>(ms); } IFuture<T> fut = super.getRequiredService(info, binding, rebind, filter); return FutureFunctionality.getDelegationFuture(fut, new ComponentFutureFunctionality(instance.getExternalAccess(), adapter)); }
IFuture<T> fut = fetcher.getService(info, binding, rebind, filter); return FutureFunctionality.getDelegationFuture(fut, new ComponentFutureFunctionality(getComponent()));