Package org.apache.tapestry.ioc.services

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


        ComponentResources resources = mockComponentResources();
        Component container = mockComponent();
        PropertyAccess access = newPropertyAccess();
        ClassPropertyAdapter classPropertyAdapter = newClassPropertyAdapter();
        PropertyAdapter propertyAdapter = newPropertyAdapter();
        BindingSource bindingSource = mockBindingSource();
        Binding binding = mockBinding();
        ComponentResources containerResources = mockComponentResources();

        train_getId(resources, id);
View Full Code Here


    }

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

        train_getAnnotation(adapter, DataType.class, null);

        replay();
View Full Code Here

    @Test
    public void value_from_annotation()
    {
        String value = "password";
        PropertyAdapter adapter = mockPropertyAdapter();

        train_getAnnotation(adapter, DataType.class, mockDataType(value));

        replay();
View Full Code Here

            readMethod = validateMethodName(step, terminal, propertyExpression);
            bindingType = readMethod.getReturnType();
        }
        else
        {
            PropertyAdapter adapter = _access.getAdapter(step).getPropertyAdapter(terminal);

            if (adapter == null)
                throw new RuntimeException(BindingsMessages.noSuchProperty(
                        step,
                        terminal,
                        propertyExpression));

            bindingType = adapter.getType();
            readMethod = adapter.getReadMethod();
            writeMethod = adapter.getWriteMethod();
        }

        Class bindingClass = createBindingClass(
                targetClass,
                builder.toString(),
View Full Code Here

    }

    private Class extendWithPropertyTerm(Class inClass, String term, String propertyExpression,
            StringBuilder builder)
    {
        PropertyAdapter pa = _access.getAdapter(inClass).getPropertyAdapter(term);

        if (pa == null)
            throw new RuntimeException(BindingsMessages.noSuchProperty(
                    inClass,
                    term,
                    propertyExpression));

        Method m = pa.getReadMethod();

        if (m == null)
            throw new RuntimeException(BindingsMessages.writeOnlyProperty(
                    term,
                    inClass,
                    propertyExpression));

        builder.append(".");
        builder.append(m.getName());
        builder.append(PARENS);

        return pa.getType();
    }
View Full Code Here

                    _beanType,
                    propertyName));

        String label = defaultLabel(propertyName);

        final PropertyAdapter adapter = _classPropertyAdapter.getPropertyAdapter(propertyName);

        PropertyConduit conduit = defaultConduit(adapter);

        PropertyEditModel propertyModel = new PropertyEditModelImpl(this, propertyName)
                .label(label).conduit(conduit);

        if (adapter != null)
            propertyModel.propertyType(adapter.getType());

        if (conduit != null)
        {
            Order annotation = conduit.getAnnotation(Order.class);
View Full Code Here

        BeanEditorModel model = new BeanEditorModelImpl(beanClass, adapter, _typeCoercer, messages);

        for (String propertyName : adapter.getPropertyNames())
        {
            PropertyAdapter pa = adapter.getPropertyAdapter(propertyName);

            if (pa.isRead() && pa.isUpdate())
            {
                String editorType = _registry.get(pa.getType());

                // If an unregistered type, then ignore the property.

                if (editorType.equals(""))
                    continue;
View Full Code Here

            // Indexed properties will have a null propertyType (and a non-null
            // indexedPropertyType). We ignore indexed properties.

            if (pd.getPropertyType() == null) continue;

            PropertyAdapter pa = new PropertyAdapterImpl(pd);

            _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

    }

    public <T> T build(Object source, String propertyName, Class<T> propertyType)
    {
        Class sourceClass = source.getClass();
        PropertyAdapter adapter = _propertyAccess.getAdapter(sourceClass).getPropertyAdapter(
                propertyName);

        // TODO: Perhaps extend ClassPropertyAdapter to do these checks?

        if (adapter == null)
            throw new RuntimeException(ServiceMessages.noSuchProperty(sourceClass, propertyName));

        if (!adapter.isRead())
            throw new RuntimeException(ServiceMessages.readNotSupported(source, propertyName));

        if (!propertyType.isAssignableFrom(adapter.getType()))
            throw new RuntimeException(ServiceMessages.propertyTypeMismatch(
                    propertyName,
                    sourceClass,
                    adapter.getType(),
                    propertyType));

        ClassFab cf = _classFactory.newClass(propertyType);

        cf.addField("_source", sourceClass);

        cf.addConstructor(new Class[]
        { sourceClass }, null, "_source = $1;");

        String body = format("return _source.%s();", adapter.getReadMethod().getName());

        MethodSignature sig = new MethodSignature(propertyType, "_delegate", null, null);
        cf.addMethod(Modifier.PRIVATE, sig, body);

        String toString = format("<Shadow: property %s of %s>", propertyName, source);
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.