Package org.apache.tapestry5.services

Examples of org.apache.tapestry5.services.MethodAccess


                TransformMethodSignature targetMethodSignature = new TransformMethodSignature(Modifier.PROTECTED,
                        "void", "protectedVoidNoArgs", null, null);
                TransformMethod pvna = transformation.getOrCreateMethod(targetMethodSignature);

                final MethodAccess pvnaAccess = pvna.getAccess();

                transformation.getOrCreateMethod(RUN).addAdvice(new ComponentMethodAdvice()
                {
                    public void advise(ComponentMethodInvocation invocation)
                    {
                        invocation.proceed();

                        MethodInvocationResult invocationResult = pvnaAccess.invoke(invocation.getInstance());

                        assertFalse(invocationResult.isFail(), "fail should be false, no checked exception thrown");
                    }
                });
            }
View Full Code Here


                TransformMethodSignature targetMethodSignature = new TransformMethodSignature(Modifier.PUBLIC, "void",
                        "publicVoidThrowsException", null, new String[]
                        { SQLException.class.getName() });
                TransformMethod targetMethod = transformation.getOrCreateMethod(targetMethodSignature);

                final MethodAccess targetAccess = targetMethod.getAccess();

                transformation.getOrCreateMethod(RUN).addAdvice(new ComponentMethodAdvice()
                {
                    public void advise(ComponentMethodInvocation invocation)
                    {
                        invocation.proceed();

                        MethodInvocationResult invocationResult = targetAccess.invoke(invocation.getInstance());

                        assertTrue(invocationResult.isFail(), "fail should be true; checked exception thrown");

                        SQLException ex = invocationResult.getThrown(SQLException.class);
View Full Code Here

                TransformMethod incrementer = transformation.getOrCreateMethod(new TransformMethodSignature(
                        Modifier.PUBLIC, "int", "incrementer", new String[]
                        { "int" }, null));

                final MethodAccess incrementerAccess = incrementer.getAccess();

                TransformMethodSignature operateSig = new TransformMethodSignature(Modifier.PUBLIC, "int", "operate",
                        new String[]
                        { "int" }, null);

                TransformMethod operate = transformation.getOrCreateMethod(operateSig);

                operate.addAdvice(new ComponentMethodAdvice()
                {
                    public void advise(ComponentMethodInvocation invocation)
                    {
                        // This advice *replaces* the original do-nothing method, because
                        // it never calls invocation.proceed().

                        // This kind of advice always needs some special knowledge of
                        // the parameters to the original method, so that they can be mapped
                        // to some other method (including a MethodAccess).

                        Integer parameter = (Integer) invocation.getParameter(0);

                        MethodInvocationResult result = incrementerAccess.invoke(invocation.getInstance(), parameter);

                        invocation.overrideResult(result.getReturnValue());
                    }
                });
            }
View Full Code Here

                TransformMethod targetMethod = transformation.getOrCreateMethod(new TransformMethodSignature(
                        Modifier.PRIVATE, "java.lang.String", "privateMethod", new String[]
                        { "java.lang.String", "int" }, null));

                final MethodAccess targetMethodAccess = targetMethod.getAccess();

                TransformMethodSignature processSig = new TransformMethodSignature(Modifier.PUBLIC, "java.lang.String",
                        "process", new String[]
                        { "java.lang.String", "int" }, null);

                TransformMethod process = transformation.getOrCreateMethod(processSig);

                process.addAdvice(new ComponentMethodAdvice()
                {
                    public void advise(ComponentMethodInvocation invocation)
                    {
                        // Don't even bother with proceed() this time, which is OK (but
                        // somewhat rare).

                        MethodInvocationResult result = targetMethodAccess.invoke(invocation.getInstance(), invocation
                                .getParameter(0), invocation.getParameter(1));

                        invocation.overrideResult(result.getReturnValue());
                    }
                });
View Full Code Here

    }

    private void captureDefaultValueFromDefaultMethod(ClassTransformation transformation,
            TransformMethod defaultMethod, final FieldAccess conduitAccess)
    {
        final MethodAccess access = defaultMethod.getAccess();

        ComponentMethodAdvice advice = new InvokeParameterDefaultMethod(conduitAccess, access);

        addPageLoadAdvice(transformation, advice);
    }
View Full Code Here

    private void invokeMethodWithinLifecycle(final ClassTransformation transformation, TransformMethod method)
    {
        validateMethodSignature(method);

        final MethodAccess access = method.getAccess();

        ComponentMethodAdvice advice = createAdviceToInvokeMethod(access);

        transformation.getOrCreateMethod(lifecycleMethodSignature).addAdvice(advice);
    }
View Full Code Here

    {
        List<Invoker> result = CollectionFactory.newList();

        for (TransformMethod method : methods)
        {
            MethodAccess methodAccess = toMethodAccess(method);

            Invoker invoker = new Invoker(method.getMethodIdentifier(), methodAccess);

            result.add(invoker);
        }
View Full Code Here

                TransformMethodSignature targetMethodSignature = new TransformMethodSignature(Modifier.PROTECTED,
                        "void", "protectedVoidNoArgs", null, null);
                TransformMethod pvna = transformation.getOrCreateMethod(targetMethodSignature);

                final MethodAccess pvnaAccess = pvna.getAccess();

                transformation.getOrCreateMethod(RUN).addAdvice(new ComponentMethodAdvice()
                {
                    public void advise(ComponentMethodInvocation invocation)
                    {
                        invocation.proceed();

                        MethodInvocationResult invocationResult = pvnaAccess.invoke(invocation.getInstance());

                        assertFalse(invocationResult.isFail(), "fail should be false, no checked exception thrown");
                    }
                });
            }
View Full Code Here

                TransformMethodSignature targetMethodSignature = new TransformMethodSignature(Modifier.PUBLIC, "void",
                        "publicVoidThrowsException", null, new String[]
                        { SQLException.class.getName() });
                TransformMethod targetMethod = transformation.getOrCreateMethod(targetMethodSignature);

                final MethodAccess targetAccess = targetMethod.getAccess();

                transformation.getOrCreateMethod(RUN).addAdvice(new ComponentMethodAdvice()
                {
                    public void advise(ComponentMethodInvocation invocation)
                    {
                        invocation.proceed();

                        MethodInvocationResult invocationResult = targetAccess.invoke(invocation.getInstance());

                        assertTrue(invocationResult.isFail(), "fail should be true; checked exception thrown");

                        SQLException ex = invocationResult.getThrown(SQLException.class);
View Full Code Here

                TransformMethod incrementer = transformation.getOrCreateMethod(new TransformMethodSignature(
                        Modifier.PUBLIC, "int", "incrementer", new String[]
                        { "int" }, null));

                final MethodAccess incrementerAccess = incrementer.getAccess();

                TransformMethodSignature operateSig = new TransformMethodSignature(Modifier.PUBLIC, "int", "operate",
                        new String[]
                        { "int" }, null);

                TransformMethod operate = transformation.getOrCreateMethod(operateSig);

                operate.addAdvice(new ComponentMethodAdvice()
                {
                    public void advise(ComponentMethodInvocation invocation)
                    {
                        // This advice *replaces* the original do-nothing method, because
                        // it never calls invocation.proceed().

                        // This kind of advice always needs some special knowledge of
                        // the parameters to the original method, so that they can be mapped
                        // to some other method (including a MethodAccess).

                        Integer parameter = (Integer) invocation.getParameter(0);

                        MethodInvocationResult result = incrementerAccess.invoke(invocation.getInstance(), parameter);

                        invocation.overrideResult(result.getReturnValue());
                    }
                });
            }
View Full Code Here

TOP

Related Classes of org.apache.tapestry5.services.MethodAccess

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.