Package org.codehaus.aspectwerkz

Examples of org.codehaus.aspectwerkz.AspectMetaData


    private static void registerThrowsPointcuts(final String uuid,
                                                final AspectWerkzDefinitionImpl definition) {
        // get all aspects definitions
        for (Iterator it1 = definition.getAspectDefinitions().iterator(); it1.hasNext();) {
            AspectDefinition aspectDefinition = (AspectDefinition)it1.next();
            AspectMetaData aspect = SystemLoader.getSystem(uuid).
                    getAspectMetaData(aspectDefinition.getName());

            try {
                // get all bind-advice rules defined in this aspect
                List bindAdviceRules = aspectDefinition.getBindAdviceRules();
                for (Iterator it2 = bindAdviceRules.iterator(); it2.hasNext();) {
                    BindAdviceRule bindAdviceRule = (BindAdviceRule)it2.next();

                    // create throws pointcut
                    Expression expression = bindAdviceRule.getExpression();
                    if (!expression.getType().equals(PointcutType.THROWS)) {
                        continue;
                    }
                    ThrowsPointcut pointcut = new ThrowsPointcut(uuid, expression);

                    // add advices
                    List adviceRefs = bindAdviceRule.getAdviceRefs();
                    for (Iterator it3 = adviceRefs.iterator(); it3.hasNext();) {
                        String asdf = (String)it3.next();
                        pointcut.addAdvice(asdf);
                    }

                    // add advices from advice stacks
                    List adviceStackRefs = bindAdviceRule.getAdviceStackRefs();
                    for (Iterator it3 = adviceStackRefs.iterator(); it3.hasNext();) {
                        AdviceStackDefinition adviceStackDefinition =
                                definition.getAdviceStackDefinition((String)it3.next());

                        List advices = adviceStackDefinition.getAdviceRefs();
                        for (Iterator it4 = advices.iterator(); it4.hasNext();) {
                            pointcut.addAdvice((String)it4.next());
                        }
                    }

                    // add the throws pointcut
                    aspect.addThrowsPointcut(pointcut);
                }
            }
            catch (NullPointerException e) {
                throw new DefinitionException("throws pointcuts in aspect <" + aspect.getName() + "> are not properly defined");
            }
            catch (Exception e) {
                throw new WrappedRuntimeException(e);
            }
        }
View Full Code Here


    private static void registerCFlowPointcuts(final String uuid,
                                               final AspectWerkzDefinitionImpl definition) {
        // get all aspects definitions
        for (Iterator it1 = definition.getAspectDefinitions().iterator(); it1.hasNext();) {
            AspectDefinition aspectDefinition = (AspectDefinition)it1.next();
            AspectMetaData aspect = SystemLoader.getSystem(uuid).
                    getAspectMetaData(aspectDefinition.getName());

            // get all bind-advice rules defined in this aspect
            List bindAdviceRules = aspectDefinition.getBindAdviceRules();
            for (Iterator it2 = bindAdviceRules.iterator(); it2.hasNext();) {
                BindAdviceRule bindAdviceRule = (BindAdviceRule)it2.next();

                Expression expression = bindAdviceRule.getExpression();
                for (Iterator it3 = expression.getCflowExpressions().entrySet().iterator(); it3.hasNext();) {
                    Map.Entry entry = (Map.Entry) it3.next();
                    Expression value = (Expression) entry.getValue();
                    if (value instanceof ExpressionExpression) {
                        // recursive
                        //TODO exprexpr using exprexpr
                        // like pc cflow = "a or b"
                        // .. pc exec = "c IN cflow"
                        (new Exception("todo")).printStackTrace();
                    } else {
                        // get the referenced cflow poincut definition
                        PointcutDefinition cflowPointcutDef =
                                aspectDefinition.getPointcutDef(value.getName());

                        // create call pointcut
                        CallPointcut pointcut = new CallPointcut(uuid, value);

                        // register the cflow advices in the system (if they does not already exist)
                        //TODO: [alex] clean this - works as well when commented.
                        if (!SystemLoader.getSystem(uuid).hasAspect(CFlowPreAdvice.NAME)) {
                            AdviceDefinition adviceDef = CFlowPreAdvice.getDefinition();
                            // add the advice to the aspectwerkz definition
                            definition.addAdvice(adviceDef);
                            // add the advice to the aspectwerkz system
                            registerAdvice(uuid, adviceDef);
                        }
                        if (!SystemLoader.getSystem(uuid).hasAspect(CFlowPostAdvice.NAME)) {
                            AdviceDefinition adviceDef = CFlowPostAdvice.getDefinition();
                            // add the advice to the aspectwerkz definition
                            definition.addAdvice(adviceDef);
                            // add the advice to the aspectwerkz system
                            registerAdvice(uuid, adviceDef);
                        }

                        // add the pointcut definition to the method pointcut
                        pointcut.addPointcutDef(cflowPointcutDef);
                        // add references to the cflow advices to the cflow pointcut
                        pointcut.addBeforeAdvice(CFlowPreAdvice.NAME);
                        pointcut.addAfterAdvice(CFlowPostAdvice.NAME);
                        // add the method pointcut
                        aspect.addCallPointcut(pointcut);

                        //TODO USELESS - does not support NOT IN
                        // impl a visitor
                        aspect.addMethodToCflowExpressionMap(expression, value);
                    }
                }
//                //expression.
//                Expression cflowExpression = bindAdviceRule.getCflowExpression();
//                if ( cflowExpression == null ) {
View Full Code Here

            return (List)m_callPointcutCache.get(hashKey);
        }

        List pointcuts = new ArrayList();
        for (Iterator it = m_aspects.values().iterator(); it.hasNext();) {
            AspectMetaData aspect = (AspectMetaData)it.next();
            pointcuts.addAll(aspect.getCallPointcuts(classMetaData, methodMetaData));
        }

        synchronized (m_callPointcutCache) {
            m_callPointcutCache.put(hashKey, pointcuts);
        }
View Full Code Here

            return (List)m_cflowPointcutCache.get(hashKey);
        }

        List pointcuts = new ArrayList();
        for (Iterator it = m_aspects.values().iterator(); it.hasNext();) {
            AspectMetaData aspect = (AspectMetaData)it.next();
            pointcuts.addAll(aspect.getCFlowExpressions(classMetaData, methodMetaData));
        }

        synchronized (m_cflowPointcutCache) {
            m_cflowPointcutCache.put(hashKey, pointcuts);
        }
View Full Code Here

        assertEquals(DeploymentModel.PER_CLASS, ((XmlDefSystem)SystemLoader.getSystem("tests")).getAdvice("methodAdvice1").getDeploymentModel());
    }

    public void testRegisterAspect() {
        ((XmlDefSystem)SystemLoader.getSystem("tests")).register(
                new AspectMetaData("tests", getClass().getName(), DeploymentModel.PER_JVM)
        );
        Collection aspects = SystemLoader.getSystem("tests").getAspectsMetaData();
        for (Iterator it = aspects.iterator(); it.hasNext();) {
            AspectMetaData aspect = (AspectMetaData)it.next();
            if (aspect.getName().equals(getClass().getName())) {
                return;
            }
        }
        fail();
    }
View Full Code Here

        }

        boolean hasThrowsPointcut = false;
        Collection aspects = m_system.getAspectsMetaData();
        for (Iterator it = aspects.iterator(); it.hasNext();) {
            AspectMetaData aspect = (AspectMetaData)it.next();
            if (aspect.hasThrowsPointcut(
                    m_classMetaData,
                    m_methodMetaData,
                    cause.getClass().getName())) {
                hasThrowsPointcut = true;
                break;
View Full Code Here

TOP

Related Classes of org.codehaus.aspectwerkz.AspectMetaData

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.