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); } } }
@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; }
public void introspectPolicyOnOperations(ServiceContract contract, Class<?> implClass, IntrospectionContext context) { for (Operation operation : contract.getOperations()) { // determine the operation signature and look up the corresponding method on the implementation class List<DataType<?>> types = operation.getInputTypes(); Class<?>[] params = new Class<?>[types.size()]; for (int i = 0; i < types.size(); i++) { DataType<?> type = types.get(i); Class<?> physical = type.getPhysical(); params[i] = physical; } try { Method method = implClass.getMethod(operation.getName(), params); for (Annotation annotation : method.getAnnotations()) { policyProcessor.process(annotation, operation, context); } } catch (NoSuchMethodException e) { // should not happen throw new AssertionError(e); } } }
public void introspectPolicyOnOperations(ServiceContract contract, Class<?> implClass, IntrospectionContext context) { for (Operation operation : contract.getOperations()) { // determine the operation signature and look up the corresponding method on the implementation class List<DataType> types = operation.getInputTypes(); Class<?>[] params = new Class<?>[types.size()]; for (int i = 0; i < types.size(); i++) { DataType dataType = types.get(i); Class<?> type = dataType.getType(); params[i] = type; } try { Method method = implClass.getMethod(operation.getName(), params); for (Annotation annotation : method.getAnnotations()) { policyProcessor.process(annotation, operation, context); } } catch (NoSuchMethodException e) { // should not happen throw new AssertionError(e); } } }
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; } }
@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); } }