Package org.apache.tapestry5.ioc.services

Examples of org.apache.tapestry5.ioc.services.MethodSignature


    {
        ClassFab cf = newClassFab("SimpleService", Object.class);

        cf.addInterface(SimpleService.class);

        cf.addMethod(Modifier.PUBLIC, new MethodSignature(int.class, "add", new Class[] { int.class, int.class }, null),
                     "return $1 + $2;");

        Class targetClass = cf.createClass();

        SimpleService s = (SimpleService) targetClass.newInstance();
View Full Code Here


        cf.addInterface(Runnable.class);

        try
        {
            cf.addMethod(Modifier.PUBLIC, new MethodSignature(void.class, "run", null, null), "fail;");
        }
        catch (RuntimeException ex)
        {
            assertExceptionSubstring(ex, "Unable to add method void run() to class BadMethodBody:");
        }
View Full Code Here

    @Test
    public void add_duplicate_method_signature() throws Exception
    {
        ClassFab cf = newClassFab("DupeMethodAdd", Object.class);

        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

        cf.addField("_map", Map.class);

        cf.addConstructor(new Class[] { Map.class, Runnable.class },
                          new Class[] { IllegalArgumentException.class, DataFormatException.class }, "{ _map = $1; }");

        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; }");
View Full Code Here

    public void add_noop_method() throws Exception
    {
        ClassFab cf = newClassFab("NoOp", Object.class);
        cf.addInterface(Runnable.class);

        cf.addNoOpMethod(new MethodSignature(void.class, "run", null, null));
        cf.addNoOpMethod(new MethodSignature(int.class, "getInt", null, null));
        cf.addNoOpMethod(new MethodSignature(double.class, "getDouble", null, null));

        Class clazz = cf.createClass();

        Runnable instance = (Runnable) clazz.newInstance();
View Full Code Here

                "org.apache.tapestry5.ioc.internal.services.LineNumberBean.wilma(int[], Double[][][]) (at LineNumberBean.java:34)");
    }

    private void addRunMethod(ClassFab cf)
    {
        cf.addMethod(Modifier.PUBLIC, new MethodSignature(void.class, "run", null, null), " { } ");
    }
View Full Code Here

        MethodIterator mi = new MethodIterator(serviceInterface);

        while (mi.hasNext())
        {
            MethodSignature sig = mi.next();

            // ($r) properly handles void methods for us, which keeps this simple.

            String body = format("return ($r) %s.%s($$);", delegateExpression, sig.getName());

            addMethod(Modifier.PUBLIC, sig, body);
        }

        if (!mi.getToString()) addToString(toString);
View Full Code Here

    public void addToString(String toString)
    {
        lock.check();

        MethodSignature sig = new MethodSignature(String.class, "toString", null, null);

        // TODO: Very simple quoting here, will break down if the string itself contains
        // double quotes or various other characters that need escaping.

        addMethod(Modifier.PUBLIC, sig, format("return \"%s\";", toString));
View Full Code Here

            filterMethods.add(mi.next());
        }

        while (!serviceMethods.isEmpty())
        {
            MethodSignature ms = serviceMethods.remove(0);

            addBridgeMethod(ms, filterMethods);
        }

        reportExtraFilterMethods(filterMethods);
View Full Code Here

    {
        Iterator i = filterMethods.iterator();

        while (i.hasNext())
        {
            MethodSignature ms = (MethodSignature) i.next();

            logger.error(ServiceMessages
                    .extraFilterMethod(ms, filterInterface, serviceInterface));
        }
    }
View Full Code Here

TOP

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