/** * Add a reference and its associated with an injection site. * * @param reference the reference to add * @param injectionSite the injection site for the reference */ public void add(Reference<ComponentType> reference, InjectionSite injectionSite) { super.add(reference); Injectable injectable = new Injectable(InjectableType.REFERENCE, reference.getName()); addInjectionSite(injectionSite, injectable); injectionSiteMapping.put(reference, injectionSite); }
/** * Adds a callback proxy definition and its associated injection site * * @param definition the callback proxy definition * @param injectionSite the proxy injection site */ public void add(Callback definition, InjectionSite injectionSite) { definition.setParent(this); String name = definition.getName(); callbacks.put(name, definition); Injectable injectable = new Injectable(InjectableType.CALLBACK, name); addInjectionSite(injectionSite, injectable); injectionSiteMapping.put(definition, injectionSite); }
/** * Add a resource reference and its associated an injection site. * * @param definition the resource reference to add * @param injectionSite the injection site for the resource */ public void add(ResourceReference definition, InjectionSite injectionSite) { super.add(definition); Injectable injectable = new Injectable(InjectableType.RESOURCE, definition.getName()); addInjectionSite(injectionSite, injectable); injectionSiteMapping.put(definition, injectionSite); }
/** * Add a producer and its associated injection site. * * @param producer the producer to add * @param injectionSite the injection site for the producer */ public void add(Producer<ComponentType> producer, InjectionSite injectionSite) { super.add(producer); Injectable injectable = new Injectable(InjectableType.PRODUCER, producer.getName()); addInjectionSite(injectionSite, injectable); injectionSiteMapping.put(producer, injectionSite); }
/** * Add a property and its associated with an injection site. * * @param property the property to add * @param injectionSite the injection site for the property */ public void add(Property property, InjectionSite injectionSite) { super.add(property); Injectable injectable = new Injectable(InjectableType.PROPERTY, property.getName()); addInjectionSite(injectionSite, injectable); injectionSiteMapping.put(property, injectionSite); }
/** * Add a consumer and its associated accessible object. * * @param consumer the consumer to add * @param object the consumer method, field or ctor */ public void add(Consumer<ComponentType> consumer, InjectionSite injectionSite, AccessibleObject object) { super.add(consumer); Injectable injectable = new Injectable(InjectableType.CONSUMER, consumer.getName()); addInjectionSite(injectionSite, injectable); injectionSiteMapping.put(consumer, injectionSite); consumerSignatures.put(consumer.getName(), object); }
public PhysicalWireSource generateSource(LogicalReference reference) throws Fabric3Exception { SingletonWireSource source = new SingletonWireSource(); URI uri = reference.getUri(); source.setOptimizable(true); source.setUri(uri); source.setInjectable(new Injectable(InjectableType.REFERENCE, uri.getFragment())); return source; }
public PhysicalWireSource generateResourceSource(LogicalResourceReference<?> resourceReference) throws Fabric3Exception { URI uri = resourceReference.getUri(); SystemWireSource definition = new SystemWireSource(); definition.setOptimizable(true); definition.setUri(uri); String name = uri.getFragment(); Injectable injectable = new Injectable(InjectableType.RESOURCE, name); definition.setInjectable(injectable); return definition; }
public PhysicalWireSource generateResourceSource(LogicalResourceReference<?> resourceReference) throws Fabric3Exception { SingletonWireSource source = new SingletonWireSource(); URI uri = resourceReference.getUri(); source.setOptimizable(true); source.setUri(uri); source.setInjectable(new Injectable(InjectableType.RESOURCE, uri.getFragment())); return source; }
public void generateConnectionSource(JavaConnectionSource source, LogicalProducer producer) { URI uri = producer.getUri(); source.setUri(uri); ServiceContract serviceContract = producer.getDefinition().getServiceContract(); Class<?> interfaze = serviceContract.getInterfaceClass(); source.setInjectable(new Injectable(InjectableType.PRODUCER, uri.getFragment())); source.setServiceInterface(interfaze); }
public void generateResourceWireSource(JavaWireSource source, LogicalResourceReference<?> resourceReference) { URI uri = resourceReference.getUri(); JavaServiceContract serviceContract = (JavaServiceContract) resourceReference.getDefinition().getServiceContract(); source.setUri(uri); source.setInjectable(new Injectable(InjectableType.RESOURCE, uri.getFragment())); source.setInterfaceClass(serviceContract.getInterfaceClass()); }
public PhysicalConnectionSource generateConnectionSource(LogicalProducer producer) { SystemConnectionSource source = new SystemConnectionSource(); URI uri = producer.getUri(); JavaServiceContract serviceContract = (JavaServiceContract) producer.getDefinition().getServiceContract(); source.setUri(uri); source.setInjectable(new Injectable(InjectableType.PRODUCER, uri.getFragment())); source.setServiceInterface(serviceContract.getInterfaceClass()); return source; }
public void generateWireSource(JavaWireSource source, LogicalReference reference) { URI uri = reference.getUri(); JavaServiceContract serviceContract = (JavaServiceContract) reference.getDefinition().getServiceContract(); source.setUri(uri); source.setInjectable(new Injectable(InjectableType.REFERENCE, uri.getFragment())); source.setInterfaceClass(serviceContract.getInterfaceClass()); // assume for now that any wire from a Java component can be optimized source.setOptimizable(true); if (reference.getDefinition().isKeyed()) { source.setKeyed(true); DataType type = reference.getDefinition().getKeyDataType(); String className = type.getType().getName(); source.setKeyClassName(className); } }
public void generateCallbackWireSource(JavaWireSource source, LogicalComponent<? extends JavaImplementation> component, JavaServiceContract contract) { InjectingComponentType type = component.getDefinition().getImplementation().getComponentType(); String name = null; for (Callback entry : type.getCallbacks().values()) { // NB: This currently only supports the case where one callback injection site of the same type is on an implementation. ServiceContract candidate = entry.getServiceContract(); MatchResult result = matcher.isAssignableFrom(candidate, contract, false); if (result.isAssignable()) { name = entry.getName(); break; } } if (name == null) { String interfaze = contract.getQualifiedInterfaceName(); throw new Fabric3Exception("Callback injection site not found for type: " + interfaze); } Injectable injectable = new Injectable(InjectableType.CALLBACK, name); source.setInjectable(injectable); source.setInterfaceClass(contract.getInterfaceClass()); URI uri = URI.create(component.getUri().toString() + "#" + name); source.setUri(uri); source.setOptimizable(false); }
public PhysicalWireSource generateSource(LogicalReference reference) throws Fabric3Exception { URI uri = reference.getUri(); SystemWireSource definition = new SystemWireSource(); definition.setOptimizable(true); definition.setUri(uri); definition.setInjectable(new Injectable(InjectableType.REFERENCE, uri.getFragment())); JavaServiceContract serviceContract = (JavaServiceContract) reference.getDefinition().getServiceContract(); definition.setInterfaceClass(serviceContract.getInterfaceClass()); if (reference.getDefinition().isKeyed()) { definition.setKeyed(true); String className = reference.getDefinition().getKeyDataType().getType().getName(); definition.setKeyClassName(className); } return definition; }
@SuppressWarnings({"unchecked"}) public void generateConnectionTarget(JavaConnectionTarget target, LogicalConsumer consumer) { // Create an injectable for the consumer. Note in cases where the consumer is a method that is connected via an event stream and is used to receive // events rather than act as a setter for a direct connection, the injector will never be activated. Injectable injectable = new Injectable(InjectableType.CONSUMER, consumer.getUri().getFragment()); target.setInjectable(injectable); LogicalComponent<? extends JavaImplementation> component = (LogicalComponent<? extends JavaImplementation>) consumer.getParent(); URI uri = component.getUri(); target.setUri(uri); ServiceContract serviceContract = consumer.getDefinition().getServiceContract(); Class<?> interfaze = serviceContract.getInterfaceClass(); target.setServiceInterface(interfaze); InjectingComponentType type = component.getDefinition().getImplementation().getComponentType(); AccessibleObject object = type.getConsumerSite(consumer.getUri().getFragment()); if (object == null) { // programming error throw new Fabric3Exception("Consumer not found on: " + consumer.getUri()); } target.setConsumerSite(object); }
Injectable source = new Injectable(InjectableType.PROPERTY, name); if (property.getInstanceValue() != null) { factory.setSupplier(source, property::getInstanceValue);
Injectable source = new Injectable(InjectableType.PROPERTY, name); if (property.getInstanceValue() != null) { factory.setSupplier(source, property::getInstanceValue);