transaction = t.beginTransaction(collection.size()); if (t.add(item, transaction)) { t.retainAll(shouldBeThere, transaction); t.endTransaction(transaction, toNotify);
/** Method to be called when a result is cleared to signal that the list * of all result should be checked for clearing. * @param template the template the result was for * @return true if the hash map with all items has been cleared */ <T> boolean cleanUpResult(Lookup.Template<T> template) { AbstractLookup.Storage<?> t = enterStorage(); try { return t.cleanUpResult(template) == null; } finally { exitStorage(); Thread.yield(); } }
/** Implements the search for allItems, but without asking for before lookup */ private Collection<Pair<T>> allItemsWithoutBeforeLookup() { Pair<T>[] c = getItemsCache(); if (c != null) { return Collections.unmodifiableList(Arrays.asList(c)); } ArrayList<Pair<Object>> saferCheck = null; AbstractLookup.Storage<?> t = reference.lookup.enterStorage(); try { try { return Collections.unmodifiableCollection(initItems(t)); } catch (AbstractLookup.ISE ex) { // do less effective evaluation of items outside of the // locked storage saferCheck = new ArrayList<Pair<Object>>(); Enumeration<Pair<Object>> en = t.lookup(null); // get all Pairs while (en.hasMoreElements()) { Pair<Object> i = en.nextElement(); saferCheck.add(i); } } } finally { reference.lookup.exitStorage(); } return extractPairs(saferCheck); }
transaction = t.beginTransaction(collection.size()); if (t.add(item, transaction)) { t.retainAll(shouldBeThere, transaction); t.endTransaction(transaction, toNotify);
transaction = t.beginTransaction(collection.size ()); while (it.hasNext ()) { Pair item = (Pair)it.next (); if (t.add (item, transaction)) { t.retainAll (shouldBeThere, transaction); t.endTransaction(transaction, toNotify);
transaction = t.beginTransaction(collection.size ()); while (it.hasNext ()) { Pair item = (Pair)it.next (); if (t.add (item, transaction)) { t.retainAll (shouldBeThere, transaction); t.endTransaction(transaction, toNotify);
transaction = t.beginTransaction(collection.size()); if (t.add(item, transaction)) { t.retainAll(shouldBeThere, transaction); t.endTransaction(transaction, toNotify);
Enumeration en = t.lookup (null); // get all Pairs while (en.hasMoreElements ()) { Pair i = (Pair)en.nextElement ();;
Enumeration en = t.lookup (null); // get all Pairs while (en.hasMoreElements ()) { Pair i = (Pair)en.nextElement ();;
AbstractLookup.Storage t = enterStorage (); try { transaction = t.beginTransaction(-2); if (t.add (pair, transaction)) { try { pair.setIndex(t, count++); } catch (IllegalStateException ex) { t.remove (pair, transaction); t.endTransaction (transaction, toNotify); } else { t.endTransaction (transaction, new HashSet ());
AbstractLookup.Storage t = enterStorage (); try { transaction = t.beginTransaction(-2); if (t.add (pair, transaction)) { try { pair.setIndex(t, count++); } catch (IllegalStateException ex) { t.remove (pair, transaction); t.endTransaction (transaction, toNotify); } else { t.endTransaction (transaction, new HashSet ());
public Transaction beginTransaction(int ensure) { try { return delegate.beginTransaction(ensure); } catch (UnsupportedOperationException ex) { // let's convert to InheritanceTree ArrayStorage arr = (ArrayStorage) delegate; InheritanceTree inh = new InheritanceTree(); changeDelegate(inh); // // Copy content // Enumeration<Pair<Object>> en = arr.lookup(Object.class); while (en.hasMoreElements()) { if (!inh.add(en.nextElement(), new ArrayList<Class>())) { throw new IllegalStateException("All objects have to be accepted"); // NOI18N } } // // Copy listeners // AbstractLookup.ReferenceToResult<?> ref = arr.cleanUpResult(null); if (ref != null) { ref.cloneList(inh); } // we have added the current content and now we can start transaction return delegate.beginTransaction(ensure); } }
public Transaction beginTransaction(int ensure) { try { return delegate.beginTransaction(ensure); } catch (UnsupportedOperationException ex) { // let's convert to InheritanceTree ArrayStorage arr = (ArrayStorage) delegate; InheritanceTree inh = new InheritanceTree(); changeDelegate(inh); // // Copy content // Enumeration<Pair<Object>> en = arr.lookup(Object.class); while (en.hasMoreElements()) { if (!inh.add(en.nextElement(), new ArrayList<Class>())) { throw new IllegalStateException("All objects have to be accepted"); // NOI18N } } // // Copy listeners // AbstractLookup.ReferenceToResult<?> ref = arr.cleanUpResult(null); if (ref != null) { ref.cloneList(inh); } // we have added the current content and now we can start transaction return delegate.beginTransaction(ensure); } }
@Override public final <T> Lookup.Item<T> lookupItem(Lookup.Template<T> template) { AbstractLookup.this.beforeLookup(template); ArrayList<Pair<T>> list = null; AbstractLookup.Storage<?> t = enterStorage(); try { Enumeration<Pair<T>> en; try { en = t.lookup(template.getType()); return findSmallest(en, template, false); } catch (AbstractLookup.ISE ex) { // not possible to enumerate the exception, ok, copy it // to create new list = new ArrayList<Pair<T>>(); en = t.lookup(null); // this should get all the items without any checks // the checks will be done out side of the storage while (en.hasMoreElements()) { list.add(en.nextElement()); } } } finally { exitStorage(); } return findSmallest(Collections.enumeration(list), template, true); }
/** Implements the search for allItems, but without asking for before lookup */ private Collection<Pair<T>> allItemsWithoutBeforeLookup() { Pair<T>[] c = getItemsCache(); if (c != null) { return Collections.unmodifiableList(Arrays.asList(c)); } ArrayList<Pair<Object>> saferCheck = null; AbstractLookup.Storage<?> t = reference.lookup.enterStorage(); try { try { return Collections.unmodifiableCollection(initItems(t)); } catch (AbstractLookup.ISE ex) { // do less effective evaluation of items outside of the // locked storage saferCheck = new ArrayList<Pair<Object>>(); Enumeration<Pair<Object>> en = t.lookup(null); // get all Pairs while (en.hasMoreElements()) { Pair<Object> i = en.nextElement(); saferCheck.add(i); } } } finally { reference.lookup.exitStorage(); } return extractPairs(saferCheck); }
/** Implements the search for allItems, but without asking for before lookup */ private Collection<Pair<T>> allItemsWithoutBeforeLookup() { Pair<T>[] c = getItemsCache(); if (c != null) { return Collections.unmodifiableList(Arrays.asList(c)); } ArrayList<Pair<Object>> saferCheck = null; AbstractLookup.Storage<?> t = reference.lookup.enterStorage(); try { try { return Collections.unmodifiableCollection(initItems(t)); } catch (AbstractLookup.ISE ex) { // do less effective evaluation of items outside of the // locked storage saferCheck = new ArrayList<Pair<Object>>(); Enumeration<Pair<Object>> en = t.lookup(null); // get all Pairs while (en.hasMoreElements()) { Pair<Object> i = en.nextElement(); saferCheck.add(i); } } } finally { reference.lookup.exitStorage(); } return extractPairs(saferCheck); }
public Object beginTransaction(int ensure) { try { return delegate.beginTransaction (ensure); } catch (UnsupportedOperationException ex) { if (!delegate.add ((AbstractLookup.Pair)en.nextElement(), new ArrayList ())) { throw new IllegalStateException ("All objects have to be accepted"); // NOI18N return delegate.beginTransaction(ensure);
public Object beginTransaction(int ensure) { try { return delegate.beginTransaction (ensure); } catch (UnsupportedOperationException ex) { if (!delegate.add ((AbstractLookup.Pair)en.nextElement(), new ArrayList ())) { throw new IllegalStateException ("All objects have to be accepted"); // NOI18N return delegate.beginTransaction(ensure);