Package org.apache.tapestry5.services

Examples of org.apache.tapestry5.services.TransformMethodSignature


        replay();

        ClassTransformation ct = createClassTransformation(SimpleBean.class, logger);

        TransformMethodSignature sig = new TransformMethodSignature("methodDoesNotExist");

        try
        {
            ct.isMethodOverride(sig);
            unreachable();
View Full Code Here


        ClassTransformation childTransform = parentTransform.createChildTransformation(childClass,
                                                                                       stubMutableComponentModel(
                                                                                               logger));

        assertFalse(childTransform.isMethodOverride(new TransformMethodSignature("notOverridden")));

        assertTrue(childTransform.isMethodOverride(
                new TransformMethodSignature(Modifier.PUBLIC, "void", "setAge", new String[] { "int" }, null)));
    }
View Full Code Here

            // Caching might be good for efficiency at some point.

            String methodName = transformation.newMemberName("environment_read", name);

            TransformMethodSignature sig = new TransformMethodSignature(Modifier.PRIVATE, type, methodName, null,
                                                                        null);

            String body = String.format(
                    "return ($r) %s.%s($type);",
                    envField,
View Full Code Here

            String fieldType = transformation.getFieldType(fieldName);

            if (annotation.read())
            {
                TransformMethodSignature getter
                        = new TransformMethodSignature(Modifier.PUBLIC | Modifier.FINAL, fieldType,
                                                       "get" + propertyName,
                                                       null, null);

                transformation.addTransformedMethod(getter, "return " + fieldName + ";");
            }

            if (annotation.write())
            {
                TransformMethodSignature setter
                        = new TransformMethodSignature(Modifier.PUBLIC | Modifier.FINAL, "void", "set" + propertyName,
                                                       new String[] { fieldType }, null);

                transformation.addTransformedMethod(setter, fieldName + " = $1;");
            }
View Full Code Here

        assertEquals(subclassFieldName, parentFieldName);

        // This proves the the field is protected and can be used in subclasses.

        ct.addMethod(new TransformMethodSignature(Modifier.PUBLIC, "java.lang.String", "getValue", null, null),
                     "return " + subclassFieldName + ";");

        ct.finish();

        Instantiator instantiator = ct.createInstantiator();
View Full Code Here

    private void replaceAccessToField(InternalClassTransformation ct, String baseName)
    {
        String fieldName = "_" + baseName;
        String readMethodName = "_read_" + baseName;

        TransformMethodSignature readMethodSignature = new TransformMethodSignature(Modifier.PRIVATE, STRING_CLASS_NAME,
                                                                                    readMethodName, null, null);

        ct.addMethod(readMethodSignature, String.format("throw new RuntimeException(\"read %s\");", baseName));

        ct.replaceReadAccess(fieldName, readMethodName);

        String writeMethodName = "_write_" + baseName;

        TransformMethodSignature writeMethodSignature = new TransformMethodSignature(Modifier.PRIVATE, "void",
                                                                                     writeMethodName,
                                                                                     new String[] { STRING_CLASS_NAME },
                                                                                     null);
        ct.addMethod(writeMethodSignature, String.format("throw new RuntimeException(\"write %s\");", baseName));
View Full Code Here

        replay();

        ClassTransformation ct = createClassTransformation(EventHandlerTarget.class, logger);

        OnEvent annotation = ct.getMethodAnnotation(new TransformMethodSignature("handler"), OnEvent.class);

        // Check that the attributes of the annotation match the expectation.

        assertEquals(annotation.value(), "fred");
        assertEquals(annotation.component(), "alpha");
View Full Code Here

        ClassTransformation ct = createClassTransformation(ParentClass.class, logger);

        try
        {
            ct.getMethodAnnotation(new TransformMethodSignature("foo"), OnEvent.class);
            unreachable();
        }
        catch (IllegalArgumentException ex)
        {
            assertEquals(ex.getMessage(),
View Full Code Here

    @Test
    public void prefix_method() throws Exception
    {
        Logger logger = mockLogger();
        TransformMethodSignature sig = new TransformMethodSignature(Modifier.PUBLIC, "int", "getParentField", null,
                                                                    null);

        replay();

        InternalClassTransformation ct = createClassTransformation(ParentClass.class, logger);
View Full Code Here

    @Test
    public void fields_in_prefixed_methods_are_transformed() throws Exception
    {
        Logger logger = mockLogger();
        TransformMethodSignature sig = new TransformMethodSignature(Modifier.PUBLIC, "int", "getTargetValue", null,
                                                                    null);
        Runnable runnable = mockRunnable();

        runnable.run();

        replay();

        InternalClassTransformation ct = createClassTransformation(MethodPrefixTarget.class, logger);

        String name = ct.addInjectedField(Runnable.class, "runnable", runnable);

        // Transform the field.

        TransformMethodSignature reader = new TransformMethodSignature(Modifier.PRIVATE, "int", "read_target_value",
                                                                       null, null);

        ct.addMethod(reader, "return 66;");

        ct.replaceReadAccess("_targetField", "read_target_value");
View Full Code Here

TOP

Related Classes of org.apache.tapestry5.services.TransformMethodSignature

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.