Package org.apache.tapestry.services

Examples of org.apache.tapestry.services.TransformMethodSignature


            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

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

        TransformMethodSignature sig = new TransformMethodSignature(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);

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

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

                             String managerFieldName, String typeFieldName)
    {

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

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

        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

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.