Package org.apache.hivemind.service

Examples of org.apache.hivemind.service.MethodSignature


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

        MethodFab mf = cf.addMethod(
                Modifier.PUBLIC + Modifier.FINAL + Modifier.SYNCHRONIZED,
View Full Code Here


    tryAddNoOpMethod(float.class, "{ return 0.0f; }");
  }

  /** @since 1.1 */
  private void tryAddNoOpMethod(Class returnClass, String expectedBody) {
    MethodSignature sig = new MethodSignature(returnClass, "run", null,
        null);

    MockControl control = newControl(ClassFab.class);
    ClassFab cf = (ClassFab) control.getMock();
    MethodFab mf = (MethodFab) newMock(MethodFab.class);
View Full Code Here

        { String.class, delegateClass }, null, "{ this($1); _delegate = $2; }");

        classFab.addInterface(RegistryShutdownListener.class);
        if( RegistryShutdownListener.class.isAssignableFrom( delegateClass ) )
        {
          classFab.addMethod(Modifier.PUBLIC | Modifier.FINAL, new MethodSignature(void.class,
                    "registryDidShutdown", null, null), "{ _delegate.registryDidShutdown(); _delegate = null; _shutdown = true; }");
        }
        else
        {
            classFab.addMethod(Modifier.PUBLIC | Modifier.FINAL, new MethodSignature(void.class,
                    "registryDidShutdown", null, null), "{ _delegate = null; _shutdown = true; }");
        }
        BodyBuilder builder = new BodyBuilder();

        builder.begin();

        builder.addln("if (_shutdown)");
        builder.addln("  throw org.apache.hivemind.HiveMind#createRegistryShutdownException();");

        builder.add("return _delegate;");

        builder.end();

        classFab.addMethod(Modifier.FINAL | Modifier.PRIVATE, new MethodSignature(delegateClass,
                DELEGATE_ACCESSOR_METHOD_NAME, null, null), builder.toString());
    }
View Full Code Here

        return _formatter.format("module-class-is-package-private", moduleClass.getName());
    }

    public static String annotatedMethodHasInvalidModifiers(Method method, String methodType, int invalidModifiers)
    {
        MethodSignature methodSig = new MethodSignature(method);
        String modifierStr = Modifier.toString(invalidModifiers);
        return _formatter.format("annotated-method-has-invalid-modifiers", methodSig.toString(), methodType, modifierStr);
    }
View Full Code Here

        return _formatter.format("annotated-method-has-invalid-modifiers", methodSig.toString(), methodType, modifierStr);
    }

    public static String annotatedMethodIsProtectedAndNotAccessible(Method method, String methodType)
    {
        MethodSignature methodSig = new MethodSignature(method);
        return _formatter.format("annotated-method-protected-not-accessible", methodSig.toString());
    }
View Full Code Here

        classFab.addField("_shutdown", boolean.class);
        if (!RegistryShutdownListener.class.isAssignableFrom(serviceInterface))
        {
            classFab.addInterface(RegistryShutdownListener.class);

            classFab.addMethod(Modifier.PUBLIC | Modifier.FINAL, new MethodSignature(void.class,
                    "registryDidShutdown", null, null), "{ _shutdown = true; }");
        }
        classFab.addMethod(
                Modifier.PUBLIC | Modifier.SYNCHRONIZED | Modifier.FINAL,
                new MethodSignature(void.class, "_setInner", new Class[]
                { serviceInterface }, null),
                "{ _inner = $1; }");

        BodyBuilder builder = new BodyBuilder();
        builder.begin();
        builder.addln("if (_shutdown)");
        builder.begin();
        builder.addln("_inner = null;");
        builder.addln("throw org.apache.hivemind.HiveMind#createRegistryShutdownException();");
        builder.end();

        builder.addln("return _inner;");
        builder.end();

        classFab.addMethod(Modifier.PRIVATE, new MethodSignature(serviceInterface, "_getInner",
                null, null), builder.toString());

        proxyBuilder.addServiceMethods("_getInner()");

        return classFab.createClass();
View Full Code Here

        body.end();

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

        builder.addServiceMethods("_service()");

        // Build the implementation of interface SingletonInnerProxy

        body.clear();
        body.begin();

        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

    private void addClearCachedMethod(ClassFab classFab)
    {
        classFab.addMethod(
            Modifier.PROTECTED,
            new MethodSignature(void.class, "_clearCachedReferences", null, null),
            "_remote = null;");
    }
View Full Code Here

        builder.end();

        classFab.addMethod(
            Modifier.SYNCHRONIZED + Modifier.PRIVATE,
            new MethodSignature(
                remoteInterface,
                "_lookupRemote",
                null,
                new Class[] { RemoteException.class }),
            builder.toString());
View Full Code Here

        builder.add("  throw ex;");
        builder.end(); // catch
        builder.end(); // while
        builder.end();

        classFab.addMethod(Modifier.PUBLIC, new MethodSignature(m), builder.toString());
    }
View Full Code Here

TOP

Related Classes of org.apache.hivemind.service.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.