Package org.apache.tapestry.services

Examples of org.apache.tapestry.services.TransformMethodSignature


    @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


    @Test
    public void extend_existing_method_fields_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

    @Test
    public void invalid_code() 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

        List<TransformMethodSignature> sigs = ct.findMethodsWithAnnotation(OnEvent.class);

        assertEquals(sigs.size(), 1);

        TransformMethodSignature sig = sigs.get(0);

        assertEquals(ct.getMethodIdentifier(sig),
                     "org.apache.tapestry.internal.transform.pages.MethodIdentifier.makeWaves(java.lang.String, int[]) (at MethodIdentifier.java:24)");

        verify();
View Full Code Here

        addImplementedInterface(Component.class);

        _resourcesFieldName = addInjectedFieldUncached(InternalComponentResources.class, "resources", null);

        TransformMethodSignature sig = new TransformMethodSignature(Modifier.PUBLIC | Modifier.FINAL,
                                                                    ComponentResources.class.getName(),
                                                                    "getComponentResources", null, null);

        addMethod(sig, "return " + _resourcesFieldName + ";");
View Full Code Here

            newMethod.setBody(null);

            _ctClass.addMethod(newMethod);

            TransformMethodSignature sig = getMethodSignature(newMethod);

            addMethodToDescription("add default", sig, "<default>");
        }
        catch (CannotCompileException ex)
        {
View Full Code Here

        {
            List<Annotation> annotations = findMethodAnnotations(method);

            if (findAnnotationInList(annotationClass, annotations) != null)
            {
                TransformMethodSignature sig = getMethodSignature(method);
                result.add(sig);
            }
        }

        Collections.sort(result);
View Full Code Here

        List<TransformMethodSignature> result = newList();

        for (CtMethod method : _ctClass.getDeclaredMethods())
        {
            TransformMethodSignature sig = getMethodSignature(method);

            if (filter.accept(sig)) result.add(sig);
        }

        Collections.sort(result);
View Full Code Here

        return result;
    }

    private TransformMethodSignature getMethodSignature(CtMethod method)
    {
        TransformMethodSignature result = _methodSignatures.get(method);
        if (result == null)
        {
            try
            {
                String type = method.getReturnType().getName();
                String[] parameters = toTypeNames(method.getParameterTypes());
                String[] exceptions = toTypeNames(method.getExceptionTypes());

                result = new TransformMethodSignature(method.getModifiers(), type, method.getName(), parameters,
                                                      exceptions);

                _methodSignatures.put(method, result);
            }
            catch (NotFoundException ex)
View Full Code Here

    {
        String methodName = newMemberName("write", fieldName);

        String fieldType = getFieldType(fieldName);

        TransformMethodSignature sig = new TransformMethodSignature(Modifier.PRIVATE, "void", methodName,
                                                                    new String[]{fieldType}, null);

        String message = ServicesMessages.readOnlyField(_ctClass.getName(), fieldName);

        String body = format("throw new java.lang.RuntimeException(\"%s\");", message);
View Full Code Here

TOP

Related Classes of org.apache.tapestry.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.