/** * Merges the POJO component type into the web component type. * * @param webType the web component type to merge into * @param componentType the component type to merge * @param context the introspection context */ private void mergeComponentTypes(WebComponentType webType, InjectingComponentType componentType, IntrospectionContext context) { for (Map.Entry<String, ReferenceDefinition> entry : componentType.getReferences().entrySet()) { String name = entry.getKey(); AbstractReference reference = webType.getReferences().get(name); if (reference != null) { ServiceContract source = reference.getServiceContract(); ServiceContract target = entry.getValue().getServiceContract(); MatchResult result = matcher.isAssignableFrom(source, target, false); if (!result.isAssignable()) { // TODO display areas where it was not matching IncompatibleReferenceDefinitions failure = new IncompatibleReferenceDefinitions(name); context.addError(failure); } } else { webType.add(entry.getValue()); } } // apply all injection sites for (Map.Entry<InjectionSite, Injectable> entry : componentType.getInjectionSites().entrySet()) { webType.addMapping(componentType.getImplClass(), entry.getKey(), entry.getValue()); } }
public void applyHeuristics(InjectingComponentType componentType, Class<?> implClass, IntrospectionContext context) { serviceHeuristic.applyHeuristics(componentType, implClass, context); if (componentType.getConstructor() == null) { Signature ctor = findConstructor(implClass, componentType, context); componentType.setConstructor(ctor); } if (componentType.getProperties().isEmpty() && componentType.getReferences().isEmpty() && componentType.getResourceReferences().isEmpty()) { evaluateConstructor(componentType, implClass, context); evaluateSetters(componentType, implClass, context); evaluateFields(componentType, implClass, context); } if (componentType.getInitMethod() == null) { Signature setUp = getCallback(implClass, "setUp"); if (setUp == null) { setUp = getCallback(implClass, Before.class); } componentType.setInitMethod(setUp); } if (componentType.getDestroyMethod() == null) { Signature tearDown = getCallback(implClass, "tearDown"); if (tearDown == null) { tearDown = getCallback(implClass, After.class); } componentType.setDestroyMethod(tearDown); } }