Examples of AdviceInfo


Examples of org.codehaus.aspectwerkz.AdviceInfo

        // add one case for each around advice invocation
        for (int i = 0; i < aroundAdvice.length; i++) {
            cv.visitLabel(caseLabels[i]);

            // gather advice info
            AdviceInfo adviceInfo = aroundAdvice[i];
            AspectContainer container = adviceInfo.getAspectManager().getAspectContainer(adviceInfo.getAspectIndex());
            Method adviceMethod = container.getAdvice(adviceInfo.getMethodIndex());
            String aspectClassName = container.getCrossCuttingInfo().getAspectClass().getName().replace('.', '/');
            String aspectFieldName = AROUND_ADVICE_FIELD_PREFIX + i;
            String aspectClassSignature = L + aspectClassName + SEMICOLON;

            // get the aspect instance
            cv.visitFieldInsn(GETSTATIC, joinPointClassName, AROUND_ADVICE_FIELD_PREFIX + i, aspectClassSignature);

            // load the arguments to the advice from the join point instance plus build up the advice method signature
            int[] argIndexes = adviceInfo.getMethodToArgIndexes();
            // if empty, we consider for now that we have to push JoinPoint for old advice with JoinPoint as sole arg
            if (argIndexes.length <= 0) {
                cv.visitVarInsn(ALOAD, 0);
            }
            for (int j = 0; j < argIndexes.length; j++) {
View Full Code Here

Examples of org.codehaus.aspectwerkz.AdviceInfo

                                                   final Type[] argumentTypes,
                                                   final int argStartIndex,
                                                   final int joinPointInstanceIndex) {

        for (int i = 0; i < advices.length; i++) {
            AdviceInfo advice = advices[i];
            AspectContainer container = advice.getAspectManager().getAspectContainer(advice.getAspectIndex());
            Method adviceMethod = container.getAdvice(advice.getMethodIndex());
            String aspectClassName = container.getCrossCuttingInfo().getAspectClass().getName().replace('.', '/');
            String aspectFieldName = BEFORE_ADVICE_FIELD_PREFIX + i;
            String aspectClassSignature = L + aspectClassName + SEMICOLON;

            //get the aspect instance
            cv.visitFieldInsn(GETSTATIC, joinPointClassName, aspectFieldName, aspectClassSignature);

            // load the arguments that should be passed to the advice
            int[] argIndexes = advice.getMethodToArgIndexes();
            // if empty, we consider for now that we have to push JoinPoint for old advice with JoinPoint as sole arg
            if (argIndexes.length == 0) {
                if (joinPointInstanceIndex < 0) {
                    // get the static instance of the join point
                    cv.visitFieldInsn(GETSTATIC,
View Full Code Here

Examples of org.codehaus.aspectwerkz.AdviceInfo

                                                  final int argStartIndex,
                                                  final int joinPointInstanceIndex) {

        // add after advice in reverse order
        for (int i = advices.length - 1; i >= 0; i--) {
            AdviceInfo advice = advices[i];
            AspectContainer container = advice.getAspectManager().getAspectContainer(advice.getAspectIndex());
            Method adviceMethod = container.getAdvice(advice.getMethodIndex());
            String aspectClassName = container.getCrossCuttingInfo().getAspectClass().getName().replace('.', '/');
            String aspectFieldName = AFTER_ADVICE_FIELD_PREFIX + i;
            String aspectClassSignature = L + aspectClassName + SEMICOLON;

            // get the aspect instance
            cv.visitFieldInsn(GETSTATIC, joinPointClassName, aspectFieldName, aspectClassSignature);

            // load the arguments that should be passed to the advice
            int[] argIndexes = advice.getMethodToArgIndexes();
            // if empty, we consider for now that we have to push JoinPoint for old advice with JoinPoint as sole arg
            if (argIndexes.length == 0) {
                if (joinPointInstanceIndex < 0) {
                    // get the static instance of the join point
                    cv.visitFieldInsn(GETSTATIC,
View Full Code Here

Examples of org.codehaus.aspectwerkz.AdviceInfo

                pointcut.getExpressionInfo().getArgsIndexMapper().match(ctx);

                //TODO can we do cache, can we do in another visitor
                //TODO skip map when no args()
                for (int j = 0; j <beforeAdviceIndexes.length; j++) {
                    AdviceInfo indexTuple = beforeAdviceIndexes[j];
                    String adviceName = pointcut.getBeforeAdviceName(j);

                    //grab the parameters names
                    String[] adviceArgNames = JoinPointMetaData.getParameterNames(adviceName);

                    // map them from the ctx info
                    int[] adviceToTargetArgs = new int[adviceArgNames.length];
                    for (int k = 0; k < adviceArgNames.length; k++) {
                        String adviceArgName = adviceArgNames[k];
                        int exprArgIndex = pointcut.getExpressionInfo().getArgumentIndex(adviceArgName);
                        if (exprArgIndex >= 0 && ctx.m_exprIndexToTargetIndex.containsKey(exprArgIndex)) {
                            adviceToTargetArgs[k] = ctx.m_exprIndexToTargetIndex.get(exprArgIndex);
                        } else {
                            adviceToTargetArgs[k] = -1;
                        }
                    }
                    //                    //debug:
                    //                    for (int k = 0; k < adviceToTargetArgs.length; k++) {
                    //                        int adviceToTargetArg = adviceToTargetArgs[k];
                    //                        System.out.println(" " + k + " -> " + adviceToTargetArg);
                    //                    }
                    indexTuple.setMethodToArgIndexes(adviceToTargetArgs);
                }
                for (int j = 0; j < afterAdviceIndexes.length; j++) {
                    AdviceInfo indexTuple = afterAdviceIndexes[j];
                    String adviceName = pointcut.getAfterAdviceName(j);

                    //grab the parameters names
                    String[] adviceArgNames = JoinPointMetaData.getParameterNames(adviceName);

                    // map them from the ctx info
                    int[] adviceToTargetArgs = new int[adviceArgNames.length];
                    for (int k = 0; k < adviceArgNames.length; k++) {
                        String adviceArgName = adviceArgNames[k];
                        int exprArgIndex = pointcut.getExpressionInfo().getArgumentIndex(adviceArgName);
                        if (exprArgIndex >= 0 && ctx.m_exprIndexToTargetIndex.containsKey(exprArgIndex)) {
                            adviceToTargetArgs[k] = ctx.m_exprIndexToTargetIndex.get(exprArgIndex);
                        } else {
                            adviceToTargetArgs[k] = -1;
                        }
                    }
                    //                    //debug:
                    //                    for (int k = 0; k < adviceToTargetArgs.length; k++) {
                    //                        int adviceToTargetArg = adviceToTargetArgs[k];
                    //                        System.out.println(" " + k + " -> " + adviceToTargetArg);
                    //                    }
                    indexTuple.setMethodToArgIndexes(adviceToTargetArgs);
                }

                for (int j = 0; j < aroundAdviceIndexes.length; j++) {
                    AdviceInfo indexTuple = aroundAdviceIndexes[j];
                    String adviceName = pointcut.getAroundAdviceName(j);

                    //grab the parameters names
                    String[] adviceArgNames = JoinPointMetaData.getParameterNames(adviceName);

                    // map them from the ctx info
                    int[] adviceToTargetArgs = new int[adviceArgNames.length];
                    for (int k = 0; k < adviceArgNames.length; k++) {
                        String adviceArgName = adviceArgNames[k];
                        int exprArgIndex = pointcut.getExpressionInfo().getArgumentIndex(adviceArgName);
                        if (exprArgIndex >= 0 && ctx.m_exprIndexToTargetIndex.containsKey(exprArgIndex)) {
                            adviceToTargetArgs[k] = ctx.m_exprIndexToTargetIndex.get(exprArgIndex);
                        } else {
                            adviceToTargetArgs[k] = -1;
                        }
                    }
                    //                    //debug:
                    //                    for (int k = 0; k < adviceToTargetArgs.length; k++) {
                    //                        int adviceToTargetArg = adviceToTargetArgs[k];
                    //                        System.out.println(" " + k + " -> " + adviceToTargetArg);
                    //                    }
                    indexTuple.setMethodToArgIndexes(adviceToTargetArgs);
                }

                adviceIndexInfoList.add(adviceIndexInfo);

                // collect the cflow expressions for the matching pointcuts (if they have one)
View Full Code Here

Examples of org.codehaus.aspectwerkz.AdviceInfo

        if (hasBeforeAfterAdvice) {
            cv.visitLabel(switchCaseLabels[0]);

            // add invocations to the before advices
            for (int i = 0; i < beforeAdvices.length; i++) {
                AdviceInfo beforeAdvice = beforeAdvices[i];
                AspectContainer container = beforeAdvice.getAspectManager().getAspectContainer(
                    beforeAdvice.getAspectIndex());
                Method adviceMethod = container.getAdvice(beforeAdvice.getMethodIndex());
                String aspectClassName = container.getCrossCuttingInfo().getAspectClass().getName().replace('.', '/');
                String aspectFieldName = BEFORE_ADVICE_FIELD_PREFIX + i;
                String aspectClassSignature = L + aspectClassName + SEMICOLON;
                // handles advice with signature for args() support
                //      JoinPoint as sole arg or:
                //      this.getRtti().getParametersValues()[<index>], unwrap if primitive type
                int[] argIndexes = beforeAdvice.getMethodToArgIndexes();
                // if no arg or only JoinPoint, we consider for now that we have to push JoinPoint for old advice with JoinPoint as sole arg
                if (isAdviceArgsJoinPointOnly(argIndexes)) {
                    cv.visitVarInsn(Constants.ALOAD, 0);
                    cv.visitFieldInsn(Constants.GETFIELD, className, aspectFieldName, aspectClassSignature);
                    cv.visitVarInsn(Constants.ALOAD, 0);
                } else {
                    Type[] adviceArgTypes = Type.getArgumentTypes(adviceMethod);
                    // this.getRtti().getParameterValues() (array, store in register 2)
                    prepareParameterUnwrapping(joinPointType, adviceArgTypes, cv, className);
                    cv.visitVarInsn(Constants.ALOAD, 0);
                    cv.visitFieldInsn(Constants.GETFIELD, className, aspectFieldName, aspectClassSignature);
                    for (int j = 0; j < argIndexes.length; j++) {
                        int argIndex = argIndexes[j];
                        if (argIndex != -1) {
                            Type argumentType = adviceArgTypes[j];
                            cv.visitVarInsn(Constants.ALOAD, 2);//the param array
                            AsmHelper.loadConstant(cv, argIndex);//index
                            cv.visitInsn(Constants.AALOAD);
                            unwrapParameter(argumentType, cv);//unwrap
                        } else {
                            // assume JoinPoint - TODO support for static part optimization
                            cv.visitVarInsn(Constants.ALOAD, 0);
                        }
                    }
                }
                cv.visitMethodInsn(
                    Constants.INVOKEVIRTUAL,
                    aspectClassName,
                    adviceMethod.getName(),
                    Type.getMethodDescriptor(adviceMethod));
            }

            // add invocation to this.proceed
            cv.visitVarInsn(Constants.ALOAD, 0);
            cv.visitMethodInsn(Constants.INVOKEVIRTUAL, className, PROCEED_METHOD_NAME, PROCEED_METHOD_SIGNATURE);
            cv.visitVarInsn(Constants.ASTORE, 1);

            // add invocations to the after advices
            for (int i = afterAdvices.length - 1; i >= 0; i--) {
                AdviceInfo afterAdvice = afterAdvices[i];
                AspectContainer container = afterAdvice.getAspectManager().getAspectContainer(
                    afterAdvice.getAspectIndex());
                Method adviceMethod = container.getAdvice(afterAdvice.getMethodIndex());
                String aspectClassName = container.getCrossCuttingInfo().getAspectClass().getName().replace('.', '/');
                String aspectFieldName = AFTER_ADVICE_FIELD_PREFIX + i;
                String aspectClassSignature = L + aspectClassName + SEMICOLON;
                // handles advice with signature for args() support
                //      JoinPoint as sole arg or:
                //      this.getRtti().getParametersValues()[<index>], unwrap if primitive type
                int[] argIndexes = afterAdvice.getMethodToArgIndexes();
                // if no arg or only JoinPoint, we consider for now that we have to push JoinPoint for old advice with JoinPoint as sole arg
                if (isAdviceArgsJoinPointOnly(argIndexes)) {
                    cv.visitVarInsn(Constants.ALOAD, 0);
                    cv.visitFieldInsn(Constants.GETFIELD, className, aspectFieldName, aspectClassSignature);
                    cv.visitVarInsn(Constants.ALOAD, 0);
View Full Code Here

Examples of org.codehaus.aspectwerkz.AdviceInfo

        int j = 0;
        if (hasBeforeAfterAdvice) {
            j = 1;
        }
        for (; i < aroundAdvices.length; i++, j++) {
            AdviceInfo aroundAdvice = aroundAdvices[i];
            AspectContainer container = aroundAdvice.getAspectManager().getAspectContainer(
                aroundAdvice.getAspectIndex());
            Method adviceMethod = container.getAdvice(aroundAdvice.getMethodIndex());
            String aspectClassName = container.getCrossCuttingInfo().getAspectClass().getName().replace('.', '/');
            String aspectFieldName = AROUND_ADVICE_FIELD_PREFIX + i;
            String aspectClassSignature = L + aspectClassName + SEMICOLON;
            cv.visitLabel(switchCaseLabels[j]);
            // handles advice with signature for args() support
            //      JoinPoint as sole arg or:
            //      this.getRtti().getParametersValues()[<index>], unwrap if primitive type
            int[] argIndexes = aroundAdvice.getMethodToArgIndexes();
            // if no arg or only JoinPoint, we consider for now that we have to push JoinPoint for old advice with JoinPoint as sole arg
            if (isAdviceArgsJoinPointOnly(argIndexes)) {
                cv.visitVarInsn(Constants.ALOAD, 0);
                cv.visitFieldInsn(Constants.GETFIELD, className, aspectFieldName, aspectClassSignature);
                cv.visitVarInsn(Constants.ALOAD, 0);
View Full Code Here

Examples of org.codehaus.aspectwerkz.AdviceInfo

                pointcut.getExpressionInfo().getArgsIndexMapper().match(ctx);

                //TODO can we do cache, can we do in another visitor
                //TODO skip map when no args()
                for (int j = 0; j <beforeAdviceIndexes.length; j++) {
                    AdviceInfo indexTuple = beforeAdviceIndexes[j];
                    String adviceName = pointcut.getBeforeAdviceName(j);

                    //grab the parameters names
                    String[] adviceArgNames = JoinPointMetaData.getParameterNames(adviceName);

                    // map them from the ctx info
                    int[] adviceToTargetArgs = new int[adviceArgNames.length];
                    for (int k = 0; k < adviceArgNames.length; k++) {
                        String adviceArgName = adviceArgNames[k];
                        int exprArgIndex = pointcut.getExpressionInfo().getArgumentIndex(adviceArgName);
                        if (exprArgIndex >= 0 && ctx.m_exprIndexToTargetIndex.containsKey(exprArgIndex)) {
                            adviceToTargetArgs[k] = ctx.m_exprIndexToTargetIndex.get(exprArgIndex);
                        } else {
                            adviceToTargetArgs[k] = -1;
                        }
                    }
                    //                    //debug:
                    //                    for (int k = 0; k < adviceToTargetArgs.length; k++) {
                    //                        int adviceToTargetArg = adviceToTargetArgs[k];
                    //                        System.out.println(" " + k + " -> " + adviceToTargetArg);
                    //                    }
                    indexTuple.setMethodToArgIndexes(adviceToTargetArgs);
                }
                for (int j = 0; j < afterAdviceIndexes.length; j++) {
                    AdviceInfo indexTuple = afterAdviceIndexes[j];
                    String adviceName = pointcut.getAfterAdviceName(j);

                    //grab the parameters names
                    String[] adviceArgNames = JoinPointMetaData.getParameterNames(adviceName);

                    // map them from the ctx info
                    int[] adviceToTargetArgs = new int[adviceArgNames.length];
                    for (int k = 0; k < adviceArgNames.length; k++) {
                        String adviceArgName = adviceArgNames[k];
                        int exprArgIndex = pointcut.getExpressionInfo().getArgumentIndex(adviceArgName);
                        if (exprArgIndex >= 0 && ctx.m_exprIndexToTargetIndex.containsKey(exprArgIndex)) {
                            adviceToTargetArgs[k] = ctx.m_exprIndexToTargetIndex.get(exprArgIndex);
                        } else {
                            adviceToTargetArgs[k] = -1;
                        }
                    }
                    //                    //debug:
                    //                    for (int k = 0; k < adviceToTargetArgs.length; k++) {
                    //                        int adviceToTargetArg = adviceToTargetArgs[k];
                    //                        System.out.println(" " + k + " -> " + adviceToTargetArg);
                    //                    }
                    indexTuple.setMethodToArgIndexes(adviceToTargetArgs);
                }

                for (int j = 0; j < aroundAdviceIndexes.length; j++) {
                    AdviceInfo indexTuple = aroundAdviceIndexes[j];
                    String adviceName = pointcut.getAroundAdviceName(j);

                    //grab the parameters names
                    String[] adviceArgNames = JoinPointMetaData.getParameterNames(adviceName);

                    // map them from the ctx info
                    int[] adviceToTargetArgs = new int[adviceArgNames.length];
                    for (int k = 0; k < adviceArgNames.length; k++) {
                        String adviceArgName = adviceArgNames[k];
                        int exprArgIndex = pointcut.getExpressionInfo().getArgumentIndex(adviceArgName);
                        if (exprArgIndex >= 0 && ctx.m_exprIndexToTargetIndex.containsKey(exprArgIndex)) {
                            adviceToTargetArgs[k] = ctx.m_exprIndexToTargetIndex.get(exprArgIndex);
                        } else {
                            adviceToTargetArgs[k] = -1;
                        }
                    }
                    //                    //debug:
                    //                    for (int k = 0; k < adviceToTargetArgs.length; k++) {
                    //                        int adviceToTargetArg = adviceToTargetArgs[k];
                    //                        System.out.println(" " + k + " -> " + adviceToTargetArg);
                    //                    }
                    indexTuple.setMethodToArgIndexes(adviceToTargetArgs);
                }

                adviceIndexInfoList.add(adviceIndexInfo);

                // collect the cflow expressions for the matching pointcuts (if they have one)
View Full Code Here

Examples of org.codehaus.aspectwerkz.AdviceInfo

                                // in the
                                // aspectContainer
                                List advices = crossCuttingInfo.getAspectDefinition().getAllAdvices();
                                for (Iterator it = advices.iterator(); it.hasNext();) {
                                    final AdviceDefinition adviceDef = (AdviceDefinition) it.next();
                                    AdviceInfo tuple = new AdviceInfo(
                                        indexAspect,
                                        adviceDef.getMethodIndex(),
                                        m_aspectManager);

                                    //prefix AdviceName with AspectName to allow AspectReuse
View Full Code Here

Examples of org.codehaus.aspectwerkz.AdviceInfo

     */
    public AdviceInfo getAdviceIndexFor(final String name) {
        if (name == null) {
            throw new IllegalArgumentException("advice name can not be null");
        }
        final AdviceInfo index = (AdviceInfo) m_adviceIndexes.get(name);
        if (index == null) {
            throw new DefinitionException("advice " + name + " is not properly defined");
        }
        return index;
    }
View Full Code Here

Examples of org.codehaus.aspectwerkz.AdviceInfo

     * Records entering into cflow.
     *
     * @param joinPointInfo
     */
    private void enterCflow(final JoinPointInfo joinPointInfo) throws Throwable {
        AdviceInfo enter = joinPointInfo.enterCflow;
        if (enter != null) {
            enter.getAspectManager().getAspectContainer(enter.getAspectIndex()).invokeAdvice(
                enter.getMethodIndex(),
                joinPointInfo.joinPoint);
        }
    }
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.