public void visitField(Binding annotation, Field field, Class<?> implClass, InjectingComponentType componentType, IntrospectionContext context) { if (field.isAnnotationPresent(Reference.class)) { return; } String name = helper.getSiteName(field, ""); if (componentType.getReferences().containsKey(name)) { // reference already introspected, e.g. repeatable annotations return; } referenceProcessor.addDefinition(field, "", true, implClass, componentType, context); } }
public void visitMethod(Monitor annotation, Method method, Class<?> implClass, InjectingComponentType componentType, IntrospectionContext context) { String name = helper.getSiteName(method, null); TypeMapping typeMapping = context.getTypeMapping(implClass); Type genericType = helper.getGenericType(method); Class<?> type = helper.getBaseType(genericType, typeMapping); MethodInjectionSite site = new MethodInjectionSite(method, 0); MonitorResourceReference resource = createDefinition(name, annotation, type, componentType, context); componentType.add(resource, site); }
@SuppressWarnings({"unchecked"}) private DataType<?> getDataType(Type type, TypeMapping typeMapping) { if (type instanceof Class) { // non-generic type Class<?> nonGenericType = (Class<?>) type; if (nonGenericType.isPrimitive()) { // convert primitive representation to its object equivalent nonGenericType = ParamTypes.PRIMITIVE_TO_OBJECT.get(nonGenericType); } return new JavaClass(nonGenericType); } else { // a generic JavaTypeInfo info = helper.createTypeInfo(type, typeMapping); return new JavaGenericType(info); } }
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 addReference(InjectingComponentType componentType, TypeMapping typeMapping, String name, Type parameterType, InjectionSite site, IntrospectionContext context) { Class<?> type = helper.getBaseType(parameterType, typeMapping); ServiceContract contract = contractProcessor.introspect(type, context, componentType); Reference<ComponentType> reference = new Reference<>(name, contract); helper.processMultiplicity(reference, false, parameterType, typeMapping); componentType.add(reference, site); } }
public void visitMethod(Callback annotation, Method method, Class<?> implClass, InjectingComponentType componentType, IntrospectionContext context) { validate(method, componentType, context); String name = helper.getSiteName(method, null); Type type = helper.getGenericType(method); MethodInjectionSite site = new MethodInjectionSite(method, 0); CallbackDefinition definition = createDefinition(name, type, implClass, componentType, context); componentType.add(definition, site); }
public void visitField(Monitor annotation, Field field, Class<?> implClass, InjectingComponentType componentType, IntrospectionContext context) { String name = helper.getSiteName(field, null); Type genericType = field.getGenericType(); TypeMapping typeMapping = context.getTypeMapping(implClass); Class<?> type = helper.getBaseType(genericType, typeMapping); FieldInjectionSite site = new FieldInjectionSite(field); MonitorResourceReference resource = createDefinition(name, annotation, type, componentType, context); componentType.add(resource, site); }
private TypeMapping getTypeMapping(Class<?> type, Class<?> baseClass, IntrospectionContext context) { TypeMapping typeMapping = context.getTypeMapping(baseClass); if (typeMapping == null) { typeMapping = new TypeMapping(); context.addTypeMapping(type, typeMapping); helper.resolveTypeParameters(type, typeMapping); } return typeMapping; }
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); } }
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(); Annotation[] annotations = field.getAnnotations(); processSite(componentType, typeMapping, name, field, parameterType, site, annotations, 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]; Annotation[] annotations = setter.getAnnotations(); processSite(componentType, typeMapping, name, setter, parameterType, site, annotations, context); } }
private Callback createDefinition(String name, Type type, Class<?> implClass, InjectingComponentType componentType, IntrospectionContext context) { TypeMapping typeMapping = context.getTypeMapping(implClass); Class<?> baseType = helper.getBaseType(type, typeMapping); ServiceContract contract = contractProcessor.introspect(baseType, implClass, context, componentType); return new Callback(name, contract); }
Class<?> implClass; try { implClass = helper.loadClass(className, cl); } catch (ImplementationNotFoundException e) { Throwable cause = e.getCause(); mapping = new TypeMapping(); context.addTypeMapping(implClass, mapping); helper.resolveTypeParameters(implClass, mapping);
private void addProperty(InjectingComponentType componentType, TypeMapping typeMapping, String name, Type type, InjectionSite site) { Property property = new Property(name); MultiplicityType multiplicityType = helper.introspectMultiplicity(type, typeMapping); property.setMany(MultiplicityType.COLLECTION == multiplicityType || MultiplicityType.DICTIONARY == multiplicityType); componentType.add(property, site); }
public void visitMethod(Context annotation, Method method, Class<?> implClass, InjectingComponentType componentType, IntrospectionContext context) { Type type = helper.getGenericType(method); MethodInjectionSite site = new MethodInjectionSite(method, 0); visit(type, componentType, site, method.getDeclaringClass(), method, context); }
@SuppressWarnings({"unchecked"}) private void addReference(InjectingComponentType componentType, String name, Class<?> parameterType, Class<?> declaringClass, InjectionSite site, IntrospectionContext context) { TypeMapping typeMapping = context.getTypeMapping(declaringClass); ServiceContract contract = contractProcessor.introspect(parameterType, context, componentType); Reference reference = new Reference(name, contract); helper.processMultiplicity(reference, false, parameterType, typeMapping); componentType.add(reference, site); } }
public void visitMethod(Producer annotation, Method method, Class<?> implClass, InjectingComponentType componentType, IntrospectionContext context) { String name = helper.getSiteName(method, annotation.value()); Type type = helper.getGenericType(method); MethodInjectionSite site = new MethodInjectionSite(method, 0); ProducerDefinition definition = createDefinition(name, type, implClass, componentType, method, context); componentType.add(definition, site); }
public void visitField(Monitor annotation, Field field, Class<?> implClass, InjectingComponentType componentType, IntrospectionContext context) { String name = helper.getSiteName(field, null); Type genericType = field.getGenericType(); TypeMapping typeMapping = context.getTypeMapping(implClass); Class<?> type = helper.getBaseType(genericType, typeMapping); FieldInjectionSite site = new FieldInjectionSite(field); MonitorResourceReference resource = createDefinition(name, annotation, type, componentType, context); componentType.add(resource, site); }
private TypeMapping getTypeMapping(Class<?> type, Class<?> baseClass, IntrospectionContext context) { TypeMapping typeMapping = context.getTypeMapping(baseClass); if (typeMapping == null) { typeMapping = new TypeMapping(); context.addTypeMapping(type, typeMapping); helper.resolveTypeParameters(type, typeMapping); } return typeMapping; }
private Reference<ComponentType> createDefinition(String name, boolean required, Type type, Class<?> implClass, InjectingComponentType componentType, IntrospectionContext context) { TypeMapping typeMapping = context.getTypeMapping(implClass); Class<?> baseType = helper.getBaseType(type, typeMapping); ServiceContract contract = contractProcessor.introspect(baseType, implClass, context, componentType); Reference<ComponentType> definition = new Reference<>(name, contract); helper.processMultiplicity(definition, required, type, typeMapping); return definition; }