private <A extends Annotation> void visitType(A annotation, Class<?> clazz, InjectingComponentType componentType, IntrospectionContext context) { AnnotationProcessor<A> processor = getProcessor(annotation); if (processor != null) { processor.visitType(annotation, clazz, componentType, context); } else { // check if the annotation is a policy set or intent if (policyProcessor != null) { policyProcessor.process(annotation, componentType, context); } } }
private <A extends Annotation> void visitMethod(A annotation, Method method, Class<?> implClass, InjectingComponentType componentType, IntrospectionContext context) { AnnotationProcessor<A> processor = getProcessor(annotation); if (processor != null) { processor.visitMethod(annotation, method, implClass, componentType, context); } else { // check if the annotation is a policy if (policyProcessor != null) { policyProcessor.process(annotation, componentType, context); } } }
private <A extends Annotation> void visitField(A annotation, Field field, Class<?> implClass, InjectingComponentType componentType, IntrospectionContext context) { AnnotationProcessor<A> processor = getProcessor(annotation); if (processor != null) { processor.visitField(annotation, field, implClass, componentType, context); } }
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); } }
@SuppressWarnings({"unchecked"}) private ServiceDefinition createServiceDefinition(Class<?> serviceInterface, InjectingComponentType componentType, IntrospectionContext context) { ServiceContract contract = contractProcessor.introspect(serviceInterface, context, componentType); ServiceDefinition definition = new ServiceDefinition(contract.getInterfaceName(), contract); Annotation[] annotations = serviceInterface.getAnnotations(); if (policyProcessor != null) { for (Annotation annotation : annotations) { policyProcessor.process(annotation, definition, context); } } return definition; }
if (constructor.isAnnotationPresent(org.oasisopen.sca.annotation.Constructor.class)) { if (selected != null) { context.addError(new AmbiguousConstructor(implClass, componentType)); return null;
private <A extends Annotation> void visitMethod(A annotation, Method method, Class<?> implClass, InjectingComponentType componentType, IntrospectionContext context) { AnnotationProcessor<A> processor = getProcessor(annotation); if (processor != null) { processor.visitMethod(annotation, method, implClass, componentType, context); } }
private <A extends Annotation> void visitMethodParameter(A annotation, Method method, int index, Class<?> implClass, InjectingComponentType componentType, IntrospectionContext context) { AnnotationProcessor<A> processor = getProcessor(annotation); if (processor != null) { processor.visitMethodParameter(annotation, method, index, implClass, componentType, context); } }
private <A extends Annotation> void visitConstructorParameter(A annotation, Constructor<?> constructor, int index, Class<?> implClass, InjectingComponentType componentType, IntrospectionContext context) { AnnotationProcessor<A> processor = getProcessor(annotation); if (processor != null) { processor.visitConstructorParameter(annotation, constructor, index, implClass, componentType, context); } }
private <A extends Annotation> void visitConstructor(A annotation, Constructor<?> constructor, Class<?> implClass, InjectingComponentType componentType, IntrospectionContext context) { AnnotationProcessor<A> processor = getProcessor(annotation); if (processor != null) { processor.visitConstructor(annotation, constructor, implClass, componentType, 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(); }
private <A extends Annotation> void visitType(A annotation, Class<?> clazz, InjectingComponentType componentType, IntrospectionContext context) { AnnotationProcessor<A> processor = getProcessor(annotation); if (processor != null) { processor.visitType(annotation, clazz, componentType, context); } else { // check if the annotation is a policy if (policyProcessor != null) { policyProcessor.process(annotation, componentType, context); } // check for meta-annotation for (Annotation metaAnnotation : annotation.annotationType().getDeclaredAnnotations()) { if (skipAnnotation(metaAnnotation)) { continue; } visitType(metaAnnotation, clazz, componentType, context); } } }
@SuppressWarnings({"unchecked"}) private ServiceDefinition createDefinition(Class<?> service, Class<?> implClass, InjectingComponentType componentType, IntrospectionContext context) { ServiceContract serviceContract = contractProcessor.introspect(service, implClass, context, componentType); ServiceDefinition definition = new ServiceDefinition(serviceContract.getInterfaceName(), serviceContract); Annotation[] annotations = service.getAnnotations(); if (policyProcessor != null) { for (Annotation annotation : annotations) { policyProcessor.process(annotation, definition, context); } policyIntrospector.introspectPolicyOnOperations(serviceContract, implClass, context); } return definition; } }
private Signature findConstructor(Class<?> implClass, InjectingComponentType componentType, IntrospectionContext context) { Constructor<?>[] constructors = implClass.getDeclaredConstructors(); Constructor<?> selected = null; if (constructors.length == 1) { selected = constructors[0]; } else { for (Constructor<?> constructor : constructors) { if (constructor.isAnnotationPresent(org.oasisopen.sca.annotation.Constructor.class)) { if (selected != null) { context.addError(new AmbiguousConstructor(implClass, componentType)); return null; } selected = constructor; } } if (selected == null) { context.addError(new NoConstructorFound(implClass, componentType)); return null; } } return new Signature(selected); }
private <A extends Annotation> void visitField(A annotation, Field field, Class<?> implClass, InjectingComponentType componentType, IntrospectionContext context) { AnnotationProcessor<A> processor = getProcessor(annotation); if (processor != null) { processor.visitField(annotation, field, implClass, componentType, context); } }
private <A extends Annotation> void visitMethodParameter(A annotation, Method method, int index, Class<?> implClass, InjectingComponentType componentType, IntrospectionContext context) { AnnotationProcessor<A> processor = getProcessor(annotation); if (processor != null) { processor.visitMethodParameter(annotation, method, index, implClass, componentType, context); } }
private <A extends Annotation> void visitConstructorParameter(A annotation, Constructor<?> constructor, int index, Class<?> implClass, InjectingComponentType componentType, IntrospectionContext context) { AnnotationProcessor<A> processor = getProcessor(annotation); if (processor != null) { processor.visitConstructorParameter(annotation, constructor, index, implClass, componentType, context); } }
private <A extends Annotation> void visitConstructor(A annotation, Constructor<?> constructor, Class<?> implClass, InjectingComponentType componentType, IntrospectionContext context) { AnnotationProcessor<A> processor = getProcessor(annotation); if (processor != null) { processor.visitConstructor(annotation, constructor, implClass, componentType, context); } }
@SuppressWarnings({"unchecked"}) private ReferenceDefinition createDefinition(String name, boolean required, Type type, Class<?> implClass, Annotation[] annotations, InjectingComponentType componentType, IntrospectionContext context) { TypeMapping typeMapping = context.getTypeMapping(implClass); Class<?> baseType = helper.getBaseType(type, typeMapping); ServiceContract contract = contractProcessor.introspect(baseType, implClass, context, componentType); ReferenceDefinition definition = new ReferenceDefinition(name, contract); helper.processMultiplicity(definition, required, type, typeMapping); if (policyProcessor != null) { for (Annotation annotation : annotations) { policyProcessor.process(annotation, definition, context); } } return definition; }
private void addReference(InjectingComponentType componentType, TypeMapping typeMapping, String name, Type parameterType, InjectionSite site, Annotation[] annotations, IntrospectionContext context) { Class<?> type = helper.getBaseType(parameterType, typeMapping); ServiceContract contract = contractProcessor.introspect(type, context, componentType); ReferenceDefinition reference = new ReferenceDefinition(name, contract); helper.processMultiplicity(reference, false, parameterType, typeMapping); if (policyProcessor != null) { for (Annotation annotation : annotations) { policyProcessor.process(annotation, reference, context); } } componentType.add(reference, site); } }