public @Override void resultChanged(LookupEvent ev) { synchronized (ProxyURLStreamHandlerFactory.this) { Collection<? extends URLStreamHandler> instances = result.allInstances(); handlers.put(protocol, instances.isEmpty() ? null : instances.iterator().next()); } } };
Collection<? extends ActionMap> ams = result.allInstances();
res = new ArrayList<URLMapper>(result.allInstances());
/** Blocks on lookup and after the lookup returns updates * delegates and adds a listener. */ public void initialize() { r = Lookup.getDefault().lookupResult(ErrorManager.class); setDelegates(r.allInstances()); }
/** Nodes are taken from the lookup if any. */ public final synchronized Node[] nodes() { if (result != null) { return result.allInstances().toArray(EMPTY_NODE_ARRAY); } else { return EMPTY_NODE_ARRAY; } }
@Override public Collection<? extends T> allInstances() { Collection<? extends T> res = delegate.allInstances(); synchronized (this) { if (!res.isEmpty()) { allInstances = res; } return allInstances; } }
@Override public void resultChanged(LookupEvent ev) { all = result.allInstances(); } }
if (r.allInstances().isEmpty()) {
all.addAll(result.allInstances()); MIMEResolver[] toRet = all.toArray(new MIMEResolver[all.size()]);
Iterator it = loaderQuery.allInstances().iterator(); if (it.hasNext()) { ClassLoader toReturn = (ClassLoader) it.next();
private Collection computeSingleResult(int i) { Collection one = null; switch (indexToCache) { case 0: if (!callBeforeLookup && arr[i] instanceof WaitableResult<?>) { WaitableResult<?> wr = (WaitableResult<?>) arr[i]; one = wr.allInstances(callBeforeLookup); } else { one = arr[i].allInstances(); } break; case 1: one = arr[i].allClasses(); break; case 2: if (!callBeforeLookup && arr[i] instanceof WaitableResult<?>) { WaitableResult<?> wr = (WaitableResult<?>) arr[i]; one = wr.allItems(callBeforeLookup); } else { one = arr[i].allItems(); } break; default: assert false : "Wrong index: " + indexToCache; } return one; }
public @Override InputSource resolveEntity(String publicID, String systemID) throws IOException, SAXException { if (result == null) { result = Lookup.getDefault().lookupResult(EntityCatalog.class); } for (EntityCatalog res : result.allInstances()) { // using resolver's method because EntityCatalog extends EntityResolver InputSource is = res.resolveEntity(publicID, systemID); if (is != null) { return is; } } if (systemID != null && systemID.startsWith("http")) { // NOI18N Logger.getLogger(EntityCatalog.class.getName()).log( /* More of a problem when blocking EQ; cf. #157850: */ EventQueue.isDispatchThread() ? Level.WARNING : Level.FINE, "No resolver found for {0}", systemID); } return null; } }
/** * Find all instances corresponding to a given class. * Equivalent to calling {@link #lookupResult} and asking for {@link Lookup.Result#allInstances} but slightly more convenient. * Subclasses may override this method to produce the same semantics more efficiently. * <div class="nonnormative"> * <p>Example usage:</p> * <pre> * for (MyService svc : Lookup.getDefault().lookupAll(MyService.class)) { * svc.useMe(); * } * </pre> * </div> * @param clazz the supertype of the result * @return all currently available instances of that type * @since org.openide.util 6.10 */ public <T> Collection<? extends T> lookupAll(Class<T> clazz) { return lookupResult(clazz).allInstances(); }
private static FileSystem[] computeDelegates() { List<FileSystem> arr = new ArrayList<FileSystem>(); arr.add(MEMORY); for (FileSystem f : ALL.allInstances()) { if (Boolean.TRUE.equals(f.getRoot().getAttribute("fallback"))) { // NOI18N continue; } arr.add(f); } arr.add(layers); for (FileSystem f : ALL.allInstances()) { if (Boolean.TRUE.equals(f.getRoot().getAttribute("fallback"))) { // NOI18N arr.add(f); } } return arr.toArray(new FileSystem[0]); }
/*** Finds an action that we should delegate to * @return the action or null */ private Action findAction() { Collection<? extends ActionMap> c = result != null ? result.allInstances() : Collections.<ActionMap>emptySet(); if (!c.isEmpty()) { Object key = delegate.getActionMapKey(); for (ActionMap map : c) { Action action = map.get(key); if (action != null) { return action; } } } return null; }
public java.util.Collection<? extends T> allInstances() { return checkResult().allInstances(); }
public String toString() { return "SimpleLookup" + lookup(new Template<Object>(Object.class)).allInstances(); }
@Override public Collection<? extends T> allInstances() { return openCol(result.allInstances(), 0); } @Override
/** Updates the delegates.*/ public void resultChanged(LookupEvent ev) { if (r != null) { setDelegates(r.allInstances()); } }
/** Blocks on lookup and after the lookup returns updates * delegates and adds a listener. */ public void initialize() { r = Lookup.getDefault().lookupResult(ErrorManager.class); setDelegates(r.allInstances()); }