Package org.codehaus.aspectwerkz.definition

Examples of org.codehaus.aspectwerkz.definition.AspectDefinition


    private static void parseIntroductionAttributes(
            final AspectWerkzDefinition definition,
            final String className,
            final QDoxParser qdoxParser) {

        AspectDefinition aspectDefinition = definition.getAspectDefinition(
                AspectWerkzDefinition.SYSTEM_ASPECT);

        JavaClass javaClass = qdoxParser.getJavaClass();
        DocletTag[] introductionTags = javaClass.getTagsByName(AttributeTag.INTRODUCTION);

        IntroductionWeavingRule weavingRule = new IntroductionWeavingRule();
        weavingRule.setClassPattern(className);

        for (int i = 0; i < introductionTags.length; i++) {
            if (introductionTags[i] == null) {
                continue;
            }
            String[] attributes = introductionTags[i].getParameters();
            for (int j = 0; j < attributes.length; j++) {
                final String introductionRef = definition.
                        getIntroductionNameByAttribute(attributes[j]);
                if (introductionRef == null) {
                    continue;
                }
                weavingRule.addIntroductionRef(introductionRef);
            }
            aspectDefinition.addIntroductionWeavingRule(weavingRule);
        }
    }
View Full Code Here


        Map aspectModelMap = new HashMap();

        for (int i = 0; i < m_aspectInfos.length; i++) {

            AspectDefinition aspectDef = m_aspectInfos[i].getAspectDefinition();

            if (aspectDef.isAspectWerkzAspect()) {

                continue; // AW Aspect Model not managed by AspectModelManager

            }

            String type = aspectDef.getAspectModel();

            AspectModel aspectModel = AspectModelManager.getModelFor(type);

            aspectModelMap.put(type, aspectModel);
View Full Code Here

            loadAspect(cv, isOptimizedJoinPoint, joinPointInstanceIndex, adviceMethodInfo.getAspectInfo());



            AspectDefinition aspectDef = adviceMethodInfo.getAdviceInfo().getAdviceDefinition().getAspectDefinition();

            if (aspectDef.isAspectWerkzAspect()) {

                // AW aspect

                int[] argIndexes = adviceMethodInfo.getAdviceMethodArgIndexes();

                // if empty, we consider for now that we have to push JoinPoint for old advice with JoinPoint as sole arg

                for (int j = 0; j < argIndexes.length; j++) {

                    int argIndex = argIndexes[j];

                    if (argIndex >= 0) {

                        Type argumentType = m_argumentTypes[argIndex];

                        int argStackIndex = AsmHelper.getRegisterIndexOf(m_argumentTypes, argIndex) + argStartIndex;

                        AsmHelper.loadType(cv, argStackIndex, argumentType);

                    } else if (argIndex == AdviceInfo.JOINPOINT_ARG || argIndex == AdviceInfo.STATIC_JOINPOINT_ARG) {

                        loadJoinPointInstance(cv, isOptimizedJoinPoint, joinPointInstanceIndex);

                    } else if (argIndex == AdviceInfo.TARGET_ARG) {

                        loadCallee(cv, isOptimizedJoinPoint, joinPointInstanceIndex, calleeIndex);

                        // add a cast if runtime check was used

                        if (adviceMethodInfo.getAdviceInfo().hasTargetWithRuntimeCheck()) {

                            cv.visitTypeInsn(

                                    CHECKCAST,

                                    adviceMethodInfo.getAdviceInfo().getMethodParameterTypes()[j].getInternalName()

                            );

                        }

                    } else if (argIndex == AdviceInfo.THIS_ARG) {

                        loadCaller(cv, isOptimizedJoinPoint, joinPointInstanceIndex, callerIndex);

                    } else {

                        throw new Error("special argument index is not supported: " + argIndex);

                    }

                }

            } else {

                // non-AW aspect

                adviceMethodInfo.setJoinPointIndex(joinPointInstanceIndex);

                for (int j = 0; j < m_aspectModels.length; j++) {

                    AspectModel aspectModel = m_aspectModels[j];

                    if (aspectDef.getAspectModel().equals(aspectModel.getAspectModelType())) {

                        aspectModel.createBeforeAdviceArgumentHandling(cv, adviceMethodInfo);

                    }
View Full Code Here

        loadAspect(cv, isOptimizedJoinPoint, joinPointInstanceIndex, adviceMethodInfo.getAspectInfo());



        AspectDefinition aspectDef = adviceMethodInfo.getAdviceInfo().getAdviceDefinition().getAspectDefinition();

        if (aspectDef.isAspectWerkzAspect()) {

            // AW aspect

            // load the arguments that should be passed to the advice

            int[] argIndexes = adviceMethodInfo.getAdviceMethodArgIndexes();

            for (int j = 0; j < argIndexes.length; j++) {

                int argIndex = argIndexes[j];

                if (argIndex >= 0) {

                    Type argumentType = m_argumentTypes[argIndex];

                    int argStackIndex = AsmHelper.getRegisterIndexOf(m_argumentTypes, argIndex) + argStartIndex;

                    AsmHelper.loadType(cv, argStackIndex, argumentType);

                } else if (argIndex == AdviceInfo.JOINPOINT_ARG || argIndex == AdviceInfo.STATIC_JOINPOINT_ARG) {

                    loadJoinPointInstance(cv, isOptimizedJoinPoint, joinPointInstanceIndex);

                } else if (argIndex == AdviceInfo.TARGET_ARG) {

                    loadCallee(cv, isOptimizedJoinPoint, joinPointInstanceIndex, calleeIndex);

                    // add a cast if runtime check was used

                    if (adviceMethodInfo.getAdviceInfo().hasTargetWithRuntimeCheck()) {

                        cv.visitTypeInsn(

                                CHECKCAST,

                                adviceMethodInfo.getAdviceInfo().getMethodParameterTypes()[j].getInternalName()

                        );

                    }

                } else if (argIndex == AdviceInfo.THIS_ARG) {

                    loadCaller(cv, isOptimizedJoinPoint, joinPointInstanceIndex, callerIndex);

                } else if (argIndex == AdviceInfo.SPECIAL_ARGUMENT && specialArgIndex != INDEX_NOTAVAILABLE) {

                    Type argumentType = adviceMethodInfo.getAdviceInfo().getMethodParameterTypes()[j];

                    AsmHelper.loadType(cv, specialArgIndex, argumentType);

                    if (adviceMethodInfo.getAdviceInfo().getAdviceDefinition().getType().equals(

                            AdviceType.AFTER_THROWING

                    )) {

                        cv.visitTypeInsn(CHECKCAST, argumentType.getInternalName());

                    }

                } else {

                    throw new Error("magic index is not supported: " + argIndex);

                }

            }

        } else {

            // non-AW aspect

            adviceMethodInfo.setJoinPointIndex(joinPointInstanceIndex);

            for (int i = 0; i < m_aspectModels.length; i++) {

                AspectModel aspectModel = m_aspectModels[i];

                if (aspectDef.getAspectModel().equals(aspectModel.getAspectModelType())) {

                    aspectModel.createAfterAdviceArgumentHandling(cv, adviceMethodInfo);

                }
View Full Code Here

    void revertChanges() {
        final ClassLoader loader = (ClassLoader) m_loaderRef.get();
        // hotdeployment is done thru the virtual system, so reverts changes as well
        SystemDefinition systemDef = SystemDefinitionContainer.getVirtualDefinitionAt(loader);
        for (Iterator it2 = systemDef.getAspectDefinitions().iterator(); it2.hasNext();) {
            AspectDefinition aspectDef = (AspectDefinition) it2.next();
            for (Iterator it3 = aspectDef.getAfterAdviceDefinitions().iterator(); it3.hasNext();) {
                AdviceDefinition adviceDef = (AdviceDefinition) it3.next();
                DefinitionChangeElement changeElement =
                        (DefinitionChangeElement) m_definitionChangeElements.get(adviceDef.getQualifiedName());
                if (changeElement != null) {
                    changeElement.getAdviceDef().setExpressionInfo(changeElement.getOldExpression());
View Full Code Here

     * @param visibleFrom
     * @param qName
     * @return
     */
    private static AspectDefinition lookupAspectDefinition(final ClassLoader visibleFrom, final String qName) {
        AspectDefinition aspectDefinition = null;

        Set definitions = SystemDefinitionContainer.getDefinitionsFor(visibleFrom);
        if (qName.indexOf('/')>0) {
            // has system uuid ie real qName
            for (Iterator iterator = definitions.iterator(); iterator.hasNext();) {
                SystemDefinition systemDefinition = (SystemDefinition) iterator.next();
                for (Iterator iterator1 = systemDefinition.getAspectDefinitions().iterator(); iterator1.hasNext();) {
                    AspectDefinition aspectDef = (AspectDefinition) iterator1.next();
                    if (qName.equals(aspectDef.getQualifiedName())) {
                        aspectDefinition = aspectDef;
                        break;
                    }
                }
            }
        } else {
            // fallback on class name lookup
            // must find at most one
            int found = 0;
            for (Iterator iterator = definitions.iterator(); iterator.hasNext();) {
                SystemDefinition systemDefinition = (SystemDefinition) iterator.next();
                for (Iterator iterator1 = systemDefinition.getAspectDefinitions().iterator(); iterator1.hasNext();) {
                    AspectDefinition aspectDef = (AspectDefinition) iterator1.next();
                    if (qName.equals(aspectDef.getClassName())) {
                        aspectDefinition = aspectDef;
                        found++;
                    }
                }
            }
View Full Code Here

        ClassInfo cflowAspectInfo = JavaClassInfo.getClassInfo(aspectClass);



        AspectDefinition aspectDef = new AspectDefinition(

                aspectName.replace('/', '.'),

                cflowAspectInfo,

                systemDefinition

        );

        aspectDef.addBeforeAdviceDefinition(

                new AdviceDefinition(

                        CFLOW_ENTER_ADVICE.getName(),

                        AdviceType.BEFORE,

                        null,

                        aspectName,

                        aspectName,

                        m_cflowSubExpression,

                        CFLOW_ENTER_ADVICE,

                        aspectDef

                )

        );

        aspectDef.addAfterAdviceDefinition(

                new AdviceDefinition(

                        CFLOW_EXIT_ADVICE.getName(),
View Full Code Here

            Collection aspects = systemDefinition.getAspectDefinitions();

            for (Iterator iterator1 = aspects.iterator(); iterator1.hasNext();) {

                AspectDefinition aspectDefinition = (AspectDefinition) iterator1.next();

                if (aspectDefinition.getName().equals(Virtual.class.getName())) {

                    continue;

                }



                //TODO - do we care about non bounded pointcut ?

                for (Iterator iterator2 = aspectDefinition.getAdviceDefinitions().iterator(); iterator2.hasNext();) {

                    AdviceDefinition adviceDefinition = (AdviceDefinition) iterator2.next();

                    final ExpressionInfo expressionInfo = adviceDefinition.getExpressionInfo();

                    if (expressionInfo == null) {

                        continue;

                    }

                    if (expressionInfo.getExpression().match(expressionContext)) {

                        // compute the target method to advice method arguments map, and grab information about this

                        // and target bindings

                        expressionContext.resetRuntimeState();

                        ArgsIndexVisitor.updateContextForRuntimeInformation(

                                expressionInfo,

                                expressionContext,

                                loader

                        );

                        // Note that the expressionContext dynamic information updated here should only be used

                        // in the scope of this code block, since at the next iteration, the data will be

                        // updated for another advice binding

                        // [hence see setMethodArgumentIndexes below]



                        // create a lightweight representation of the bounded advices to pass to the compiler

                        final MethodInfo adviceMethodInfo = adviceDefinition.getMethodInfo();

                        final AdviceInfo adviceInfo = new AdviceInfo(

                                aspectDefinition.getQualifiedName(),

                                aspectDefinition.getClassName(),

                                aspectDefinition.getDeploymentModel(),

                                adviceMethodInfo.getName(),

                                AsmHelper.getMethodDescriptor(adviceMethodInfo),
View Full Code Here

        // support for old style advices in XML whose name does not contain the call signature

        if (adviceArgNames.length == 0) {

            AspectDefinition aspectDef = adviceInfo.getAdviceDefinition().getAspectDefinition();

            Type[] adviceArgTypes = adviceInfo.getMethodParameterTypes();

            for (int i = 0; i < adviceArgTypes.length; i++) {



                if (aspectDef.isAspectWerkzAspect()) {

                    if (isJoinPoint(adviceArgTypes[i])) {

                        adviceToTargetArgs[i] = AdviceInfo.JOINPOINT_ARG;

                    } else if (isStaticJoinPoint(adviceArgTypes[i])) {

                        adviceToTargetArgs[i] = AdviceInfo.STATIC_JOINPOINT_ARG;

                    } else {

                        throw new Error(

                                "Unbound unnamed advice parameter at index " + i +

                                " in " + adviceInfo.getMethodSignature()

                        );

                    }

                } else {

                    final AspectModel aspectModel = AspectModelManager.getModelFor(aspectDef.getAspectModel());

                    final String superClassName = aspectModel.getAroundClosureClassInfo().getSuperClassName();

                    final String[] interfaces = aspectModel.getAroundClosureClassInfo().getInterfaceNames();
View Full Code Here

     * @param visibleFrom class loader to look from
     * @param qName
     * @return the container class
     */
    public static String[] getAspectQNameContainerClassName(final ClassLoader visibleFrom, final String qName) {
        AspectDefinition aspectDefinition = lookupAspectDefinition(visibleFrom, qName);
        return new String[]{aspectDefinition.getQualifiedName(), aspectDefinition.getContainerClassName()};
    }
View Full Code Here

TOP

Related Classes of org.codehaus.aspectwerkz.definition.AspectDefinition

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.