/** * Unregisters the handler for the specified bag key. */ public static void remove(BagKey key) { instance.doRemove(key); }
@Override public TransitLayer transitlayer() { return new NoOpTransitLayer(); } }
@Override public NestedBaggageContext join(NestedBaggageContext left, NestedBaggageContext right) { if (left == null) { return right; } else { left.mergeWith(right); return left; } }
/** * <p> * Returns the {@link List} that backs this {@link AtomContext} object, so modifications to the list will be * reflected by this context and vice versa. {@link AtomContext} uses reference counting as an optimization, so a * call to this method might result in duplicating atoms if others currently hold a reference to them. * </p> * * @return the atoms of this {@link AtomContext} */ public List<ByteBuffer> getModifiableAtoms() { toExclusive(); return atoms(); }
/** * Create an empty {@link BaggageHandlerRegistry} */ static BaggageHandlerRegistry empty() { return new BaggageHandlerRegistry(new Registrations(new TreeMap<>())); }
@Override public void discard(AtomContext baggageContext) { if (baggageContext != null) { baggageContext.discard(); } }
/** * Look up the {@link BagKey} that the specified {@link BaggageHandler} is registered to */ public static BagKey get(BaggageHandler<?> handler) { return instance.doGet(handler); }
/** * Registers the provided key with the provided handler. It is recommended to statically configure the mapping from * keys to handlers as part of the process configuration, rather than calling this method. */ public static void add(BagKey key, BaggageHandler<?> handler) { instance.doAdd(key, handler); }
void discard() { atoms.deref(); atoms = null; }
@Override public BaggageProvider<? extends BaggageContext> provider() { return new NoOpBaggageContextProvider(); }
@Override public BaggageProvider<? extends BaggageContext> provider() { return new NestedBaggageContextProvider(); }
@Override public BaggageProvider<? extends BaggageContext> provider() { return new AtomContextProvider(); }
@Override public NestedBaggageContext branch(NestedBaggageContext from) { return from == null ? null : from.branch(); }
@Override public AtomContext branch(AtomContext from) { return from == null ? null : from.branch(); }
AtomContext(RefCount<List<ByteBuffer>> atoms) { this.atoms = atoms; this.atoms.ref(); }
@Override public BaggageProvider<? extends BaggageContext> provider() { return new BDLContextProvider(BaggageHandlerRegistry.instance); }
@Override public AtomContext join(AtomContext left, AtomContext right) { return left == null ? right : left.merge(right); }
BagKey doGet(BaggageHandler<?> handler) { return registrations.get(handler); }
void doRemove(BagKey key) { registrations = registrations.remove(key); }
AtomContext(List<ByteBuffer> atoms) { this(new RefCount<>(atoms)); }