Examples of AspectDefinition


Examples of org.codehaus.aspectwerkz.attribdef.definition.AspectDefinition

     */
    public Collection getAdviceDefinitions() {
        if (!m_aspectsLoaded) throw new IllegalStateException("aspects are not loaded");
        final Collection adviceDefs = new ArrayList();
        for (Iterator it = m_aspectMap.values().iterator(); it.hasNext();) {
            AspectDefinition aspectDef = (AspectDefinition)it.next();
            adviceDefs.addAll(aspectDef.getAroundAdvices());
            adviceDefs.addAll(aspectDef.getBeforeAdvices());
            adviceDefs.addAll(aspectDef.getAfterAdvices());
        }
        return adviceDefs;
    }
View Full Code Here

Examples of org.codehaus.aspectwerkz.definition.AspectDefinition

     * Creates a new aspect container.
     *
     * @param aspectClass the aspect class
     */
    private static AspectContainer createAspectContainer(final Class aspectClass) {
        AspectDefinition aspectDefinition = null;

        Set definitions = SystemDefinitionContainer.getDefinitionsFor(aspectClass.getClassLoader());
        for (Iterator iterator = definitions.iterator(); iterator.hasNext() && aspectDefinition == null;) {
            SystemDefinition systemDefinition = (SystemDefinition) iterator.next();
            for (Iterator iterator1 = systemDefinition.getAspectDefinitions().iterator(); iterator1.hasNext();) {
                AspectDefinition aspectDef = (AspectDefinition) iterator1.next();
                if (aspectClass.getName().replace('/', '.').equals(aspectDef.getClassName())) {
                    aspectDefinition = aspectDef;
                    break;
                }
            }
        }
View Full Code Here

Examples of org.codehaus.aspectwerkz.definition.AspectDefinition

        //Collections.reverse(definitionsBottomUp);

        for (Iterator iterator = definitionsBottomUp.iterator(); iterator.hasNext();) {
            SystemDefinition definition = (SystemDefinition) iterator.next();
            for (Iterator iterator1 = definition.getAspectDefinitions().iterator(); iterator1.hasNext();) {
                AspectDefinition aspectDefinition = (AspectDefinition) iterator1.next();
                if (qualifiedName.equals(aspectDefinition.getQualifiedName())) {
                    return aspectDefinition.getClassName();
                }
            }
        }
        return null;
    }
View Full Code Here

Examples of org.codehaus.aspectwerkz.definition.AspectDefinition

        // TODO: how to do this class define lazyly and not pass in a classloader ?
        // could be done in the JIT jp clinit when 1+ advice has a cflow binding
        Class aspectClass = CflowCompiler.compileCflowAspectAndAttachToClassLoader(loader, m_cflowID);
        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(),
                        AdviceType.AFTER_FINALLY,
                        null,
                        aspectName,
View Full Code Here

Examples of org.codehaus.aspectwerkz.definition.AspectDefinition

        SystemDefinition sysDef = DefinitionLoader.getDefinition(HotSwapTarget.class

                .getClassLoader(), "hotdeployed");

        AspectDefinition aspectDef = sysDef.getAspectDefinition(aspectName);

        ExpressionNamespace namespace = ExpressionNamespace.getNamespace(aspectDef

                .getFullQualifiedName());

        ExpressionInfo expressionInfo = new ExpressionInfo(pointcut, aspectDef

                .getFullQualifiedName());

        namespace.addExpressionInfo(pointcutName, expressionInfo);

        AdviceDefinition newDef = null;

        for (Iterator arounds = aspectDef.getAroundAdvices().iterator(); arounds.hasNext();) {

            AdviceDefinition around = (AdviceDefinition) arounds.next();

            if (around.getName().equals(aspectName + ".logMethod")) {

                // copy the logMethod advice

                // note: we could add a totally new advice as well

                newDef = around.copyAt(expressionInfo);

                break;

            }

        }

        aspectDef.addAroundAdvice(newDef);



        //TODO: experimental API
View Full Code Here

Examples of org.codehaus.aspectwerkz.definition.AspectDefinition

        SystemDefinition sysDef = DefinitionLoader.getDefinition(HotSwapTarget.class

                .getClassLoader(), "hotdeployed");

        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.getExpressionInfo().getExpressionAsString())) {

                System.out.println("<removing> " + around.getName() + " at " + pointcutName);

                removedAdviceDefs.add(around);

            } else {

                //System.out.println("around = " + around.getExpression().getName());

            }

        }

        for (Iterator arounds = removedAdviceDefs.iterator(); arounds.hasNext();) {

            aspectDef.removeAroundAdvice((AdviceDefinition) arounds.next());

        }

        //TODO remove from PointcutManager as well for mem safety ?
View Full Code Here

Examples of org.codehaus.aspectwerkz.definition.AspectDefinition

        for (Iterator iterator = systemDefinitions.iterator(); iterator.hasNext();) {
            SystemDefinition systemDefinition = (SystemDefinition) iterator.next();
            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),
                                AsmHelper.getArgumentTypes(adviceMethodInfo),
                                adviceDefinition.getType(),
                                adviceDefinition.getSpecialArgumentType(),
View Full Code Here

Examples of org.codehaus.aspectwerkz.definition.AspectDefinition

            }
        }

        // 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();
                    final String[] classNames = new String[interfaces.length + 1];
                    classNames[0] = superClassName;
                    for (int j = 1; j < interfaces.length + 1; j++) {
View Full Code Here

Examples of org.codehaus.aspectwerkz.definition.AspectDefinition

            msg.append(e.toString());
            throw new RuntimeException(msg.toString());
        }

        // create the aspect definition
        AspectDefinition aspectDef = new AspectDefinition(aspectClassName, aspectClassName, m_definition.getUuid());
        aspectDef.setDeploymentModel(DeploymentModel.getDeploymentModelAsString(deploymentModel));

        // parse the class attributes and create a definition
        m_annotationParser.parse(aspectClass, aspectDef, m_definition);
        m_definition.addAspect(aspectDef);
        CrossCuttingInfo crossCuttingInfo = new CrossCuttingInfo(
            null,
            aspectClass,
            aspectDef.getName(),
            deploymentModel,
            aspectDef,
            new HashMap());
        AspectContainer container = StartupManager.createAspectContainer(crossCuttingInfo);
        crossCuttingInfo.setContainer(container);
View Full Code Here

Examples of org.codehaus.aspectwerkz.definition.AspectDefinition

        final ClassInfo aspectClassInfo = JavaClassInfo.getClassInfo(aspectClass);

        // create a new aspect def and fill it up with the annotation def from the aspect class
        final SystemDefinition systemDef = SystemDefinitionContainer.getVirtualDefinitionAt(deployLoader);
        final AspectDefinition newAspectDef = new AspectDefinition(className, aspectClassInfo, systemDef);
        final Set newExpressions = getNewExpressionsForAspect(
                aspectClass, newAspectDef, systemDef, deploymentScope, deploymentHandle
        );

        redefine(newExpressions);
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.