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); } }
public PhysicalComponentDefinition generate(LogicalComponent<JUnitImplementation> component) throws GenerationException { ComponentDefinition<JUnitImplementation> definition = component.getDefinition(); JUnitImplementation implementation = definition.getImplementation(); InjectingComponentType type = implementation.getComponentType(); String scope = type.getScope(); ImplementationManagerDefinition managerDefinition = new ImplementationManagerDefinition(); managerDefinition.setComponentUri(component.getUri()); managerDefinition.setReinjectable(Scope.COMPOSITE.getScope().equals(scope)); managerDefinition.setConstructor(type.getConstructor()); managerDefinition.setInitMethod(type.getInitMethod()); managerDefinition.setDestroyMethod(type.getDestroyMethod()); managerDefinition.setImplementationClass(implementation.getImplementationClass()); helper.processInjectionSites(type, managerDefinition); JavaComponentDefinition physical = new JavaComponentDefinition(); physical.setScope(scope); physical.setManagerDefinition(managerDefinition); helper.processPropertyValues(component, physical); return physical; }