Package org.codehaus.aspectwerkz.definition

Examples of org.codehaus.aspectwerkz.definition.AdviceDefinition


        SystemDefinition sysDef = DefinitionLoader.getDefinition(HotSwapTarget.class.getClassLoader(), "samples");
        AspectDefinition aspectDef = sysDef.getAspectDefinition(aspectName);

        List removedAdviceDefs = new ArrayList();
        for (Iterator arounds = aspectDef.getAroundAdvices().iterator(); arounds.hasNext();) {
            AdviceDefinition around = (AdviceDefinition)arounds.next();
            if (pointcutName.equals(around.getExpression().getName())) {
                System.out.println("<removing> " + around.getName());
                removedAdviceDefs.add(around);
            }
        }
        for (Iterator arounds = removedAdviceDefs.iterator(); arounds.hasNext();) {
            aspectDef.removeAroundAdvice((AdviceDefinition)arounds.next());
View Full Code Here


                                java.lang.System.arraycopy(tmpAspects, 0, m_aspectContainers, 0, tmpAspects.length);

                                // retrieve a sorted advices list => matches the sorted method list in the container
                                List advices = crossCuttingInfo.getAspectDefinition().getAllAdvices();
                                for (Iterator it = advices.iterator(); it.hasNext();) {
                                    final AdviceDefinition adviceDef = (AdviceDefinition)it.next();
                                    m_adviceIndexes.put(
                                            adviceDef.getName(),
                                            new IndexTuple(indexAspect, adviceDef.getMethodIndex())
                                    );
                                }

                                // mixins
                                List introductions = crossCuttingInfo.getAspectDefinition().getIntroductions();
View Full Code Here

    public void testAdviceTag() {
        try {
            AspectWerkzDefinition aspectwerkz = XmlDefinitionParser.parseNoCache(m_input.toURL());
            Iterator it = aspectwerkz.getAdviceDefinitions().iterator();
            AdviceDefinition advice1 = (AdviceDefinition)it.next();
            assertEquals("logging", advice1.getName());
            assertEquals("examples.logging.LoggingAdvice", advice1.getAdviceClassName());
            assertEquals("perClass", advice1.getDeploymentModel());
            assertEquals("log", advice1.getAttribute());
        }
        catch (Exception e) {
            fail();
        }
    }
View Full Code Here

        // create the cflow pre and post advice definitions
        addAdviceDefElement(root, CFlowPreAdvice.getDefinition());
        addAdviceDefElement(root, CFlowPostAdvice.getDefinition());

        for (Iterator it = definition.getAdviceDefinitions().iterator(); it.hasNext();) {
            AdviceDefinition def = (AdviceDefinition)it.next();
            addAdviceDefElement(root, def);
        }
    }
View Full Code Here

        for (int i = 0; i < adviceDefTags.length; i++) {
            if (adviceDefTags[i] == null) {
                continue;
            }

            AdviceDefinition adviceDef = new AdviceDefinition();
            adviceDef.setName(adviceDefTags[i].getNamedParameter("name"));
            adviceDef.setAdviceClassName(javaClass.getFullyQualifiedName());
            adviceDef.setDeploymentModel(adviceDefTags[i].getNamedParameter("deployment-model"));
            adviceDef.setIsPersistent(adviceDefTags[i].getNamedParameter("persistent"));
            adviceDef.setAttribute(adviceDefTags[i].getNamedParameter("attribute"));

            weaveAdviceParamAttributes(javaClass, adviceDef);

            definition.addAdvice(adviceDef);
        }
View Full Code Here

            }

            // match on perinstance deployed aspects
            Collection adviceDefs = systemDef.getAdviceDefinitions();
            for (Iterator defs = adviceDefs.iterator(); defs.hasNext();) {
                AdviceDefinition adviceDef = (AdviceDefinition) defs.next();
                ExpressionInfo expressionInfo = adviceDef.getExpressionInfo();
                if (expressionInfo == null) {
                    continue;
                }
                if (adviceDef.getAspectDefinition().getDeploymentModel().equals(DeploymentModel.PER_INSTANCE)
                    && expressionInfo.getAdvisedClassFilterExpression().match(ctx)) {
                    return false;
                }
            }
View Full Code Here

        // 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

        );

        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(),

                        AdviceType.AFTER_FINALLY,
View Full Code Here

                //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),

                                AsmHelper.getArgumentTypes(adviceMethodInfo),

                                adviceDefinition.getType(),

                                adviceDefinition.getSpecialArgumentType(),

                                adviceDefinition.getName(),

                                expressionContext.m_targetWithRuntimeCheck,

                                expressionInfo,

                                expressionContext,

                                adviceDefinition

                        );



                        setMethodArgumentIndexes(expressionInfo, expressionContext, adviceInfo, loader);



                        if (AdviceType.BEFORE.equals(adviceDefinition.getType())) {

                            beforeAdvices.add(adviceInfo);

                        } else if (AdviceType.AROUND.equals(adviceDefinition.getType())) {

                            aroundAdvices.add(adviceInfo);

                        } else if (AdviceType.AFTER_FINALLY.equals(adviceDefinition.getType())) {

                            afterFinallyAdvices.add(adviceInfo);

                        } else if (AdviceType.AFTER_RETURNING.equals(adviceDefinition.getType())) {

                            afterReturningAdvices.add(adviceInfo);

                        } else if (AdviceType.AFTER_THROWING.equals(adviceDefinition.getType())) {

                            afterThrowingAdvices.add(adviceInfo);

                        } else if (AdviceType.AFTER.equals(adviceDefinition.getType())) {

                            afterFinallyAdvices.add(adviceInfo);//special case for "after only"

                        }
View Full Code Here

                                       final AspectDefinition aspectDef) {
        List aroundAnnotations = AsmAnnotations.getAnnotations(AnnotationConstants.AROUND, method);
        for (Iterator iterator = aroundAnnotations.iterator(); iterator.hasNext();) {
            Around aroundAnnotation = (Around) iterator.next();
            if (aroundAnnotation != null) {
                AdviceDefinition adviceDef = DefinitionParserHelper.createAdviceDefinition(
                        getAdviceNameAsInSource(method),
                        AdviceType.AROUND,
                        aroundAnnotation.value(),
                        null,
                        aspectName,
View Full Code Here

TOP

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

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.