Package org.apache.hivemind.service

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


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

        assertEquals(207, s.add(99, 108));
    }
View Full Code Here


    {
        ClassFab cf = newClassFab("StringSubclass", String.class);

        try
        {
            cf.createClass();
        }
        catch (ApplicationRuntimeException ex)
        {
            assertEquals(
                "Unable to create class StringSubclass: Cannot inherit from final class",
View Full Code Here

    public void testInPackage() throws Exception
    {
        ClassFab cf = newClassFab("org.apache.hivemind.InPackage", Object.class);

        Class c = cf.createClass();

        Object o = c.newInstance();

        assertEquals("org.apache.hivemind.InPackage", o.getClass().getName());
    }
View Full Code Here

                new MethodSignature(int.class, "getValue", null, null),
                "return 1;");

        mf.extend("return 2 * $_;", false);

        Object bean = cf.createClass().newInstance();

        assertEquals(new Integer(2), PropertyUtils.read(bean, "value"));
    }

    public void testExtendMethodAlterReturn() throws Exception
View Full Code Here

                new MethodSignature(int.class, "getValue", null, null),
                "return 2;");

        mf.extend("$_ = 3 * $_;", false);

        Object bean = cf.createClass().newInstance();

        assertEquals(new Integer(6), PropertyUtils.read(bean, "value"));
    }

    public void testExtendMethodFailure() throws Exception
View Full Code Here

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

        FailService fs = (FailService) targetClass.newInstance();

        try
        {
View Full Code Here

        cf.addField("buffy", int.class);
        cf.addField("", int.class);

        try
        {
            cf.createClass();
            unreachable();
        }
        catch (ApplicationRuntimeException ex)
        {
            assertExceptionSubstring(ex, "Unable to create class InvalidField");
View Full Code Here

        addServiceAccessor(classFab, delegationMethodName, servicePoint);

        builder.addServiceMethods(SERVICE_ACCESSOR_METHOD_NAME + "()");

        Class proxyClass = classFab.createClass();

        try
        {
            Constructor c = proxyClass.getConstructor(new Class[] { serviceModel.getClass()});
View Full Code Here

            new MethodSignature(serviceInterface, "_getInner", null, null),
            builder.toString());

        proxyBuilder.addServiceMethods("_getInner()");

        return classFab.createClass();
    }

    private Class createInnerProxyClass(Class deferredProxyClass)
    {
        ServicePoint servicePoint = getServicePoint();
View Full Code Here

            new MethodSignature(void.class, "_instantiateServiceImplementation", null, null),
            body.toString());

        classFab.addInterface(SingletonInnerProxy.class);

        return classFab.createClass();
    }

    public void instantiateService()
    {
        // Ensure that the outer and inner proxies have been created
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.