Package org.apache.hivemind.service

Examples of org.apache.hivemind.service.ClassFab.addMethod()


    public void testDupeMethodAdd() 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();
View Full Code Here


        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 (ApplicationRuntimeException ex)
        {
            assertEquals("Attempt to redefine method void foo() of class DupeMethodAdd.", ex
View Full Code Here

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

        cf.addInterface(FailService.class);

        MethodFab mf = cf.addMethod(Modifier.PUBLIC, new MethodSignature(void.class, "fail", null,
                null), "throw new java.lang.RuntimeException(\"Ouch!\");");

        mf.addCatch(RuntimeException.class, "throw new java.io.IOException($e.getMessage());");

        Class targetClass = cf.createClass();
View Full Code Here

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

        cf.addInterface(Runnable.class);

        MethodFab mf = cf.addMethod(Modifier.PUBLIC, new MethodSignature(void.class, "run", null,
                null), "return;");

        try
        {
            mf.addCatch(RuntimeException.class, "woops!");
View Full Code Here

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

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

        mf.addCatch(NullPointerException.class, "return null;");
View Full Code Here

    MockControl control = newControl(ClassFab.class);
    ClassFab cf = (ClassFab) control.getMock();
    MethodFab mf = (MethodFab) newMock(MethodFab.class);

    cf.addMethod(Modifier.PUBLIC, sig, expectedBody);
    control.setReturnValue(mf);

    replayControls();

    ClassFabUtils.addNoOpMethod(cf, sig);
View Full Code Here

        body.add("return _service;");

        body.end();

        classFab.addMethod(
                Modifier.PRIVATE | Modifier.FINAL | Modifier.SYNCHRONIZED,
                new MethodSignature(serviceInterface, "_service", null, null),
                body.toString());

        builder.addServiceMethods("_service()");
View Full Code Here

        body.add("_service();");

        body.end();

        classFab.addMethod(Modifier.PUBLIC | Modifier.FINAL, new MethodSignature(void.class,
                "_instantiateServiceImplementation", null, null), body.toString());

        classFab.addInterface(SingletonInnerProxy.class);

        return classFab.createClass();
View Full Code Here

        cf.addConstructor(new Class[]
        { StrategyRegistry.class }, null, "_registry = $1;");

        // TODO: Should we add a check for $1 == null?

        cf.addMethod(Modifier.PRIVATE, new MethodSignature(serviceInterface, "_getStrategy",
                new Class[]
                { Object.class }, null), "return (" + serviceInterface.getName()
                + ") _registry.getStrategy($1.getClass());");

        MethodIterator i = new MethodIterator(serviceInterface);
View Full Code Here

        MockControl control = newControl(ClassFab.class);
        ClassFab cf = (ClassFab) control.getMock();
        MethodFab mf = (MethodFab) newMock(MethodFab.class);

        cf.addMethod(Modifier.PUBLIC, sig, expectedBody);
        control.setReturnValue(mf);

        replayControls();

        ClassFabUtils.addNoOpMethod(cf, sig);
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.