public Map<AccessibleObject, Supplier<Object>> getInjectors(Class<?> clazz) { Map<AccessibleObject, Supplier<Object>> injectors = new HashMap<>(); // introspect class InjectingComponentType componentType = new InjectingComponentType(clazz); DefaultIntrospectionContext context = new DefaultIntrospectionContext(); TypeMapping typeMapping = new TypeMapping(); context.addTypeMapping(clazz, typeMapping); introspectionHelper.resolveTypeParameters(clazz, typeMapping); classVisitor.visit(componentType, clazz, context); for (PostProcessor postProcessor : postProcessors) { postProcessor.process(componentType, clazz, context); } // process injection sites for (Map.Entry<ModelObject, InjectionSite> entry : componentType.getInjectionSiteMappings().entrySet()) { ModelObject key = entry.getKey(); InjectionSite value = entry.getValue(); if (key instanceof Reference) { Reference<?> reference = (Reference) key; handleReference(reference, value, clazz, injectors); } else if (key instanceof Producer) { Producer producer = (Producer) key; throw new UnsupportedOperationException("Not yet implemented"); } else if (key instanceof Consumer) { throw new UnsupportedOperationException("Not yet implemented"); } } return injectors; }
public Map<AccessibleObject, Supplier<Object>> getInjectors(Class<?> clazz) { Map<AccessibleObject, Supplier<Object>> injectors = new HashMap<>(); // introspect class InjectingComponentType componentType = new InjectingComponentType(clazz); DefaultIntrospectionContext context = new DefaultIntrospectionContext(); TypeMapping typeMapping = new TypeMapping(); context.addTypeMapping(clazz, typeMapping); introspectionHelper.resolveTypeParameters(clazz, typeMapping); classVisitor.visit(componentType, clazz, context); for (PostProcessor postProcessor : postProcessors) { postProcessor.process(componentType, clazz, context); } // process injection sites for (Map.Entry<ModelObject, InjectionSite> entry : componentType.getInjectionSiteMappings().entrySet()) { ModelObject key = entry.getKey(); InjectionSite value = entry.getValue(); if (key instanceof Reference) { Reference<?> reference = (Reference) key; handleReference(reference, value, clazz, injectors); } else if (key instanceof Producer) { Producer producer = (Producer) key; throw new UnsupportedOperationException("Not yet implemented"); } else if (key instanceof Consumer) { throw new UnsupportedOperationException("Not yet implemented"); } } return injectors; }
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 Resource introspect(Class<?> clazz, Contribution contribution, IntrospectionContext context) { ResourceElement<WebComponentTypeSymbol, WebComponentType> element = getTypeElement(contribution); WebComponentType componentType = element.getValue(); // introspect the class and generate a component type that will be merged into the web component type WebArtifactImplementation artifactImpl = new WebArtifactImplementation(); InjectingComponentType tempType = new InjectingComponentType(clazz); artifactImpl.setComponentType(tempType); TypeMapping mapping = context.getTypeMapping(clazz); if (mapping == null) { mapping = new TypeMapping(); context.addTypeMapping(clazz, mapping); helper.resolveTypeParameters(clazz, mapping); } classVisitor.visit(tempType, clazz, context); mergeComponentTypes(componentType, tempType, context); return element.getResource(); }
classVisitor.visit(componentType, implClass, context);
public void introspect(WebImplementation implementation, IntrospectionContext context) { WebComponentType componentType = new WebComponentType(); implementation.setComponentType(componentType); // load the servlet, filter and context listener classes referenced in the web.xml descriptor List<Class<?>> artifacts = xmlIntrospector.introspectArtifactClasses(context); for (Class<?> artifact : artifacts) { // introspect each class and generate a component type that will be merged into the web component type WebArtifactImplementation artifactImpl = new WebArtifactImplementation(); InjectingComponentType type = new InjectingComponentType(artifact.getName()); artifactImpl.setComponentType(type); TypeMapping mapping = context.getTypeMapping(artifact); if (mapping == null) { mapping = new TypeMapping(); context.addTypeMapping(artifact, mapping); helper.resolveTypeParameters(artifact, mapping); } IntrospectionContext childContext = new DefaultIntrospectionContext(context); classVisitor.visit(type, artifact, childContext); if (childContext.hasErrors()) { context.addErrors(childContext.getErrors()); } if (childContext.hasWarnings()) { context.addWarnings(childContext.getWarnings()); } // TODO apply heuristics mergeComponentTypes(implementation.getComponentType(), type, context); } }