Package org.oasisopen.sca.annotation

Examples of org.oasisopen.sca.annotation.Reference


        super(registry);
    }   

    @Override
    public void visitMethod(Method method, JavaImplementation type) throws IntrospectionException {
        Reference annotation = method.getAnnotation(Reference.class);
        if (annotation != null) {
 
          if (!JavaIntrospectionHelper.isSetter(method)) {
              throw new IllegalReferenceException("Annotated method is not a setter: " + method, method);
          }
        
          if(Modifier.isStatic(method.getModifiers())) {
            throw new IllegalPropertyException("Static method " + method.getName() +" in class " + method.getDeclaringClass().getName() + " can not be annotated as a Reference");
          }
         
          String name = annotation.name();
          if ("".equals(name)) {
              name = JavaIntrospectionHelper.toPropertyName(method.getName());
          }
          JavaElementImpl ref = type.getReferenceMembers().get(name);
          // Setter override field
View Full Code Here


    }


    @Override
    public void visitField(Field field, JavaImplementation type) throws IntrospectionException {
        Reference annotation = field.getAnnotation(Reference.class);
        if (annotation == null) {
            return;
        }
       
        if(Modifier.isStatic(field.getModifiers())) {
          throw new IllegalReferenceException("Static field " + field.getName() +" in class " + field.getDeclaringClass().getName() + " can not be annotated as Reference");
        }
        String name = annotation.name();
        if ("".equals(name)) {
            name = field.getName();
        }
        JavaElementImpl ref = type.getReferenceMembers().get(name);
        if (ref != null && ref.getElementType() == ElementType.FIELD) {
View Full Code Here

    }

    @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);
View Full Code Here

        JavaInterfaceContract interfaceContract = javaInterfaceFactory.createJavaInterfaceContract();
        reference.setInterfaceContract(interfaceContract);

        // reference.setMember((Member)element.getAnchor());
        boolean required = true;
        Reference ref = element.getAnnotation(Reference.class);
        if (ref != null) {
            required = ref.required();
        }
        // reference.setRequired(required);
        reference.setName(name);
        Class<?> rawType = element.getType();
        if (rawType.isArray() || Collection.class.isAssignableFrom(rawType)) {
View Full Code Here

        super(registry);
    }   

    @Override
    public void visitMethod(Method method, JavaImplementation type) throws IntrospectionException {
        Reference annotation = method.getAnnotation(Reference.class);
        if (annotation != null) {
 
          if (!JavaIntrospectionHelper.isSetter(method)) {
              throw new IllegalReferenceException("Annotated method is not a setter: " + method, method);
          }
        
          if(Modifier.isStatic(method.getModifiers())) {
            throw new IllegalPropertyException("Static method " + method.getName() +" in class " + method.getDeclaringClass().getName() + " can not be annotated as a Reference");
          }
         
          String name = annotation.name();
          if ("".equals(name)) {
              name = JavaIntrospectionHelper.toPropertyName(method.getName());
          }
          JavaElementImpl ref = type.getReferenceMembers().get(name);
          // Setter override field
View Full Code Here

    }


    @Override
    public void visitField(Field field, JavaImplementation type) throws IntrospectionException {
        Reference annotation = field.getAnnotation(Reference.class);
        if (annotation == null) {
            return;
        }
       
        if(Modifier.isStatic(field.getModifiers())) {
          throw new IllegalReferenceException("Static field " + field.getName() +" in class " + field.getDeclaringClass().getName() + " can not be annotated as Reference");
        }
        String name = annotation.name();
        if ("".equals(name)) {
            name = field.getName();
        }
        JavaElementImpl ref = type.getReferenceMembers().get(name);
        if (ref != null && ref.getElementType() == ElementType.FIELD) {
View Full Code Here

    }

    @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);
View Full Code Here

            reference.setAllowsPassByReference(implementation.isAllowsPassByReference());
        }

        // reference.setMember((Member)element.getAnchor());
        boolean required = true;
        Reference ref = element.getAnnotation(Reference.class);
        if (ref != null) {
            required = ref.required();
        }
        // reference.setRequired(required);
        reference.setName(name);
        Class<?> rawType = element.getType();
        if (rawType.isArray() || Collection.class.isAssignableFrom(rawType)) {
View Full Code Here

TOP

Related Classes of org.oasisopen.sca.annotation.Reference

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.