org.oasisopen.sca.annotation.Reference.required()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(4.6k)|赞(0)|评价(0)|浏览(84)

本文整理了Java中org.oasisopen.sca.annotation.Reference.required方法的一些代码示例,展示了Reference.required的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Reference.required方法的具体详情如下:
包路径:org.oasisopen.sca.annotation.Reference
类名称:Reference
方法名:required

Reference.required介绍

暂无

代码示例

代码示例来源:origin: com.carecon.fabric3/fabric3-introspection-java

public void visitField(Reference annotation, Field field, Class<?> implClass, InjectingComponentType componentType, IntrospectionContext context) {
  String name = annotation.name();
  boolean required = annotation.required();
  referenceProcessor.addDefinition(field, name, required, implClass, componentType, context);
}

代码示例来源:origin: com.carecon.fabric3/fabric3-introspection-java

public void visitConstructorParameter(Reference annotation,
                   Constructor<?> constructor,
                   int index,
                   Class<?> implClass,
                   InjectingComponentType componentType,
                   IntrospectionContext context) {
  String name = annotation.name();
  boolean required = annotation.required();
  referenceProcessor.addDefinition(constructor, name, index, required, implClass, componentType, context);
}

代码示例来源:origin: com.carecon.fabric3/fabric3-introspection-java

public void visitMethod(Reference annotation, Method method, Class<?> implClass, InjectingComponentType componentType, IntrospectionContext context) {
  String name = annotation.name();
  boolean required = annotation.required();
  referenceProcessor.addDefinition(method, name, required, implClass, componentType, context);
}

代码示例来源:origin: org.codehaus.fabric3/fabric3-introspection-java

public void visitField(Reference annotation,
            Field field,
            Class<?> implClass,
            InjectingComponentType componentType,
            IntrospectionContext context) {
  String name = helper.getSiteName(field, annotation.name());
  Type type = field.getGenericType();
  FieldInjectionSite site = new FieldInjectionSite(field);
  Annotation[] annotations = field.getAnnotations();
  boolean required = annotation.required();
  ReferenceDefinition definition = createDefinition(name, required, type, implClass, annotations, componentType, context);
  componentType.add(definition, site);
}

代码示例来源:origin: org.codehaus.fabric3/fabric3-introspection-java

public void visitMethod(Reference annotation,
            Method method,
            Class<?> implClass,
            InjectingComponentType componentType,
            IntrospectionContext context) {
  String name = helper.getSiteName(method, annotation.name());
  Type type = helper.getGenericType(method);
  MethodInjectionSite site = new MethodInjectionSite(method, 0);
  Annotation[] annotations = method.getAnnotations();
  ReferenceDefinition definition = createDefinition(name, annotation.required(), type, implClass, annotations, componentType, context);
  componentType.add(definition, site);
}

代码示例来源:origin: org.codehaus.fabric3/fabric3-introspection-java

public void visitConstructorParameter(Reference annotation,
                   Constructor<?> constructor,
                   int index,
                   Class<?> implClass,
                   InjectingComponentType componentType,
                   IntrospectionContext context) {
  String name = helper.getSiteName(constructor, index, annotation.name());
  Type type = helper.getGenericType(constructor, index);
  ConstructorInjectionSite site = new ConstructorInjectionSite(constructor, index);
  Annotation[] annotations = constructor.getParameterAnnotations()[index];
  boolean required = annotation.required();
  ReferenceDefinition definition = createDefinition(name, required, type, implClass, annotations, componentType, context);
  componentType.add(definition, site);
}

代码示例来源:origin: org.apache.tuscany.sca/tuscany-base-runtime

@Override
public void visitConstructorParameter(JavaParameterImpl parameter, JavaImplementation type)
  throws IntrospectionException {
  Reference refAnnotation = parameter.getAnnotation(Reference.class);
  if (refAnnotation == null) {
    return;
  }
  
  if (!refAnnotation.required()) {
    throw new InvalidReferenceException("[JCA90016] Constructor has @Reference with required=false: " + type.getName());
  }
  
  if (refAnnotation.name() == null || refAnnotation.name().length() < 1) {
    throw new InvalidReferenceException("[JCA90018] @Reference in a Constructor must have a name attribute" + type.getName());
  }
  
  String paramName = parameter.getName();
  String name = getReferenceName(paramName, parameter.getIndex(), refAnnotation.name());
  JavaElementImpl ref = type.getReferenceMembers().get(name);
  // Setter override field
  if (ref != null && ref.getElementType() != ElementType.FIELD) {
    throw new DuplicateReferenceException(name);
  }
  removeReference(ref, type);
  org.apache.tuscany.sca.assembly.Reference reference = createReference(type, parameter, name);
  type.getReferences().add(reference);
  type.getReferenceMembers().put(name, parameter);
  parameter.setClassifer(Reference.class);
  parameter.setName(name);
}

代码示例来源:origin: org.apache.tuscany.sca/tuscany-base-runtime

Reference ref = element.getAnnotation(Reference.class);
if (ref != null) {
  required = ref.required();

相关文章

微信公众号

最新文章

更多