private final void writeObject(ObjectOutputStream oos) throws IOException { AbstractLookup.Storage s = enterStorage(); try { // #36830: Serializing only InheritanceTree no ArrayStorage s.beginTransaction(Integer.MAX_VALUE); // #32040: don't write half-made changes oos.defaultWriteObject(); } finally { exitStorage(); } }
/** Getter for set of pairs. Package private contract with MetaInfServicesLookup. * @return a LinkedHashSet that can be modified */ final LinkedHashSet<Pair<?>> getPairsAsLHS() { AbstractLookup.Storage<?> t = enterStorage(); try { Enumeration<Pair<Object>> en = t.lookup(Object.class); TreeSet<Pair<?>> arr = new TreeSet<Pair<?>>(ALPairComparator.DEFAULT); while (en.hasMoreElements()) { Pair<Object> item = en.nextElement(); arr.add(item); } return new LinkedHashSet<Pair<?>>(arr); } finally { exitStorage(); } }
/** 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(); } }
private <Transaction> void removePairImpl(Pair<?> pair, Executor notifyIn) { HashSet<R> toNotify = new HashSet<R>(); AbstractLookup.Storage<Transaction> t = enterStorage(); Transaction transaction = null; try { transaction = t.beginTransaction(-1); t.remove(pair, transaction); t.endTransaction(transaction, toNotify); } finally { exitStorage(); } notifyIn(notifyIn, toNotify); }
HashSet<R> toNotify = new HashSet<R>(27); AbstractLookup.Storage<Transaction> t = enterStorage(); Transaction transaction = null;
@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); }
private final <Transaction> void addPairImpl(Pair<?> pair, Executor notifyIn) { HashSet<R> toNotify = new HashSet<R>(); AbstractLookup.Storage<Transaction> t = enterStorage(); Transaction transaction = null; try { transaction = t.beginTransaction(-2); if (t.add(pair, transaction)) { try { pair.setIndex(t, count++); } catch (IllegalStateException ex) { // remove the pair t.remove(pair, transaction); // rethrow the exception throw ex; } // if the pair is newly added and was not there before t.endTransaction(transaction, toNotify); } else { // just finish the process by calling endTransaction t.endTransaction(transaction, new HashSet<R>()); } } finally { exitStorage(); } notifyIn(notifyIn, toNotify); }
@Override public final <T> Lookup.Result<T> lookup(Lookup.Template<T> template) { beforeLookupResult(template); for (;;) { AbstractLookup.ISE toRun = null; AbstractLookup.Storage<?> t = enterStorage(); try { R<T> r = new R<T>(); ReferenceToResult<T> newRef = new ReferenceToResult<T>(r, this, template); newRef.next = t.registerReferenceToResult(newRef); return r; } catch (AbstractLookup.ISE ex) { toRun = ex; } finally { exitStorage(); } toRun.recover(this); // and try again } }
private final void writeObject(ObjectOutputStream oos) throws IOException { AbstractLookup.Storage s = enterStorage(); try { // #36830: Serializing only InheritanceTree no ArrayStorage s.beginTransaction(Integer.MAX_VALUE); // #32040: don't write half-made changes oos.defaultWriteObject(); } finally { exitStorage(); } }
private final void writeObject(ObjectOutputStream oos) throws IOException { AbstractLookup.Storage s = enterStorage (); try { // #36830: Serializing only InheritanceTree no ArrayStorage s.beginTransaction(Integer.MAX_VALUE); // #32040: don't write half-made changes oos.defaultWriteObject(); } finally { exitStorage (); } }
private final void writeObject(ObjectOutputStream oos) throws IOException { AbstractLookup.Storage s = enterStorage(); try { // #36830: Serializing only InheritanceTree no ArrayStorage s.beginTransaction(Integer.MAX_VALUE); // #32040: don't write half-made changes oos.defaultWriteObject(); } finally { exitStorage(); } }
private final void writeObject(ObjectOutputStream oos) throws IOException { AbstractLookup.Storage s = enterStorage (); try { // #36830: Serializing only InheritanceTree no ArrayStorage s.beginTransaction(Integer.MAX_VALUE); // #32040: don't write half-made changes oos.defaultWriteObject(); } finally { exitStorage (); } }
/** 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(); } }
/** 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(); } }
/** 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 */ boolean cleanUpResult (Lookup.Template template) { AbstractLookup.Storage t = enterStorage (); try { return t.cleanUpResult (template) == null; } finally { exitStorage (); } }
/** 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 */ boolean cleanUpResult (Lookup.Template template) { AbstractLookup.Storage t = enterStorage (); try { return t.cleanUpResult (template) == null; } finally { exitStorage (); } }
private <Transaction> void removePairImpl(Pair<?> pair, Executor notifyIn) { HashSet<R> toNotify = new HashSet<R>(); AbstractLookup.Storage<Transaction> t = enterStorage(); Transaction transaction = null; try { transaction = t.beginTransaction(-1); t.remove(pair, transaction); t.endTransaction(transaction, toNotify); } finally { exitStorage(); } notifyIn(notifyIn, toNotify); }
private <Transaction> void removePairImpl(Pair<?> pair, Executor notifyIn) { HashSet<R> toNotify = new HashSet<R>(); AbstractLookup.Storage<Transaction> t = enterStorage(); Transaction transaction = null; try { transaction = t.beginTransaction(-1); t.remove(pair, transaction); t.endTransaction(transaction, toNotify); } finally { exitStorage(); } notifyIn(notifyIn, toNotify); }
/** Remove instance. * @param pair class/instance pair */ protected final void removePair (Pair pair) { HashSet toNotify = new HashSet (); Object transaction = null; AbstractLookup.Storage t = enterStorage (); try { transaction = t.beginTransaction(-1); t.remove (pair, transaction); t.endTransaction (transaction, toNotify); } finally { exitStorage (); } notifyListeners (toNotify); }
/** Remove instance. * @param pair class/instance pair */ protected final void removePair (Pair pair) { HashSet toNotify = new HashSet (); Object transaction = null; AbstractLookup.Storage t = enterStorage (); try { transaction = t.beginTransaction(-1); t.remove (pair, transaction); t.endTransaction (transaction, toNotify); } finally { exitStorage (); } notifyListeners (toNotify); }