/** * Put a file. * @param file The file data. * @param path The target path. * @return True, when the file has been copied. */ public ITerminableIntermediateFuture<Long> uploadFile(IInputConnection con, String path, String name) { try { return con.writeToOutputStream(new FileOutputStream(path+File.separator+name), agent); } catch(Exception e) { return new TerminableIntermediateFuture<Long>(e); } }
/** * Retrieve information about platforms as they appear or vanish. * @param include_initial If true, information about initially known platforms will be immediately posted to the caller. * Otherwise only changes that happen after the subscription will be posted. * @return An intermediate future that is notified about any changes. */ public ITerminableIntermediateFuture<DiscoveryInfo> subscribeToPlatformList(boolean include_initial) { if(listeners==null) { listeners = new LinkedHashSet<TerminableIntermediateFuture<DiscoveryInfo>>(); } TerminableIntermediateFuture<DiscoveryInfo> ret = new TerminableIntermediateFuture<DiscoveryInfo>(); listeners.add(ret); if(include_initial) { for(DiscoveryInfo dif: discovered.values()) { ret.addIntermediateResult(dif); } } return ret; }
final TerminableIntermediateFuture<Long> ret = new TerminableIntermediateFuture<Long>();
final TerminableIntermediateFuture<String> ret = new TerminableIntermediateFuture<String>(new ITerminationCommand()
/** * Get required services. * @return The services. */ public <T> ITerminableIntermediateFuture<T> getRequiredServices(RequiredServiceInfo info, RequiredServiceBinding binding, boolean rebind, IRemoteFilter<T> filter) { if(info==null) { TerminableIntermediateFuture<T> ret = new TerminableIntermediateFuture<T>(); ret.setException(new IllegalArgumentException("Info must not null.")); return ret; } IRequiredServiceFetcher fetcher = getRequiredServiceFetcher(info.getName()); return fetcher.getServices(info, binding, rebind, filter); }
/** * Search for services, starting at the given service provider. * @param provider The service provider to start the search at. * @param decider The visit decider to select nodes and terminate the search. * @param selector The result selector to select matching services and produce the final result. * @param services The local services of the provider (class->list of services). */ public ITerminableIntermediateFuture<IService> searchServices(IServiceProvider provider, IVisitDecider decider, IResultSelector selector, Map<Class<?>, Collection<IService>> services) { TerminableIntermediateFuture<IService> ret = new TerminableIntermediateFuture<IService>(); // if(selector instanceof TypeResultSelector && ((TypeResultSelector)selector).getType().toString().indexOf("IIntermediateResultService")!=-1) // { // System.out.println("sefuill ksd"); // } // local search is always allowed?! // problem: first gsm searches a node, then lsm searches the same node = double visit // if(!selector.isFinished(results))// && decider.searchNode(null, provider, results)) selector.selectServices(services) .addResultListener(new DelegationResultListener<Collection<IService>>(ret)); // if(selector instanceof TypeResultSelector && results.toString().indexOf("Add")!=-1) // System.out.println("lsm: "+provider+" "+results); return ret; }
final TerminableIntermediateFuture<Long> ret = new TerminableIntermediateFuture<Long>();
/** * Get a required services. * @return The services. */ public <T> ITerminableIntermediateFuture<T> getRequiredServices(String name, boolean rebind, IRemoteFilter<T> filter) { if(shutdowned) return new TerminableIntermediateFuture<T>(new ComponentTerminatedException(id)); RequiredServiceInfo info = getRequiredServiceInfo(name); if(info==null) { TerminableIntermediateFuture<T> ret = new TerminableIntermediateFuture<T>(); ret.setException(new ServiceNotFoundException(name)); return ret; } else { RequiredServiceBinding binding = info.getDefaultBinding();//getRequiredServiceBinding(name); return getRequiredServices(info, binding, rebind, filter); } }
return new TerminableIntermediateFuture<IService>(new ComponentTerminatedException(id));
/** * 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())); }
final TerminableIntermediateFuture<T> ret = new TerminableIntermediateFuture<T>(); SServiceProvider.getServices(provider, type, scope, (IRemoteFilter<T>) hardconstraints.getRemotableFilter()).addResultListener(new IResultListener<Collection<T>>()
final TerminableIntermediateFuture<T> ret = new TerminableIntermediateFuture<T>(); SServiceProvider.getServices(ea, type, scope, (IAsyncFilter<T>) hardconstraints.getRemotableFilter()).addResultListener(new IResultListener<Collection<T>>()
/** * Get a required services. * @return The services. */ public <T> ITerminableIntermediateFuture<T> getRequiredServices(String name, boolean rebind, IAsyncFilter<T> filter) { // if(shutdowned) // return new TerminableIntermediateFuture<T>(new ComponentTerminatedException(id)); RequiredServiceInfo info = getRequiredServiceInfo(name); if(info==null) { TerminableIntermediateFuture<T> ret = new TerminableIntermediateFuture<T>(); ret.setException(new ServiceNotFoundException(name)); return ret; } else { RequiredServiceBinding binding = info.getDefaultBinding();//getRequiredServiceBinding(name); return getRequiredServices(info, binding, rebind, filter); } }
/** * 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())); }
ti.setState(TransferInfo.STATE_WAITING); final TerminableIntermediateFuture<Long> ret = new TerminableIntermediateFuture<Long>(new TerminationCommand()
final IResultSelector selector, Map<Class<?>, Collection<IService>> services) final TerminableIntermediateFuture<IService> ret = new TerminableIntermediateFuture<IService>(); final TerminableIntermediateDelegationFuture<IService> del = new TerminableIntermediateDelegationFuture<IService>(); ret.addResultListener(new TerminableIntermediateDelegationResultListener<IService>(del, ret)
ti.setState(TransferInfo.STATE_WAITING); final TerminableIntermediateFuture<Long> ret = new TerminableIntermediateFuture<Long>(new TerminationCommand()
/** * 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())); }
ti.setState(TransferInfo.STATE_WAITING); final TerminableIntermediateFuture<Long> ret = new TerminableIntermediateFuture<Long>(new TerminationCommand()