Package org.apache.tapestry5.plastic

Examples of org.apache.tapestry5.plastic.InstructionBuilderCallback


                        .inject(creator);

                PlasticMethod delegateMethod = plasticClass.introducePrivateMethod(interfaceType.getName(), "delegate",
                        null, null);

                delegateMethod.changeImplementation(new InstructionBuilderCallback()
                {
                    public void doBuild(InstructionBuilder builder)
                    {
                        builder.loadThis().getField(objectCreatorField);
                        builder.invoke(ObjectCreator.class, Object.class, "createObject");
View Full Code Here


            // TODO: Better handling error case where delegating to a primitive or object array.

            // TODO: Is there a easy way to ensure that the type has the necessary method? I don't
            // like that errors along those lines may be deferred until execution time.

            changeImplementation(new InstructionBuilderCallback()
            {
                public void doBuild(InstructionBuilder builder)
                {
                    // Load the field
View Full Code Here

                throw new IllegalArgumentException(
                        String.format(
                                "Method %s is not usable as a delegate provider; it must be a void method that takes no arguments.",
                                delegateProvidingMethod));

            changeImplementation(new InstructionBuilderCallback()
            {
                public void doBuild(InstructionBuilder builder)
                {
                    // Load the field
View Full Code Here

         */
        void extendShimInvoke(SwitchBlock block)
        {
            final String accessMethodName = setupMethodHandleAccess();

            block.addCase(methodIndex, false, new InstructionBuilderCallback()
            {
                public void doBuild(InstructionBuilder builder)
                {
                    builder.startTryCatch(new TryCatchCallback()
                    {
                        public void doBlock(TryCatchBlock block)
                        {
                            block.addTry(new InstructionBuilderCallback()
                            {
                                public void doBuild(InstructionBuilder builder)
                                {
                                    // The third argument is an Object array; get each
                                    for (int i = 0; i < description.argumentTypes.length; i++)
                                    {
                                        String argumentType = description.argumentTypes[i];

                                        builder.loadArgument(2);
                                        builder.loadArrayElement(i, Object.class.getName());
                                        builder.castOrUnbox(argumentType);
                                    }

                                    builder.invokeVirtual(className, description.returnType, accessMethodName,
                                            description.argumentTypes);

                                    // TODO: hate see "void" just there.

                                    if (description.returnType.equals("void"))
                                        builder.loadNull();
                                    else
                                        builder.boxPrimitive(description.returnType);

                                    builder.newInstance(SuccessMethodInvocationResult.class).dupe(1).swap();
                                    builder.invokeConstructor(SuccessMethodInvocationResult.class, Object.class);
                                    builder.returnResult();
                                }
                            });

                            for (String exceptionType : description.checkedExceptionTypes)
                            {
                                block.addCatch(exceptionType, new InstructionBuilderCallback()
                                {
                                    public void doBuild(InstructionBuilder builder)
                                    {
                                        builder.newInstance(FailureMethodInvocationResult.class).dupe(1).swap();
                                        builder.invokeConstructor(FailureMethodInvocationResult.class, Throwable.class);
View Full Code Here

            if (accessType != PropertyAccessType.WRITE_ONLY)
            {
                String signature = node.signature == null ? null : "()" + node.signature;

                introduceAccessorMethod(getTypeName(), "get" + capitalized, null, signature,
                        new InstructionBuilderCallback()
                        {
                            public void doBuild(InstructionBuilder builder)
                            {
                                builder.loadThis().getField(PlasticFieldImpl.this).returnResult();
                            }
                        });
            }

            if (accessType != PropertyAccessType.READ_ONLY)
            {
                String signature = node.signature == null ? null : "(" + node.signature + ")V";

                introduceAccessorMethod("void", "set" + capitalized, new String[]
                { getTypeName() }, node.signature, new InstructionBuilderCallback()
                {
                    public void doBuild(InstructionBuilder builder)
                    {
                        builder.loadThis().loadArgument(0);
                        builder.putField(className, node.name, getTypeName());
View Full Code Here

            final String methodToInvoke = getAccess.name;

            shimInvokedMethods.add(getAccess);

            switchBlock.addCase(fieldIndex, false, new InstructionBuilderCallback()
            {
                public void doBuild(InstructionBuilder builder)
                {
                    builder.invokeVirtual(className, typeName, methodToInvoke).boxPrimitive(typeName).returnResult();
                }
View Full Code Here

            shimInvokedMethods.add(setAccess);

            final String methodToInvoke = setAccess.name;

            switchBlock.addCase(fieldIndex, true, new InstructionBuilderCallback()
            {

                public void doBuild(InstructionBuilder builder)
                {
                    builder.castOrUnbox(typeName);
View Full Code Here

                    {
                        for (int i = 0; i < description.argumentTypes.length; i++)
                        {
                            final int index = i;

                            block.addCase(i, false, new InstructionBuilderCallback()
                            {

                                public void doBuild(InstructionBuilder builder)
                                {
                                    String type = description.argumentTypes[index];
View Full Code Here

                    {
                        for (int i = 0; i < description.argumentTypes.length; i++)
                        {
                            final int index = i;

                            block.addCase(i, true, new InstructionBuilderCallback()
                            {

                                public void doBuild(InstructionBuilder builder)
                                {
                                    String type = description.argumentTypes[index];
View Full Code Here

            builder.startTryCatch(new TryCatchCallback()
            {
                public void doBlock(TryCatchBlock block)
                {
                    block.addTry(new InstructionBuilderCallback()
                    {

                        public void doBuild(InstructionBuilder builder)
                        {
                            builder.invokeVirtual(className, description.returnType, newMethodName,
                                    description.argumentTypes);

                            if (!isVoid)
                                builder.putField(invocationClassName, RETURN_VALUE, description.returnType);

                            builder.returnResult();
                        }
                    });

                    for (String exceptionName : description.checkedExceptionTypes)
                    {
                        block.addCatch(exceptionName, new InstructionBuilderCallback()
                        {
                            public void doBuild(InstructionBuilder builder)
                            {
                                builder.loadThis().swap();
                                builder.invoke(AbstractMethodInvocation.class, MethodInvocation.class,
View Full Code Here

TOP

Related Classes of org.apache.tapestry5.plastic.InstructionBuilderCallback

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.