Package org.apache.tapestry.services

Examples of org.apache.tapestry.services.MethodSignature


        List<MethodSignature> result = newList();

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

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

        Collections.sort(result);
View Full Code Here


        return result;
    }

    private MethodSignature getMethodSignature(CtMethod method)
    {
        MethodSignature 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 MethodSignature(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);

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

        String message = ServicesMessages.readOnlyField(_ctClass.getName(), fieldName);
View Full Code Here

    private void replaceFlagRead(ClassTransformation transformation, String booleanFieldName,
            String typeFieldName, String managerFieldName)
    {
        String readMethodName = transformation.newMemberName("read", booleanFieldName);

        MethodSignature sig = new MethodSignature(Modifier.PRIVATE, "boolean", readMethodName,
                null, null);

        String body = format("return %s.exists(%s);", managerFieldName, typeFieldName);

        transformation.addMethod(sig, body);
View Full Code Here

    private void replaceWrite(ClassTransformation transformation, String fieldName,
            String fieldType, String managerFieldName, String typeFieldName)
    {
        String writeMethodName = transformation.newMemberName("write", fieldName);

        MethodSignature writeSignature = new MethodSignature(Modifier.PRIVATE, "void",
                writeMethodName, new String[]
                { fieldType }, null);

        String body = format("%s.set(%s, $1);", managerFieldName, typeFieldName);
View Full Code Here

            String fieldType, String managerFieldName, String typeFieldName)
    {

        String readMethodName = transformation.newMemberName("read", fieldName);

        MethodSignature readMethodSignature = new MethodSignature(Modifier.PRIVATE, fieldType,
                readMethodName, null, null);

        String body = format("return (%s) %s.get(%s);", fieldType, managerFieldName, typeFieldName);

        transformation.addMethod(readMethodSignature, body);
View Full Code Here

        assertEquals(subclassFieldName, parentFieldName);

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

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

        ct.finish();

        Class transformed = _classPool.toClass(subclassCtClass, _loader);
View Full Code Here

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

        MethodSignature readMethodSignature = new MethodSignature(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;

        MethodSignature writeMethodSignature = new MethodSignature(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, log);

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

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

        assertEquals(annotation.value(), new String[]
        { "fred", "barney" });
View Full Code Here

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

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

TOP

Related Classes of org.apache.tapestry.services.MethodSignature

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.