Package org.apache.hivemind.service

Examples of org.apache.hivemind.service.BodyBuilder


        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


    {
        Class serviceInterface = servicePoint.getServiceInterface();

        classFab.addField(SERVICE_ACCESSOR_METHOD_NAME, serviceInterface);

        BodyBuilder builder = new BodyBuilder();
        builder.begin();

        builder.add("return (");
        builder.add(serviceInterface.getName());
        builder.add(") _serviceModel.");
        builder.add(serviceModelMethodName);
        builder.add("();");

        builder.end();

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

     * Creates a method that delegates to the _delegate object; this is used for
     * methods that are not logged.
     */
    private void addPassThruMethodImplementation(ClassFab classFab, MethodSignature sig)
    {
        BodyBuilder builder = new BodyBuilder();
        builder.begin();

        builder.add("return ($r) _delegate.");
        builder.add(sig.getName());
        builder.addln("($$);");

        builder.end();

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

        Class returnType = sig.getReturnType();
        String methodName = sig.getName();

        boolean isVoid = (returnType == void.class);

        BodyBuilder builder = new BodyBuilder();

        builder.begin();
        builder.addln("boolean debug = _log.isDebugEnabled();");

        builder.addln("if (debug)");
        builder.add("  org.apache.hivemind.service.impl.LoggingUtils.entry(_log, ");
        builder.addQuoted(methodName);
        builder.addln(", $args);");

        if (!isVoid)
        {
            builder.add(ClassFabUtils.getJavaClassName(returnType));
            builder.add(" result = ");
        }

        builder.add("_delegate.");
        builder.add(methodName);
        builder.addln("($$);");

        if (isVoid)
        {
            builder.addln("if (debug)");
            builder.add("  org.apache.hivemind.service.impl.LoggingUtils.voidExit(_log, ");
            builder.addQuoted(methodName);
            builder.addln(");");
        }
        else
        {
            builder.addln("if (debug)");
            builder.add("  org.apache.hivemind.service.impl.LoggingUtils.exit(_log, ");
            builder.addQuoted(methodName);
            builder.addln(", ($w)result);");
            builder.addln("return result;");
        }

        builder.end();

        MethodFab methodFab = classFab.addMethod(Modifier.PUBLIC, sig, builder.toString());

        builder.clear();

        builder.begin();
        builder.add("org.apache.hivemind.service.impl.LoggingUtils.exception(_log, ");
        builder.addQuoted(methodName);
        builder.addln(", $e);");
        builder.addln("throw $e;");
        builder.end();

        String body = builder.toString();

        Class[] exceptions = sig.getExceptionTypes();

        int count = exceptions.length;
View Full Code Here

        PageRenderSupport support = TapestryUtils.getPageRenderSupport(cycle, component);

        String functionName = support.getUniqueString("popup_window");

        BodyBuilder builder = new BodyBuilder();

        builder.addln("function {0}()", functionName);
        builder.begin();
        builder.addln(
                "var newWindow = window.open({0}, {1}, {2});",
                TapestryUtils.enquote(url),
                TapestryUtils.enquote(getWindowName()),
                TapestryUtils.enquote(getFeatures()));
        builder.addln("newWindow.focus();");
        builder.end();

        support.addBodyScript(builder.toString());

        return "javascript:" + functionName + "();";
    }
View Full Code Here

        Class returnType = sig.getReturnType();
        String methodName = sig.getName();

        boolean isVoid = (returnType == void.class);

        BodyBuilder builder = new BodyBuilder();

        builder.begin();
        builder.addln("boolean debug = _isDebugEnabled();");

        builder.addln("if (debug)");
        builder.add("  _logEntry(");
        builder.addQuoted(methodName);
        builder.addln(", $args);");

        if (!isVoid)
        {
            builder.add(ClassFabUtils.getJavaClassName(returnType));
            builder.add(" result = ");
        }

        builder.add("_inner.");
        builder.add(methodName);
        builder.addln("($$);");

        if (isVoid)
        {
            builder.addln("if (debug)");
            builder.add("  _logVoidExit(");
            builder.addQuoted(methodName);
            builder.addln(");");
        }
        else
        {
            builder.addln("if (debug)");
            builder.add("  _logExit(");
            builder.addQuoted(methodName);
            builder.addln(", ($w)result);");
            builder.addln("return result;");
        }

        builder.end();

        MethodFab methodFab = classFab.addMethod(Modifier.PUBLIC, sig, builder.toString());

        builder.clear();

        builder.begin();
        builder.add("_logException(");
        builder.addQuoted(methodName);
        builder.addln(", $e);");
        builder.addln("throw $e;");
        builder.end();

        String body = builder.toString();

        Class[] exceptions = sig.getExceptionTypes();

        int count = exceptions.length;
View Full Code Here

        return c.newInstance(new Object[] { log, stackTop });
    }

    private void addPassThruMethodImplementation(ClassFab classFab, MethodSignature sig)
    {
        BodyBuilder builder = new BodyBuilder();
        builder.begin();

        if (sig.getReturnType() != void.class)
            builder.add("return ");

        builder.add("_inner.");
        builder.add(sig.getName());
        builder.addln("($$);");

        builder.end();

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

     * @param indirection the name of a variable, or a method invocation snippet,
     * used to redirect the invocation on the proxy to the actual service implementation.
     */
    public void addServiceMethods(String indirection)
    {
        BodyBuilder builder = new BodyBuilder();
        boolean toString = false;

        Method[] methods = _serviceInterface.getMethods();
        for (int i = 0; i < methods.length; i++)
        {
          Method m = methods[i];
         
            builder.clear();
            builder.begin();
            builder.add("return ($r) ");
            builder.add(indirection);
            builder.add(".");
            builder.add(m.getName());
            builder.addln("($$);");
            builder.end();

            _classFab.addMethod(Modifier.PUBLIC, new MethodSignature(m), builder.toString());

            toString |= ClassFabUtils.isToString(m);
        }

        if (!toString)
View Full Code Here

        // I.e. _$fred = (IComponent) TapestryUtils.getComponent(this, "fred",
        // IComponent.class,
        // location)

        BodyBuilder builder = new BodyBuilder();

        builder.add("{0} = ({1}) ", fieldName, ClassFabUtils
                .getJavaClassName(propertyType));
        builder.add("{0}#getComponent(this, ", TapestryUtils.class.getName());
        builder.addQuoted(componentId);
        builder.add(", {0}, {1});", classField, locationField);

        op.extendMethodImplementation(IComponent.class,
                EnhanceUtils.FINISH_LOAD_SIGNATURE, builder.toString());
    }
View Full Code Here

        PageRenderSupport support = TapestryUtils.getPageRenderSupport(cycle, component);

        String functionName = support.getUniqueString("popup_window");

        BodyBuilder builder = new BodyBuilder();

        builder.addln("function {0}()", functionName);
        builder.begin();
        builder.addln(
                "var newWindow = window.open({0}, {1}, {2});",
                TapestryUtils.enquote(url),
                TapestryUtils.enquote(getWindowName()),
                TapestryUtils.enquote(getFeatures()));
        builder.addln("newWindow.focus();");
        builder.end();

        support.addBodyScript(component, builder.toString());

        return "javascript:" + functionName + "();";
    }
View Full Code Here

TOP

Related Classes of org.apache.hivemind.service.BodyBuilder

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.