Package org.apache.tapestry.ioc.services

Examples of org.apache.tapestry.ioc.services.ClassFab.addMethod()


        cf.addMethod(Modifier.PUBLIC, new MethodSignature(void.class, "foo", null, null), "{}");

        try
        {
            cf.addMethod(Modifier.PUBLIC, new MethodSignature(void.class, "foo", null, null), "{}");
            unreachable();
        }
        catch (RuntimeException ex)
        {
            assertEquals("Attempt to redefine method void foo() of class DupeMethodAdd.", ex
View Full Code Here


        MethodSignature sig = new MethodSignature(Map.class, "doTheNasty", new Class[]
        { int.class, String.class }, new Class[]
        { InstantiationException.class, IllegalAccessException.class });

        cf.addMethod(
                Modifier.PUBLIC + Modifier.FINAL + Modifier.SYNCHRONIZED,
                sig,
                "{ return _map; }");

        String toString = cf.toString();
View Full Code Here

        classFab.addField("_serviceType", Class.class);

        classFab.addConstructor(new Class[]
        { Environment.class, Class.class }, null, "{ _environment = $1; _serviceType = $2; }");

        classFab.addMethod(Modifier.PRIVATE, new MethodSignature(serviceType, "_delegate", null,
                null), "return ($r) _environment.peekRequired(_serviceType); ");

        classFab.proxyMethodsToDelegate(serviceType, "_delegate()", format(
                "<EnvironmentalProxy for %s>",
                serviceType.getName()));
View Full Code Here

        { 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);

        cf.proxyMethodsToDelegate(propertyType, "_delegate()", toString);
View Full Code Here

                    interfaceClassName);
            builder.addln("return ($r) adapter.%s($$);", sig.getName());

            builder.end();

            cf.addMethod(Modifier.PUBLIC, sig, builder.toString());

        }

        if (!mi.getToString())
            cf.addToString(String.format("<Strategy for %s>", interfaceClassName));
View Full Code Here

        String body = format("return (%s) _creator.createObject();", serviceInterface.getName());

        MethodSignature sig = new MethodSignature(serviceInterface, PER_THREAD_METHOD_NAME, null,
                null);

        cf.addMethod(Modifier.PRIVATE, sig, body);

        String toString = format(
                "<PerThread Proxy for %s(%s)>",
                resources.getServiceId(),
                serviceInterface.getName());
View Full Code Here

        if (readMethod != null)
        {
            String body = String.format("return ($w) %s.%s();", pathExpression, readMethod
                    .getName());

            classFab.addMethod(Modifier.PUBLIC, GET_SIGNATURE, body);
        }

        if (writeMethod != null)
        {
            BodyBuilder builder = new BodyBuilder();
View Full Code Here

                builder.addln("(%s) $1;", propertyTypeName);

            builder.addln("%s.%s(value);", pathExpression, writeMethod.getName());
            builder.end();

            classFab.addMethod(Modifier.PUBLIC, SET_SIGNATURE, builder.toString());
        }

        return classFab.createClass();
    }
View Full Code Here

        constructor.end();
        newInstance.addln(");");

        cf.addConstructor(constructorParameterTypes, null, constructor.toString());

        cf.addMethod(Modifier.PUBLIC, NEW_INSTANCE_SIGNATURE, newInstance.toString());

        Class instantiatorClass = cf.createClass();

        try
        {
View Full Code Here

        classFab.addField("_serviceType", Class.class);

        classFab.addConstructor(new Class[] { Environment.class, Class.class }, null,
                                "{ _environment = $1; _serviceType = $2; }");

        classFab.addMethod(Modifier.PRIVATE, new MethodSignature(serviceType, "_delegate", null, null),
                           "return ($r) _environment.peekRequired(_serviceType); ");

        classFab.proxyMethodsToDelegate(serviceType, "_delegate()",
                                        format("<EnvironmentalProxy for %s>", serviceType.getName()));
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.