/** * Returns true if the annotation is present on the type or it is present on one of the type annotations. * * @param annotationClass the annotation type * @param type the type * @return true if present */ public static <A extends Annotation> boolean isPresent(Class<A> annotationClass, Class<?> type) { return findAnnotation(annotationClass, type) != null; }
public String getMessage() { if (e == null) { return message + " : " + getCodeLocation(); } return message + ".\n" + e; }
public void applyHeuristics(InjectingComponentType componentType, Class<?> implClass, IntrospectionContext context) { serviceHeuristic.applyHeuristics(componentType, implClass, context); constructorHeuristic.applyHeuristics(componentType, implClass, context); injectionHeuristic.applyHeuristics(componentType, implClass, context); } }
private CallbackDefinition 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 CallbackDefinition(name, contract); }
public void introspect(InjectingComponentType componentType, IntrospectionContext context) { componentType.setScope(Scope.COMPOSITE); Class<?> implClass = componentType.getImplClass(); if (implClass.isInterface()) { InvalidImplementation failure = new InvalidImplementation("Implementation class is an interface", implClass, componentType); context.addError(failure); return; } TypeMapping mapping = context.getTypeMapping(implClass); if (mapping == null) { mapping = new TypeMapping(); context.addTypeMapping(implClass, mapping); helper.resolveTypeParameters(implClass, mapping); } classVisitor.visit(componentType, implClass, context); heuristic.applyHeuristics(componentType, implClass, context); } }
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(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); } }
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; }
public void visitField(Channel annotation, Field field, Class<?> implClass, InjectingComponentType componentType, IntrospectionContext context) { FieldInjectionSite site = new FieldInjectionSite(field); String name = helper.getSiteName(field, null); Class<?> type = field.getType(); createReference(name, annotation, type, componentType, site, implClass, context); }
private Property createDefinition(String name, boolean required, Type type, TypeMapping typeMapping) { Property property = new Property(name); property.setRequired(required); MultiplicityType multiplicityType = helper.introspectMultiplicity(type, typeMapping); property.setMany(MultiplicityType.COLLECTION == multiplicityType || MultiplicityType.DICTIONARY == multiplicityType); return property; }
@SuppressWarnings({"unchecked"}) private DataType<?> createDataType(Class<?> physicalType, Type type, TypeMapping mapping) { if (type instanceof Class) { // not a generic return new JavaClass(physicalType); } else { JavaTypeInfo info = helper.createTypeInfo(type, mapping); return new JavaGenericType(info); } }
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); }
public void process(InjectingComponentType componentType, Class<?> implClass, IntrospectionContext context) { processService(componentType, implClass, context); processReferences(componentType, implClass, context); }
public void visitConstructorParameter(Reference annotation, Constructor<?> constructor, int index, Class<?> implClass, InjectingComponentType componentType, IntrospectionContext context) { String name = annotation.name(); boolean required = annotation.required(); referenceProcessor.addDefinition(constructor, name, index, required, implClass, componentType, context); }
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 Property createDefinition(String name, boolean required, Type type, TypeMapping typeMapping) { Property property = new Property(name); property.setRequired(required); MultiplicityType multiplicityType = helper.introspectMultiplicity(type, typeMapping); property.setMany(MultiplicityType.COLLECTION == multiplicityType || MultiplicityType.DICTIONARY == multiplicityType); return property; }
public void visitField(Reference annotation, Field field, Class<?> implClass, InjectingComponentType componentType, IntrospectionContext context) { String name = annotation.name(); boolean required = annotation.required(); referenceProcessor.addDefinition(field, name, required, implClass, componentType, context); }
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(Reference annotation, Method method, Class<?> implClass, InjectingComponentType componentType, IntrospectionContext context) { String name = annotation.name(); boolean required = annotation.required(); referenceProcessor.addDefinition(method, name, required, implClass, componentType, context); }
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); }