public void endUpdate() { for (Map.Entry<Injectable, Supplier<?>> entry : factories.entrySet()) { // signal to multiplicity factories updates are complete Injectable injectable = entry.getKey(); Supplier<?> factory = entry.getValue(); if (InjectableType.REFERENCE == injectable.getType() || InjectableType.CALLBACK == injectable.getType()) { if (factory instanceof MultiplicitySupplier) { MultiplicitySupplier<?> multiplicitySupplier = (MultiplicitySupplier<?>) factory; multiplicitySupplier.endUpdate(); } } } }
public void startUpdate() { for (Map.Entry<Injectable, Supplier<?>> entry : factories.entrySet()) { // signal to multiplicity factories that previous contents should be overwritten if the factory is updated (e.g. during reinjection) Injectable injectable = entry.getKey(); Supplier<?> factory = entry.getValue(); if (InjectableType.REFERENCE == injectable.getType() || InjectableType.CALLBACK == injectable.getType()) { if (factory instanceof MultiplicitySupplier) { MultiplicitySupplier<?> multiplicitySupplier = (MultiplicitySupplier<?>) factory; multiplicitySupplier.startUpdate(); } } } }
public void endUpdate() { for (Map.Entry<Injectable, Supplier<?>> entry : factories.entrySet()) { // signal to multiplicity factories updates are complete Injectable injectable = entry.getKey(); Supplier<?> factory = entry.getValue(); if (InjectableType.REFERENCE == injectable.getType() || InjectableType.CALLBACK == injectable.getType()) { if (factory instanceof MultiplicitySupplier) { MultiplicitySupplier<?> multiplicitySupplier = (MultiplicitySupplier<?>) factory; multiplicitySupplier.endUpdate(); } } } }
public void startUpdate() { for (Map.Entry<Injectable, Supplier<?>> entry : factories.entrySet()) { // signal to multiplicity factories that previous contents should be overwritten if the factory is updated (e.g. during reinjection) Injectable injectable = entry.getKey(); Supplier<?> factory = entry.getValue(); if (InjectableType.REFERENCE == injectable.getType() || InjectableType.CALLBACK == injectable.getType()) { if (factory instanceof MultiplicitySupplier) { MultiplicitySupplier<?> multiplicitySupplier = (MultiplicitySupplier<?>) factory; multiplicitySupplier.startUpdate(); } } } }
/** * Adds a Supplier to be reinjected. Note only String keys are supported for singleton components to avoid a requirement on the transformer infrastructure. * * @param injectable the InjectableAttribute describing the site to reinject * @param supplier the Supplier responsible for supplying a value to reinject * @param attributes the injection attributes */ public void addSupplier(Injectable injectable, Supplier supplier, InjectionAttributes attributes) { if (InjectableType.REFERENCE == injectable.getType()) { setFactory(injectable, supplier, attributes); } else { // the factory corresponds to a property or context, which will override previous values if reinjected reinjectionMappings.put(supplier, injectable); } }
@SuppressWarnings("unchecked") public void setSupplier(Injectable injectable, Supplier<?> supplier, InjectionAttributes attributes) { if (InjectableType.REFERENCE == injectable.getType() || InjectableType.CALLBACK == injectable.getType()) { setUpdatableFactory(injectable, supplier, attributes); } else { // the factory corresponds to a property or context, which will override previous values if re-injected Supplier<?> factory = factories.get(injectable); if (factory instanceof UpdatableSupplier) { ((UpdatableSupplier) factory).update(supplier); } else { factories.put(injectable, supplier); } } }
@SuppressWarnings("unchecked") public void setSupplier(Injectable injectable, Supplier<?> supplier, InjectionAttributes attributes) { if (InjectableType.REFERENCE == injectable.getType() || InjectableType.CALLBACK == injectable.getType()) { setUpdatableFactory(injectable, supplier, attributes); } else { // the factory corresponds to a property or context, which will override previous values if re-injected Supplier<?> factory = factories.get(injectable); if (factory instanceof UpdatableSupplier) { ((UpdatableSupplier) factory).update(supplier); } else { factories.put(injectable, supplier); } } }
InjectionSite site = entry.getKey(); Injectable attribute = entry.getValue(); InjectableType type = attribute.getType(); Supplier<?> supplier = factories.get(attribute); if (supplier == null && (type == InjectableType.REFERENCE || type == InjectableType.CALLBACK)) {
InjectionSite site = entry.getKey(); Injectable attribute = entry.getValue(); InjectableType type = attribute.getType(); Supplier<?> supplier = factories.get(attribute); if (supplier == null && (type == InjectableType.REFERENCE || type == InjectableType.CALLBACK)) {
public void attach(JavaWireSource source, PhysicalWireTarget target, Wire wire) { URI sourceName = UriHelper.getDefragmentedName(source.getUri()); JavaComponent component = (JavaComponent) manager.getComponent(sourceName); if (component == null) { throw new Fabric3Exception("Source callback not found: " + sourceName); } Injectable injectable = source.getInjectable(); Class<?> type = source.getInterfaceClass(); if (InjectableType.CALLBACK.equals(injectable.getType())) { processCallback(wire, target, component, injectable, type); } else { processReference(wire, source, target, component, injectable, type); } }
public void attach(SystemWireSource source, PhysicalWireTarget target, Wire wire) { if (proxyService == null) { throw new Fabric3Exception("Attempt to inject a non-optimized wire during runtime bootstrap."); } URI sourceName = UriHelper.getDefragmentedName(source.getUri()); SystemComponent component = (SystemComponent) manager.getComponent(sourceName); Injectable injectable = source.getInjectable(); Class<?> type = source.getInterfaceClass(); if (InjectableType.CALLBACK.equals(injectable.getType())) { throw new UnsupportedOperationException("Callbacks are not supported on system components"); } else { String callbackUri = null; URI uri = target.getCallbackUri(); if (uri != null) { callbackUri = uri.toString(); } Supplier<?> factory = proxyService.createSupplier(type, wire, callbackUri); if (source.isKeyed() || source.isOrdered()) { Object key = getKey(source, target); int order = source.getOrder(); InjectionAttributes attributes = new InjectionAttributes(key, order); component.setSupplier(injectable, factory, attributes); } else { component.setSupplier(injectable, factory); } } }