private <I> ScopedComponent createPhysicalComponent(LogicalComponent<?> logicalComponent, I instance) { URI uri = logicalComponent.getUri(); InjectingComponentType type = (InjectingComponentType) logicalComponent.getDefinition().getComponentType(); type.getInjectionSites(); return new SingletonComponent(uri, instance, type.getInjectionSites(), BOOT_CONTRIBUTION); }
private <I> ScopedComponent createPhysicalComponent(LogicalComponent<?> logicalComponent, I instance) { URI uri = logicalComponent.getUri(); InjectingComponentType type = (InjectingComponentType) logicalComponent.getDefinition().getComponentType(); type.getInjectionSites(); return new SingletonComponent(uri, instance, type.getInjectionSites(), BOOT_CONTRIBUTION); }
public void processInjectionSites(InjectingComponentType componentType, ImplementationManagerDefinition managerDefinition) { Map<InjectionSite, Injectable> mappings = componentType.getInjectionSites(); // add injections for all the active constructor args Map<InjectionSite, Injectable> construction = managerDefinition.getConstruction(); Constructor<?> constructor = componentType.getConstructor(); Set<Injectable> byConstruction = new HashSet<>(); if (constructor != null) { for (int i = 0; i < constructor.getParameterTypes().length; i++) { InjectionSite site = new ConstructorInjectionSite(constructor, i); Injectable attribute = mappings.get(site); construction.put(site, attribute); byConstruction.add(attribute); } } // add field/method injections Map<InjectionSite, Injectable> postConstruction = managerDefinition.getPostConstruction(); Map<InjectionSite, Injectable> reinjection = managerDefinition.getReinjectables(); for (Map.Entry<InjectionSite, Injectable> entry : mappings.entrySet()) { InjectionSite site = entry.getKey(); if (site instanceof ConstructorInjectionSite) { continue; } Injectable attribute = entry.getValue(); if (!byConstruction.contains(attribute)) { postConstruction.put(site, attribute); } reinjection.put(site, attribute); } }
public void processInjectionSites(InjectingComponentType componentType, ImplementationManagerDefinition managerDefinition) { Map<InjectionSite, Injectable> mappings = componentType.getInjectionSites(); // add injections for all the active constructor args Map<InjectionSite, Injectable> construction = managerDefinition.getConstruction(); Constructor<?> constructor = componentType.getConstructor(); Set<Injectable> byConstruction = new HashSet<>(); if (constructor != null) { for (int i = 0; i < constructor.getParameterTypes().length; i++) { InjectionSite site = new ConstructorInjectionSite(constructor, i); Injectable attribute = mappings.get(site); construction.put(site, attribute); byConstruction.add(attribute); } } // add field/method injections Map<InjectionSite, Injectable> postConstruction = managerDefinition.getPostConstruction(); Map<InjectionSite, Injectable> reinjection = managerDefinition.getReinjectables(); for (Map.Entry<InjectionSite, Injectable> entry : mappings.entrySet()) { InjectionSite site = entry.getKey(); if (site instanceof ConstructorInjectionSite) { continue; } Injectable attribute = entry.getValue(); if (!byConstruction.contains(attribute)) { postConstruction.put(site, attribute); } reinjection.put(site, attribute); } }
void evaluateFields(InjectingComponentType componentType, Class<?> implClass, IntrospectionContext context) { Map<InjectionSite, Injectable> sites = componentType.getInjectionSites(); TypeMapping typeMapping = context.getTypeMapping(implClass); Set<Field> fields = helper.getInjectionFields(implClass); for (Field field : fields) { InjectionSite site = new FieldInjectionSite(field); // skip sites that have already been mapped if (sites.containsKey(site)) { continue; } String name = helper.getSiteName(field, null); Type parameterType = field.getGenericType(); processSite(componentType, typeMapping, name, field, parameterType, site, context); } }
void evaluateSetters(InjectingComponentType componentType, Class<?> implClass, IntrospectionContext context) { Map<InjectionSite, Injectable> sites = componentType.getInjectionSites(); TypeMapping typeMapping = context.getTypeMapping(implClass); Set<Method> setters = helper.getInjectionMethods(implClass, componentType.getServices().values()); for (Method setter : setters) { InjectionSite site = new MethodInjectionSite(setter, 0); // skip sites that have already been mapped if (sites.containsKey(site)) { continue; } String name = helper.getSiteName(setter, null); Type parameterType = setter.getGenericParameterTypes()[0]; processSite(componentType, typeMapping, name, setter, parameterType, site, context); } }
void evaluateConstructor(InjectingComponentType componentType, Class<?> implClass, IntrospectionContext context) { Map<InjectionSite, Injectable> sites = componentType.getInjectionSites(); Constructor<?> constructor = componentType.getConstructor(); TypeMapping typeMapping = context.getTypeMapping(implClass); Type[] parameterTypes = constructor.getGenericParameterTypes(); for (int i = 0; i < parameterTypes.length; i++) { InjectionSite site = new ConstructorInjectionSite(constructor, i); // skip sites that have already been mapped if (sites.containsKey(site)) { continue; } Type parameterType = parameterTypes[i]; String name = helper.getSiteName(constructor, i, null); processSite(componentType, typeMapping, name, constructor, parameterType, site, context); } }
private void evaluateFields(InjectingComponentType componentType, Class<?> implClass, IntrospectionContext context) { Map<InjectionSite, Injectable> sites = componentType.getInjectionSites(); Set<Field> fields = helper.getInjectionFields(implClass); for (Field field : fields) { InjectionSite site = new FieldInjectionSite(field); // skip sites that have already been mapped if (sites.containsKey(site)) { continue; } String name = helper.getSiteName(field, null); TypeMapping typeMapping = context.getTypeMapping(implClass); Class<?> parameterType = helper.getBaseType(field.getGenericType(), typeMapping); processSite(componentType, name, field, parameterType, implClass, site, context); } }
private void evaluateSetters(InjectingComponentType componentType, Class<?> implClass, IntrospectionContext context) { Map<InjectionSite, Injectable> sites = componentType.getInjectionSites(); Set<Method> setters = helper.getInjectionMethods(implClass, componentType.getServices().values()); for (Method setter : setters) { InjectionSite site = new MethodInjectionSite(setter, 0); // skip sites that have already been mapped if (sites.containsKey(site)) { continue; } String name = helper.getSiteName(setter, null); TypeMapping typeMapping = context.getTypeMapping(implClass); Type genericType = setter.getGenericParameterTypes()[0]; Class<?> parameterType = helper.getBaseType(genericType, typeMapping); processSite(componentType, name, setter, parameterType, implClass, site, context); } }
private void evaluateConstructor(InjectingComponentType componentType, Class<?> implClass, IntrospectionContext context) { Constructor<?> constructor = componentType.getConstructor(); if (constructor == null) { return; } Map<InjectionSite, Injectable> sites = componentType.getInjectionSites(); Type[] parameterTypes = constructor.getGenericParameterTypes(); for (int i = 0; i < parameterTypes.length; i++) { InjectionSite site = new ConstructorInjectionSite(constructor, i); // skip sites that have already been mapped if (sites.containsKey(site)) { continue; } TypeMapping typeMapping = context.getTypeMapping(implClass); Class<?> parameterType = helper.getBaseType(parameterTypes[i], typeMapping); String name = helper.getSiteName(constructor, i, null); processSite(componentType, name, constructor, parameterType, implClass, site, context); } }
for (Map.Entry<InjectionSite, Injectable> entry : tempType.getInjectionSites().entrySet()) { componentType.addMapping(tempType.getImplClass().getName(), entry.getKey(), entry.getValue());