Package org.apache.tapestry5.plastic

Examples of org.apache.tapestry5.plastic.InstructionBuilderCallback


       
        // TAP5-2235
        final String delegateTypeName = delegateType.getName();
        MethodDescription getDelegateMethodDescription =
                new MethodDescription(delegateTypeName, PlasticProxyFactoryImpl.INTERNAL_GET_DELEGATE);
        plasticClass.introduceMethod(getDelegateMethodDescription, new InstructionBuilderCallback()
        {
            @Override
            public void doBuild(InstructionBuilder builder)
            {
                builder.loadThis().getField(delegateField);
View Full Code Here


                final PlasticField registryField = plasticClass.introduceField(StrategyRegistry.class, "registry")
                        .inject(registry);

                for (final Method method : interfaceType.getMethods())
                {
                    plasticClass.introduceMethod(new MethodDescription(method), new InstructionBuilderCallback()
                    {
                        @Override
                        public void doBuild(InstructionBuilder builder)
                        {
                            Class returnType = method.getReturnType();
View Full Code Here

        return instantiator.newInstance();
    }

    private void implementMethod(PlasticClass plasticClass, final Method method, final PlasticField commandsField)
    {
        plasticClass.introduceMethod(method).changeImplementation(new InstructionBuilderCallback()
        {
            @Override
            public void doBuild(InstructionBuilder builder)
            {
                builder.loadThis().getField(commandsField).iterateArray(new InstructionBuilderCallback()
                {
                    @Override
                    public void doBuild(InstructionBuilder builder)
                    {
                        // The command is on the stack; add the elements and invoke the method.
View Full Code Here

        callback.doSwitch(this);

        if (!defaultAdded)
        {
            addDefault(new InstructionBuilderCallback()
            {
                @Override
                public void doBuild(InstructionBuilder builder)
                {
                    builder.throwException(IllegalArgumentException.class,
View Full Code Here

    {
        check();

        final LocalVariable var = state.startVariable(type);

        new InstructionBuilderCallback()
        {
            public void doBuild(InstructionBuilder builder)
            {
                callback.doBuild(var, builder);
            }
View Full Code Here

        Label ifFalseLabel = new Label();
        Label endIfLabel = new Label();

        v.visitJumpInsn(conditionToOpcode.get(condition), ifFalseLabel);

        new InstructionBuilderCallback()
        {
            public void doBuild(InstructionBuilder builder)
            {
                callback.ifTrue(builder);
            }
        }.doBuild(this);

        v.visitJumpInsn(GOTO, endIfLabel);

        v.visitLabel(ifFalseLabel);

        new InstructionBuilderCallback()
        {
            public void doBuild(InstructionBuilder builder)
            {
                callback.ifFalse(builder);
            }
View Full Code Here

        Label doCheck = state.newLabel();

        Label exitLoop = new Label();

        new InstructionBuilderCallback()
        {
            public void doBuild(InstructionBuilder builder)
            {
                callback.buildTest(builder);
            }
        }.doBuild(this);

        v.visitJumpInsn(conditionToOpcode.get(condition), exitLoop);

        new InstructionBuilderCallback()
        {
            public void doBuild(InstructionBuilder builder)
            {
                callback.buildBody(builder);
            }
View Full Code Here

    {
        check();

        if (!isMethodImplemented(PlasticUtils.TO_STRING_DESCRIPTION))
        {
            introduceMethod(PlasticUtils.TO_STRING_DESCRIPTION, new InstructionBuilderCallback()
            {
                public void doBuild(InstructionBuilder builder)
                {
                    builder.loadConstant(toStringValue).returnResult();
                }
View Full Code Here

        plasticClass.introduceInterface(Component.class);

        final PlasticField resourcesField = plasticClass.introduceField(InternalComponentResources.class,
                "internalComponentResources").injectFromInstanceContext();

        plasticClass.introduceMethod(GET_COMPONENT_RESOURCES, new InstructionBuilderCallback()
        {
            public void doBuild(InstructionBuilder builder)
            {
                builder.loadThis().getField(resourcesField).returnResult();
            }
View Full Code Here

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

                // If not concerned with efficiency, this might be done with method advice instead.
                delegateMethod.changeImplementation(new InstructionBuilderCallback()
                {
                    public void doBuild(InstructionBuilder builder)
                    {
                        builder.loadThis().getField(plasticClass.getClassName(), creatorField.getName(),
                                ObjectCreator.class);
                        builder.invoke(ObjectCreator.class, Object.class, "createObject").checkcast(serviceInterface)
                                .returnResult();
                    }
                });

                for (Method m : serviceInterface.getMethods())
                {
                    plasticClass.introduceMethod(m).delegateTo(delegateMethod);
                }

                plasticClass.introduceMethod(WRITE_REPLACE).changeImplementation(new InstructionBuilderCallback()
                {
                    public void doBuild(InstructionBuilder builder)
                    {
                        builder.loadThis()
                                .getField(plasticClass.getClassName(), tokenField.getName(), ServiceProxyToken.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.