Package org.osoa.sca.annotations

Examples of org.osoa.sca.annotations.Property


        Method method = null;
        Field field = JavaIntrospectionHelper.findClosestMatchingField(propertyName, type, fields);
        if (field == null) {
            // hack for TUSCANY-322
            for (Field current : fields) {
                Property annot = current.getAnnotation(Property.class);
                if (annot != null) {
                    if (propertyName.equals(annot.name())) {
                        field = current;
                        break;
                    }
                }
            }
            method = JavaIntrospectionHelper.findClosestMatchingMethod(propertyName, new Class[]{type}, methods);
            if (method == null) {
                // hack for TUSCANY-322
                for (Method current : methods) {
                    Property annot = current.getAnnotation(Property.class);
                    if (annot != null) {
                        if (propertyName.equals(annot.name())) {
                            method = current;
                            break;
                        }
                    }
                }
View Full Code Here


        final Class<?> clazz = bean.getClass();      

        ReflectionUtils.doWithMethods(clazz, new ReflectionUtils.MethodCallback() {
            public void doWith(Method method) {

                Property annotation = (Property) method.getAnnotation(getPropertyAnnotationType());
               
                if (annotation != null) {
                    if (Modifier.isStatic(method.getModifiers())) {
                        throw new IllegalStateException("Property annotation is not supported on static methods");
                    }
                   
                    if (Modifier.isPrivate(method.getModifiers())) {
                        throw new IllegalStateException("Property annotation is not supported on private methods");
                    }

                    if (method.getParameterTypes().length == 0) {
                        throw new IllegalStateException("Property annotation requires at least one argument: " + method);
                    }
                   
                    PropertyDescriptor pd = BeanUtils.findPropertyForMethod(method);
                    if (pd != null) {
                        String propName = annotation.name();
                        if ("".equals(propName)) {
                            injectProperty(bean, pd, propertyValue.getPropertyObj(pd.getPropertyType(), pd.getName()));
                        } else {
                            injectProperty(bean, pd, propertyValue.getPropertyObj(pd.getPropertyType(), propName));
                        }
                    }
                }
            }
        });
       
        ReflectionUtils.doWithFields(clazz, new ReflectionUtils.FieldCallback() {
            public void doWith(Field field) {

                Property annotation = (Property) field.getAnnotation(getPropertyAnnotationType());
               
                if (annotation != null) {
                    if (Modifier.isStatic(field.getModifiers())) {
                        throw new IllegalStateException("Property annotation is not supported on static fields");
                    }
                   
                    if (Modifier.isPrivate(field.getModifiers())) {
                        throw new IllegalStateException("Property annotation is not supported on private fields");
                    }

                    ReflectionUtils.makeAccessible(field);
                   
                    Object propertyObj = null;
                    String propName = annotation.name();
                    if ("".equals(propName)) {
                        propertyObj = propertyValue.getPropertyObj(field.getType(), field.getName());                       
                    } else {
                        propertyObj = propertyValue.getPropertyObj(field.getType(), propName);
                    }
View Full Code Here

        final Class<?> clazz = bean.getClass();      

        ReflectionUtils.doWithMethods(clazz, new ReflectionUtils.MethodCallback() {
            public void doWith(Method method) {
                //Annotation annotation = method.getAnnotation(getPropertyAnnotationType());               
                Property annotation = (Property) method.getAnnotation(getPropertyAnnotationType());
               
                if (annotation != null) {
                    if (Modifier.isStatic(method.getModifiers())) {
                        throw new IllegalStateException("Property annotation is not supported on static methods");
                    }
                   
                    if (Modifier.isPrivate(method.getModifiers())) {
                        throw new IllegalStateException("Property annotation is not supported on private methods");
                    }

                    if (method.getParameterTypes().length == 0) {
                        throw new IllegalStateException("Property annotation requires at least one argument: " + method);
                    }
                   
                    PropertyDescriptor pd = BeanUtils.findPropertyForMethod(method);
                    if (pd != null) {
                        String propName = annotation.name();
                        if ("".equals(propName)) {
                            injectProperty(bean, pd, getPropertyObj(pd.getPropertyType(), pd.getName()));
                        } else {
                            injectProperty(bean, pd, getPropertyObj(pd.getPropertyType(), propName));
                        }
                    }
                }
            }
        });
       
        ReflectionUtils.doWithFields(clazz, new ReflectionUtils.FieldCallback() {
            public void doWith(Field field) {
                //Annotation annotation = field.getAnnotation(getPropertyAnnotationType());
                Property annotation = (Property) field.getAnnotation(getPropertyAnnotationType());
               
                if (annotation != null) {
                    if (Modifier.isStatic(field.getModifiers())) {
                        throw new IllegalStateException("Property annotation is not supported on static fields");
                    }
                   
                    if (Modifier.isPrivate(field.getModifiers())) {
                        throw new IllegalStateException("Property annotation is not supported on private fields");
                    }

                    ReflectionUtils.makeAccessible(field);
                   
                    Object propertyObj = null;
                    String propName = annotation.name();
                    if ("".equals(propName)) {
                        propertyObj = getPropertyObj(field.getType(), field.getName());                       
                    } else {
                        propertyObj = getPropertyObj(field.getType(), propName);
                    }
View Full Code Here

        this.method = method;
    }

    public MethodInjection(Method method) {
        // TODO reference also
        Property annotation = method.getAnnotation(Property.class);
        if (annotation == null) {
            throw new IllegalArgumentException("Method " + method + " not annotated");
        }
        this.method = method;
        if ("".equals(annotation.name())) {
            setLookupName(method.getName());
        } else {
            setLookupName(annotation.name());
        }
    }
View Full Code Here

        PojoComponentType<JavaMappedService, JavaMappedReference, JavaMappedProperty<?>> type,
        Class<T> param,
        List<String> explicitNames) throws ProcessingException {
        // TODO multiplicity
        // the param is marked as a property
        Property propAnnot = (Property) annot;
        JavaMappedProperty<T> property = new JavaMappedProperty<T>();
        String name = propAnnot.name();
        if (name == null || name.length() == 0) {
            if (constructorNames.length < pos + 1 || constructorNames[pos] == null
                || constructorNames[pos].length() == 0) {
                throw new InvalidPropertyException("No name specified for property 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 property name at "
                + (pos + 1));
        }
        if (type.getProperties().get(name) != null) {
            throw new DuplicatePropertyException(name);
        }
        property.setName(name);
        property.setOverride(OverrideOptions.valueOf(propAnnot.override().toUpperCase()));

        property.setXmlType(QName.valueOf(propAnnot.xmlType()));
        property.setJavaType(param);
        type.getProperties().put(name, property);
        addName(explicitNames, pos, name);
    }
View Full Code Here

TOP

Related Classes of org.osoa.sca.annotations.Property

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.