/** * Creates an {@link IIntermediateResultListener} that delegates results and exceptions to a given IntermediateFuture. * * @param delegate The future used for intermediate and final result delegation. * @param undone Flag if undone methods should be used. * @param customResultListener Custom result listener that overwrites the delegation behaviour. * @param customIntermediateResultListener Custom intermediate result listener that overwrites the delegation behaviour. * @return {@link IntermediateDelegationResultListener} */ public static <E> IIntermediateResultListener<E> delegate(final IntermediateFuture<E> delegate, boolean undone, IFunctionalResultListener<Collection<E>> customResultListener, IFunctionalIntermediateResultListener<E> customIntermediateResultListener) { return new IntermediateDelegationResultListener<E>(delegate, undone, customResultListener, customIntermediateResultListener); }
public void exceptionOccurred(Exception exception) { checkAsyncFilters(filter, it).addResultListener(new IntermediateDelegationResultListener<T>(ret)); } });
public void customResultAvailable(final IComponentIdentifier cid) { callServices(cid, testno, -1).addResultListener(new IntermediateDelegationResultListener<TestReport>(ret)); }
public void resultAvailable(Boolean result) { if(result!=null && result.booleanValue()) { ret.addIntermediateResult(ser); } checkAsyncFilters(filter, it).addResultListener(new IntermediateDelegationResultListener<T>(ret)); }
public void customResultAvailable(Boolean result) { if(result.booleanValue() && !ret.getIntermediateResults().contains(services[i])) { ret.addIntermediateResult(services[i]); } if(i+1<services.length) { getAllResults(filter, services, i+1) .addResultListener(new IntermediateDelegationResultListener<IService>(ret)); } else { ret.setFinished(); } } });
/** * Search for services. */ // read public <T> ISubscriptionIntermediateFuture<T> searchServices(ClassInfo type, IComponentIdentifier cid, String scope, IAsyncFilter<T> filter) { final SubscriptionIntermediateFuture<T> ret = new SubscriptionIntermediateFuture<T>(); Iterator<T> sers = (Iterator<T>)getServices(type); if(sers!=null && sers.hasNext() && !RequiredServiceInfo.SCOPE_NONE.equals(scope)) { Collection<T> ssers = checkScope(sers, cid, scope, false); checkAsyncFilters(filter, ssers.iterator()).addResultListener(new IntermediateDelegationResultListener<T>(ret)); // filter checks in loop are possibly performed outside of synchornized block // searchLoopServices(filter, sers, cid, scope).addResultListener(new IntermediateDelegationResultListener<T>(ret)); } else { ret.setFinished(); } return ret; }
/** * Set the input connection. */ protected void setInputConnection(IInputConnection con) { if(this.con!=null) throw new RuntimeException("Connection already set."); this.con = con; if(future!=null) { con.aread().addResultListener(new IntermediateDelegationResultListener<byte[]>(future)); } if(closed) { con.close(); } if(transfercommand!=null) { transfercommand.execute(null); } }
/** * Set the input connection. */ protected void setInputConnection(IInputConnection con) { if(this.con!=null) throw new RuntimeException("Connection already set."); this.con = con; if(future!=null) { con.aread().addResultListener(new IntermediateDelegationResultListener<byte[]>(future)); } if(closed) { con.close(); } if(transfercommand!=null) { transfercommand.execute(null); } }
ret.addResultListener(new IntermediateDelegationResultListener<TestReport>(res) callServices(cid, testno, -1).addResultListener(new IntermediateDelegationResultListener<TestReport>(ret));
/** * Get all declared services of the given provider. * @return The corresponding services. */ public static IIntermediateFuture<IService> getDeclaredServices(IServiceProvider provider) { // synchronized(profiling) // { // Integer cnt = (Integer)profiling.get(type); // profiling.put(type, Integer.valueOf(cnt!=null ? cnt.intValue()+1 : 1)); // } final IntermediateFuture<IService> ret = new IntermediateFuture<IService>(); // Hack->remove // IVisitDecider contdecider = new DefaultVisitDecider(false); // if(Proxy.isProxyClass(provider.getClass())) // System.out.println("herere"); provider.getServices(getSearchManager(false, RequiredServiceInfo.SCOPE_LOCAL), contdecider, contanyselector) .addResultListener(new IntermediateDelegationResultListener<IService>(ret)); return ret; }
public IFuture<Void> execute(Void args) { ISubscriptionIntermediateFuture<T> fut = delegate.addQuery(query); fut.addIntermediateResultListener(new IntermediateDelegationResultListener<T>(ret)); final Future<Void> myret = new Future<Void>(); fut.addIntermediateResultListener(new IIntermediateResultListener<T>() { public void finished() { myret.setResult(null); } public void exceptionOccurred(Exception exception) { myret.setException(exception); } public void intermediateResultAvailable(T result) { } public void resultAvailable(Collection<T> result) { finished(); } }); return myret; }
/** * Test remote. */ protected IIntermediateFuture<TestReport> testRemote(final int testno) { final IntermediateFuture<TestReport> ret = new IntermediateFuture<TestReport>(); createPlatform(null/*new String[]{"-gui", "true", "-logging", "true"}*/).addResultListener(agent.getComponentFeature(IExecutionFeature.class).createResultListener( new ExceptionDelegationResultListener<IExternalAccess, Collection<TestReport>>(ret) { public void customResultAvailable(final IExternalAccess platform) { ComponentIdentifier.getTransportIdentifier(platform).addResultListener(new ExceptionDelegationResultListener<ITransportComponentIdentifier, Collection<TestReport>>(ret) { public void customResultAvailable(ITransportComponentIdentifier result) { performTests(result, testno, false) .addResultListener(agent.getComponentFeature(IExecutionFeature.class).createResultListener(new IntermediateDelegationResultListener<TestReport>(ret))); } }); } })); return ret; }
/** * Test local. */ protected IIntermediateFuture<TestReport> testLocal(final int testno) { final IntermediateFuture<TestReport> ret = new IntermediateFuture<TestReport>(); performTests(agent.getComponentIdentifier().getRoot(), testno, true) .addResultListener(agent.getComponentFeature(IExecutionFeature.class).createResultListener(new IntermediateDelegationResultListener<TestReport>(ret))); return ret; }
checkAsyncFilters(filter, it).addResultListener(new IntermediateDelegationResultListener<T>(ret));
/** * Get a file filter according to current file type settings. */ protected IIntermediateFuture<FileData> listFiles() { final IntermediateFuture<FileData> ret = new IntermediateFuture<FileData>(); if(file instanceof RemoteJarFile) { RemoteJarFile myfile = (RemoteJarFile)file; Collection<FileData> files = myfile.listFiles(); ret.setResult(files); } else { SRemoteGui.listFiles(file, factory.getFileFilter(), exta) .addResultListener(new IntermediateDelegationResultListener<FileData>(ret)); } return ret; }
super.addQuery(query).addIntermediateResultListener(new IntermediateDelegationResultListener<T>(ret));
public void customResultAvailable(Void result) { if(!RequiredServiceInfo.SCOPE_GLOBAL.equals(scope)) { if(filter==null) { Collection<T> sers = SynchronizedServiceRegistry.getRegistry(component).searchServices(new ClassInfo(type), cid, scope); if(proxy) sers = createRequiredProxies(component, sers, type); ret.setResult(sers==null? Collections.EMPTY_SET: sers); } else { IIntermediateResultListener<T> lis = proxy? new IntermediateProxyResultListener<T>(ret, component, type): new IntermediateDelegationResultListener<T>(ret); SynchronizedServiceRegistry.getRegistry(component).searchServices(new ClassInfo(type), cid, scope, filter) .addResultListener(new IntermediateComponentResultListener<T>(lis, component)); } } else { IIntermediateResultListener<T> lis = proxy? new IntermediateProxyResultListener<T>(ret, component, type): new IntermediateDelegationResultListener<T>(ret); ISubscriptionIntermediateFuture<T> fut = SynchronizedServiceRegistry.getRegistry(component).searchGlobalServices(new ClassInfo(type), cid, filter); fut.addResultListener(new IntermediateComponentResultListener<T>(lis, component)); } } });
public void customResultAvailable(Void result) { if(!RequiredServiceInfo.SCOPE_GLOBAL.equals(scope)) { if(filter==null) { Collection<T> sers = SynchronizedServiceRegistry.getRegistry(component).searchServices(type, component.getComponentIdentifier(), scope); if(proxy) sers = createRequiredProxies(component, sers, type); ret.setResult(sers==null? Collections.EMPTY_SET: sers); } else { IIntermediateResultListener<T> lis = proxy? new IntermediateProxyResultListener<T>(ret, component, type.getType(component.getClassLoader())): new IntermediateDelegationResultListener<T>(ret); SynchronizedServiceRegistry.getRegistry(component).searchServices(type, component.getComponentIdentifier(), scope, filter) .addResultListener(new IntermediateComponentResultListener<T>(lis, component)); } } else { IIntermediateResultListener<T> lis = proxy? new IntermediateProxyResultListener<T>(ret, component, type.getType(component.getClassLoader())): new IntermediateDelegationResultListener<T>(ret); ISubscriptionIntermediateFuture<T> fut = SynchronizedServiceRegistry.getRegistry(component).searchGlobalServices(type, component.getComponentIdentifier(), filter); fut.addResultListener(new IntermediateComponentResultListener<T>(lis, component)); } } });
source.addResultListener(new IntermediateDelegationResultListener((IntermediateFuture)target));
source.addResultListener(new IntermediateDelegationResultListener((IntermediateFuture)target));