public void applyHeuristics(InjectingComponentType componentType, Class<?> implClass, IntrospectionContext context) { serviceHeuristic.applyHeuristics(componentType, implClass, context); constructorHeuristic.applyHeuristics(componentType, implClass, context); injectionHeuristic.applyHeuristics(componentType, implClass, context); } }
public void applyHeuristics(InjectingComponentType componentType, Class<?> implClass, IntrospectionContext context) { // apply service heuristic serviceHeuristic.applyHeuristics(componentType, implClass, context); if (componentType.getConstructor() == null) { Constructor<?> 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); } Scope scope = componentType.getScope(); if (componentType.isManaged() && !scope.isSingleton()) { IllegalManagementAttribute warning = new IllegalManagementAttribute(implClass, componentType); context.addWarning(warning); } }
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 introspect(InjectingComponentType componentType, IntrospectionContext context) { componentType.setScope(Scope.STATELESS); 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); } try { classVisitor.visit(componentType, implClass, context); heuristic.applyHeuristics(componentType, implClass, context); } catch (NoClassDefFoundError e) { // May be thrown as a result of a referenced class not being on the classpath context.addError(new ImplementationArtifactNotFound(implClass.getName(), e.getMessage(), componentType)); } validateScope(componentType, implClass, context); for (PostProcessor postProcessor : postProcessors) { postProcessor.process(componentType, implClass, context); } }
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); } }
heuristic.applyHeuristics(componentType, implClass, context); return componentType;