Package org.codehaus.aspectwerkz.definition

Examples of org.codehaus.aspectwerkz.definition.AspectDefinition


     */
    private static void removePointcutForLoggingAdvice(String pointcut, String pointcutName) {
        final String aspectName = "examples.logging.LoggingAspect";

        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());
        }
        //TODO remove from PointcutManager as well for mem safety ?
    }
View Full Code Here


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

        // create the aspect definition
        AspectDefinition aspectDef = new AspectDefinition(
                aspectClassName,
                aspectClassName,
                DeploymentModel.getDeploymentModelAsString(deploymentModel)
        );
View Full Code Here

        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(),
                                DeploymentModel.getDeploymentModelAsInt(aspectDefinition.getDeploymentModel()),
                                adviceMethodInfo.getName(),
                                AsmHelper.getMethodDescriptor(adviceMethodInfo),
                                AsmHelper.getArgumentTypes(adviceMethodInfo),
                                adviceDefinition.getType(),
                                adviceDefinition.getSpecialArgumentType(),
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++) {
//                System.out.println("--------> parameter = " + adviceArgTypes[i].getInternalName());

                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

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

        Set definitions = SystemDefinitionContainer.getRegularAndVirtualDefinitionsFor(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

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

    public static void addPointcutForLoggingAdvice(String pointcut, String pointcutName) {
        //if (true) return;

        final String aspectName = "examples.logging.JavaLoggingAspect";
        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
        StartupManager.reinitializeSystem(HotSwapTarget.class.getClassLoader(), sysDef);
        System.out.println("sysDef = " + sysDef.getClass().getClassLoader());
View Full Code Here

    public static void removePointcutForLoggingAdvice(String pointcut, String pointcutName) {
        //if (true) return;

        final String aspectName = "examples.logging.JavaLoggingAspect";
        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

            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
        AspectAnnotationParser.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

        //if (true) return;

        final String aspectName = "examples.logging.JavaLoggingAspect";
        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
        StartupManager.reinitializeSystem(HotSwapTarget.class.getClassLoader(), sysDef);
        System.out.println("sysDef = " + sysDef.getClass().getClassLoader());
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.