Package org.osoa.sca.annotations

Examples of org.osoa.sca.annotations.Reference


        this.javaFactory = javaFactory;
    }

    @Override
    public void visitMethod(Method method, JavaImplementation type) throws IntrospectionException {
        Reference annotation = method.getAnnotation(Reference.class);
        if (annotation == null) {
            return; // Not a reference annotation.
        }
        if (!JavaIntrospectionHelper.isSetter(method)) {
            throw new IllegalReferenceException("Annotated method is not a setter: " + method, method);
        }
        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


        return false;
    }

    @Override
    public void visitField(Field field, JavaImplementation type) throws IntrospectionException {
        Reference annotation = field.getAnnotation(Reference.class);
        if (annotation == null) {
            return;
        }
        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;
        }
        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 = javaFactory.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(lookupName);
        this.field = field;
    }

    public FieldInjection(Field field) {
        Reference annotation = field.getAnnotation(Reference.class);

        this.field = field;

        if (annotation == null) {
            //throw new IllegalArgumentException("Field " + field + " not annotated");
            return;
        }

        if ("".equals(annotation.name())) {
            setLookupName(field.getName());
        } else {
            setLookupName(annotation.name());
        }
    }
View Full Code Here

        Class<?> param,
        List<String> explicitNames) throws ProcessingException {

        // TODO multiplicity
        // the param is marked as a reference
        Reference refAnnotation = (Reference) annot;
        JavaMappedReference reference = new JavaMappedReference();
        String name = refAnnotation.name();
        if (name == null || name.length() == 0) {
            if (constructorNames.length < pos + 1 || constructorNames[pos] == null
                || constructorNames[pos].length() == 0) {
                throw new InvalidReferenceException("No name specified for reference parameter " + (pos + 1));
            }
            name = constructorNames[pos];
        } else if (pos < constructorNames.length && constructorNames[pos] != null
            && constructorNames[pos].length() != 0 && !name.equals(constructorNames[pos])) {
            throw new InvalidConstructorException("Name specified by @Constructor does not match reference name at "
                + (pos + 1));
        }
        if (type.getReferences().get(name) != null) {
            throw new DuplicateReferenceException(name);
        }
        reference.setName(name);
        reference.setRequired(refAnnotation.required());
        try {
            ServiceContract<?> contract = registry.introspect(param);
            reference.setServiceContract(contract);
        } catch (InvalidServiceContractException e) {
            throw new ProcessingException(e);
View Full Code Here

    public void visitMethod(CompositeComponent parent, Method method,
                            PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type,
                            DeploymentContext context)
        throws ProcessingException {
        Reference annotation = method.getAnnotation(Reference.class);
        Autowire autowire = method.getAnnotation(Autowire.class);
        boolean isAutowire = autowire != null;
        if (annotation == null && !isAutowire) {
            return; //Not a reference or autowire annotation.
        }
        if (method.getParameterTypes().length != 1) {
            IllegalReferenceException e = new IllegalReferenceException("Setter must have one parameter");
            e.setIdentifier(method.toString());
            throw e;
        }
        //process autowire required first let reference override. or if conflicting should this fault?
        boolean required = false;
        if (isAutowire) {
            required = autowire.required();
        }

        String name = null;

        if (annotation != null) {
            if (annotation.name() != null && annotation.name().length() > 0) {
                name = annotation.name();
            }
            required = annotation.required();
        }
        if (name == null) {
            name = method.getName();
            if (method.getName().startsWith("set")) {
                name = toPropertyName(method.getName());
View Full Code Here

    }

    public void visitField(CompositeComponent parent, Field field,
                           PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type,
                           DeploymentContext context) throws ProcessingException {
        Reference annotation = field.getAnnotation(Reference.class);
        boolean autowire = field.getAnnotation(Autowire.class) != null;
        if (annotation == null && !autowire) {
            return;
        }
        String name = field.getName();
        boolean required = false;
        if (annotation != null) {
            if (annotation.name() != null) {
                name = annotation.name();
            }
            required = annotation.required();
        }
        if (name.length() == 0) {
            name = field.getName();
        }
        if (type.getReferences().get(name) != null) {
View Full Code Here

        this.javaFactory = javaFactory;
    }

    @Override
    public void visitMethod(Method method, JavaImplementation type) throws IntrospectionException {
        Reference annotation = method.getAnnotation(Reference.class);
        if (annotation == null) {
            return; // Not a reference annotation.
        }
        if (!JavaIntrospectionHelper.isSetter(method)) {
            throw new IllegalReferenceException("Annotated method is not a setter: " + method, method);
        }
        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

        return false;
    }

    @Override
    public void visitField(Field field, JavaImplementation type) throws IntrospectionException {
        Reference annotation = field.getAnnotation(Reference.class);
        if (annotation == null) {
            return;
        }
        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

TOP

Related Classes of org.osoa.sca.annotations.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.