Package org.apache.tapestry.ioc.services

Examples of org.apache.tapestry.ioc.services.PropertyAdapter


    @Test
    public void property_adapter_write_only_property()
    {
        ClassPropertyAdapter cpa = _access.getAdapter(Bean.class);
        PropertyAdapter pa = cpa.getPropertyAdapter("writeOnly");

        assertFalse(pa.isRead());
        assertTrue(pa.isUpdate());

        assertEquals(pa.getWriteMethod(), findMethod(Bean.class, "setWriteOnly"));
        assertNull(pa.getReadMethod());
    }
View Full Code Here


    }

    @Test
    public void get_annotation_when_annotation_not_present()
    {
        PropertyAdapter pa = _access.getAdapter(AnnotatedBean.class)
                .getPropertyAdapter("readWrite");

        assertNull(pa.getAnnotation(Scope.class));
    }
View Full Code Here

    }

    @Test
    public void get_annotation_with_annotation_on_write_method()
    {
        PropertyAdapter pa = _access.getAdapter(AnnotatedBean.class).getPropertyAdapter("annotationOnWrite");

        Scope annotation = pa.getAnnotation(Scope.class);
        assertNotNull(annotation);

        assertEquals(annotation.value(), "onwrite");
    }
View Full Code Here

    }

    @Test
    public void read_method_annotation_overrides_write_method_annotation()
    {
        PropertyAdapter pa = _access.getAdapter(AnnotatedBean.class).getPropertyAdapter("annotationOnRead");

        Scope annotation = pa.getAnnotation(Scope.class);
        assertNotNull(annotation);

        assertEquals(annotation.value(), "onread");
    }
View Full Code Here

    }

    @Test
    public void no_write_method_reading_missing_annotation()
    {
        PropertyAdapter pa = _access.getAdapter(AnnotatedBean.class).getPropertyAdapter("readOnly");

        assertNull(pa.getAnnotation(Scope.class));
    }
View Full Code Here

        ComponentResources resources = mockComponentResources();
        Component container = mockComponent();
        PropertyAccess access = mockPropertyAccess();
        ClassPropertyAdapter classPropertyAdapter = mockClassPropertyAdapter();
        PropertyAdapter propertyAdapter = mockPropertyAdapter();
        BindingSource bindingSource = mockBindingSource();
        Binding binding = mockBinding();
        ComponentResources containerResources = mockComponentResources();

        train_getId(resources, id);
View Full Code Here

            Method readMethod = pd.getReadMethod();

            Class propertyType = readMethod == null ? pd.getPropertyType() : GenericsUtils.extractGenericReturnType(
                    beanType, readMethod);

            PropertyAdapter pa = new PropertyAdapterImpl(pd.getName(), propertyType, readMethod, pd.getWriteMethod());

            _adapters.put(pa.getName(), pa);
        }
    }
View Full Code Here

        adaptorFor(propertyName).set(instance, value);
    }

    private PropertyAdapter adaptorFor(String name)
    {
        PropertyAdapter pa = _adapters.get(name);

        if (pa == null) throw new IllegalArgumentException(ServiceMessages.noSuchProperty(_beanType, name));

        return pa;
    }
View Full Code Here

        List<PropertyOrder> properties = newList();

        for (String name : propertyNames)
        {

            PropertyAdapter pa = classAdapter.getPropertyAdapter(name);
            List<String> propertyConstraints = CollectionFactory.newList();

            OrderBefore beforeAnnotation = pa.getAnnotation(OrderBefore.class);

            if (beforeAnnotation != null) propertyConstraints.add("before:" + beforeAnnotation.value());

            OrderAfter afterAnnotation = pa.getAnnotation(OrderAfter.class);

            if (afterAnnotation != null) propertyConstraints.add("after:" + afterAnnotation.value());

            if (!propertyConstraints.isEmpty()) constraints.put(name, propertyConstraints);

            Method readMethod = pa.getReadMethod();

            Location location = classFactory.getMethodLocation(readMethod);

            properties.add(new PropertyOrder(name, computeDepth(readMethod), location.getLine()));
        }
View Full Code Here

    }

    @Test
    public void annotation_absent()
    {
        PropertyAdapter adapter = mockPropertyAdapter();

        train_getAnnotation(adapter, DataType.class, null);

        replay();
View Full Code Here

TOP

Related Classes of org.apache.tapestry.ioc.services.PropertyAdapter

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.