Examples of MethodAccess


Examples of org.apache.tapestry5.services.MethodAccess

                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

Examples of org.apache.tapestry5.services.MethodAccess

                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

Examples of org.apache.tapestry5.services.MethodAccess

                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

Examples of org.switchyard.common.type.reflect.MethodAccess

                                    }
                                }
                                if (writeMethod != null) {
                                    Class<?> returnClass = writeMethod.getReturnType();
                                    if (returnClass == null || returnClass.isAssignableFrom(declaringClass)) {
                                        access = new MethodAccess(readMethod, writeMethod);
                                    }
                                }
                            }
                        }
                        if (access == null) {
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.