Package org.codehaus.aspectwerkz.aspect

Examples of org.codehaus.aspectwerkz.aspect.AspectContainer


     *
     * @param index the index of the aspect
     * @return the aspect container
     */
    public AspectContainer getAspectContainer(final int index) {
        AspectContainer aspect;
        try {
            aspect = m_aspectContainers[index - 1];
        }
        catch (Throwable e) {
            initialize();
View Full Code Here


     *
     * @param name the name of the aspect
     * @return the the aspect container
     */
    public AspectContainer getAspectContainer(final String name) {
        AspectContainer container = null;
        try {
            container = m_aspectContainers[m_aspectIndexes.get(name) - 1];
        }
        catch (Throwable e1) {
            initialize();
View Full Code Here

            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.loadIntegerConstant(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
View Full Code Here

        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:
View Full Code Here

        final AdviceMethodInfo[] adviceMethodInfos = new AdviceMethodInfo[adviceInfos.length];
        for (int i = 0; i < adviceInfos.length; i++) {
            AdviceInfo advice = adviceInfos[i];
            AdviceMethodInfo adviceMethodInfo = new AdviceMethodInfo();
            adviceMethodInfos[i] = adviceMethodInfo;
            AspectContainer container = advice.getAspectManager().getAspectContainer(advice.getAspectIndex());
            String aspectClassName = container.getCrossCuttingInfo().getAspectClass().getName().replace('.', '/');
            adviceMethodInfo.adviceInfo = advice;
            adviceMethodInfo.adviceMethod = container.getAdvice(advice.getMethodIndex());
            adviceMethodInfo.aspectClassName = aspectClassName;
            adviceMethodInfo.aspectFieldName = aspectFieldPrefix + i;
            adviceMethodInfo.aspectClassSignature = L + aspectClassName + SEMICOLON;
            adviceMethodInfo.specialArgumentType = advice.getSpecialArgumentType();
            adviceMethodInfo.adviceMethodArgIndexes = advice.getMethodToArgIndexes();
View Full Code Here

            TIntObjectHashMap containers = (TIntObjectHashMap) ASPECT_CONTAINER_LISTS.get(containerClass);
            if (containers == null) {
                containers = new TIntObjectHashMap();
                ASPECT_CONTAINER_LISTS.put(containerClass, containers);
            }
            AspectContainer container = (AspectContainer) containers.get(qName.hashCode());
            if (container == null) {
                container = createAspectContainer(visibleFrom, containerClass, qName);
                containers.put(qName.hashCode(), container);
            }
            return container;
View Full Code Here

                    aspectDefinition.getName(),
                    aspectDefinition.getDeploymentModel(),
                    aspectDefinition,
                    aspectDefinition.getParameters()
            );
            final AspectContainer container = (AspectContainer) constructor.newInstance(new Object[]{aspectContext});
            aspectContext.setContainer(container);
            return container;
        } catch (InvocationTargetException e) {
            throw new NoAspectBoundException(e, qName);
        } catch (NoSuchMethodException e) {
View Full Code Here

            TIntObjectHashMap containers = (TIntObjectHashMap) ASPECT_CONTAINER_LISTS.get(containerClass);
            if (containers == null) {
                containers = new TIntObjectHashMap();
                ASPECT_CONTAINER_LISTS.put(containerClass, containers);
            }
            AspectContainer container = (AspectContainer) containers.get(CompositeVisibleFromQNameKey.hash(visibleFrom, qName));
            if (container == null) {
                container = createAspectContainer(visibleFrom, containerClass, qName);
                containers.put(CompositeVisibleFromQNameKey.hash(visibleFrom, qName), container);
            }
            return container;
View Full Code Here

                    aspectDefinition.getName(),
                    aspectDefinition.getDeploymentModel(),
                    aspectDefinition,
                    aspectDefinition.getParameters()
            );
            final AspectContainer container = (AspectContainer) constructor.newInstance(new Object[]{aspectContext});
            aspectContext.setContainer(container);
            return container;
        } catch (InvocationTargetException e) {
            throw new NoAspectBoundException(e, qName);
        } catch (NoSuchMethodException e) {
View Full Code Here

                Map.Entry entry = (Map.Entry)it.next();
                aspect.___AW_setParameter((String)entry.getKey(), (String)entry.getValue());
            }

            // create and set the container for the aspect
            aspect.___AW_setContainer(new AspectContainer(aspect));

            PointcutManager pointcutManager = new PointcutManager(uuid, aspectDef.getName(), deploymentModel);

            // register the aspect in the system
            SystemLoader.getSystem(uuid).getAspectManager().register(aspect, pointcutManager);
View Full Code Here

TOP

Related Classes of org.codehaus.aspectwerkz.aspect.AspectContainer

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.