Examples of AspectMetaData


Examples of org.codehaus.aspectwerkz.AspectMetaData

    private static void registerSetPointcuts(final String uuid,
                                             final AspectWerkzDefinitionImpl definition) {
        for (Iterator it = definition.getAspectDefinitions().iterator(); it.hasNext();) {
            AspectDefinition aspectDef = (AspectDefinition)it.next();

            AspectMetaData aspectMetaData = SystemLoader.getSystem(uuid).
                    getAspectMetaData(aspectDef.getName());

            List beforeAdvices = aspectDef.getBeforeAdvices();
            for (Iterator it2 = beforeAdvices.iterator(); it2.hasNext();) {
                AdviceDefinition adviceDef = (AdviceDefinition)it2.next();

                SetPointcut pointcut = aspectMetaData.getSetPointcut(
                        adviceDef.getExpression().getExpression()
                );
                if (pointcut == null) {
                    pointcut = new SetPointcut(uuid, adviceDef.getExpression());
                    aspectMetaData.addSetPointcut(pointcut);
                }
                pointcut.addBeforeAdvice(adviceDef.getName());
            }

            List afterAdvices = aspectDef.getAfterAdvices();
            for (Iterator it2 = afterAdvices.iterator(); it2.hasNext();) {
                AdviceDefinition adviceDef = (AdviceDefinition)it2.next();

                SetPointcut pointcut = aspectMetaData.getSetPointcut(
                        adviceDef.getExpression().getExpression()
                );
                if (pointcut == null) {
                    pointcut = new SetPointcut(uuid, adviceDef.getExpression());
                    aspectMetaData.addSetPointcut(pointcut);
                }
                pointcut.addAfterAdvice(adviceDef.getName());
            }
        }
    }
View Full Code Here

Examples of org.codehaus.aspectwerkz.AspectMetaData

    private static void registerGetPointcuts(final String uuid,
                                             final AspectWerkzDefinitionImpl definition) {
        for (Iterator it = definition.getAspectDefinitions().iterator(); it.hasNext();) {
            AspectDefinition aspectDef = (AspectDefinition)it.next();

            AspectMetaData aspectMetaData = SystemLoader.getSystem(uuid).
                    getAspectMetaData(aspectDef.getName());

            List beforeAdvices = aspectDef.getBeforeAdvices();
            for (Iterator it2 = beforeAdvices.iterator(); it2.hasNext();) {
                AdviceDefinition adviceDef = (AdviceDefinition)it2.next();
                GetPointcut pointcut = aspectMetaData.getGetPointcut(
                        adviceDef.getExpression().getExpression()
                );
                if (pointcut == null) {
                    pointcut = new GetPointcut(uuid, adviceDef.getExpression());
                    aspectMetaData.addGetPointcut(pointcut);
                }
                pointcut.addBeforeAdvice(adviceDef.getName());
            }

            List afterAdvices = aspectDef.getAfterAdvices();
            for (Iterator it2 = afterAdvices.iterator(); it2.hasNext();) {
                AdviceDefinition adviceDef = (AdviceDefinition)it2.next();
                GetPointcut pointcut = aspectMetaData.getGetPointcut(
                        adviceDef.getExpression().getExpression()
                );
                if (pointcut == null) {
                    pointcut = new GetPointcut(uuid, adviceDef.getExpression());
                    aspectMetaData.addGetPointcut(pointcut);
                }
                pointcut.addAfterAdvice(adviceDef.getName());
            }
        }
    }
View Full Code Here

Examples of org.codehaus.aspectwerkz.AspectMetaData

                                      final AspectWerkzDefinitionImpl definition) {
        try {
            for (Iterator it = definition.getAspectDefinitions().iterator(); it.hasNext();) {
                AspectDefinition aspectDefinition = (AspectDefinition)it.next();
                ((XmlDefSystem)SystemLoader.getSystem(uuid)).register(
                        new AspectMetaData(uuid, aspectDefinition.getName())
                );
            }
        }
        catch (NullPointerException e) {
            throw new DefinitionException("aspects not properly defined");
View Full Code Here

Examples of org.codehaus.aspectwerkz.AspectMetaData

    private static void registerExecutionPointcuts(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 execution pointcut
                    Expression expression = bindAdviceRule.getExpression();
                    if (!expression.getType().equals(PointcutType.EXECUTION)) {
                        continue;
                    }
                    ExecutionPointcut pointcut = new ExecutionPointcut(uuid, expression);

                    // add advice references
                    List adviceRefs = bindAdviceRule.getAdviceRefs();
                    for (Iterator it3 = adviceRefs.iterator(); it3.hasNext();) {
                        pointcut.addAdvice((String)it3.next());
                    }
                    // 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 method pointcut
                    aspect.addExecutionPointcut(pointcut);
                }
            }
            catch (NullPointerException e) {
                throw new DefinitionException("execution pointcuts in aspect <" + aspect.getName() + "> are not properly defined");
            }
            catch (Exception e) {
                throw new WrappedRuntimeException(e);
            }
        }
View Full Code Here

Examples of org.codehaus.aspectwerkz.AspectMetaData

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

            List beforeAdvices = aspectDef.getBeforeAdvices();
            for (Iterator it2 = beforeAdvices.iterator(); it2.hasNext();) {
                AdviceDefinition adviceDef = (AdviceDefinition)it2.next();

                CallPointcut pointcut = aspectMetaData.getCallPointcut(
                        adviceDef.getExpression().getExpression()
                );
                if (pointcut == null) {
                    pointcut = new CallPointcut(uuid, adviceDef.getExpression());
                    aspectMetaData.addCallPointcut(pointcut);
                }
                pointcut.addBeforeAdvice(adviceDef.getName());
            }

            List afterAdvices = aspectDef.getAfterAdvices();
            for (Iterator it2 = afterAdvices.iterator(); it2.hasNext();) {
                AdviceDefinition adviceDef = (AdviceDefinition)it2.next();

                CallPointcut pointcut = aspectMetaData.getCallPointcut(
                        adviceDef.getExpression().getExpression()
                );
                if (pointcut == null) {
                    pointcut = new CallPointcut(uuid, adviceDef.getExpression());
                    aspectMetaData.addCallPointcut(pointcut);
                }
                pointcut.addAfterAdvice(adviceDef.getName());
            }
        }
    }
View Full Code Here

Examples of org.codehaus.aspectwerkz.AspectMetaData

    private static void registerCallPointcuts(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 call pointcut
                    Expression expression = bindAdviceRule.getExpression();
                    if (!expression.getType().equals(PointcutType.CALL)) {
                        continue;
                    }
                    CallPointcut pointcut = new CallPointcut(uuid, expression);

                    // add before and after advices
                    List adviceRefs = bindAdviceRule.getAdviceRefs();
                    for (Iterator it3 = adviceRefs.iterator(); it3.hasNext();) {
                        String adviceRef = (String)it3.next();
                        if (((XmlDefSystem)SystemLoader.getSystem(uuid)).
                                getAdvice(adviceRef) instanceof PreAdvice) {
                            pointcut.addBeforeAdvice(adviceRef);
                        }
                        else if (((XmlDefSystem)SystemLoader.getSystem(uuid)).
                                getAdvice(adviceRef) instanceof PostAdvice) {
                            pointcut.addAfterAdvice(adviceRef);
                        }
                    }

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

                        adviceRefs = adviceStackDefinition.getAdviceRefs();
                        for (Iterator it4 = adviceRefs.iterator(); it4.hasNext();) {
                            String adviceRef = (String)it4.next();
                            if (((XmlDefSystem)SystemLoader.getSystem(uuid)).
                                    getAdvice(adviceRef) instanceof PreAdvice) {
                                pointcut.addBeforeAdvice(adviceRef);
                            }
                            else if (((XmlDefSystem)SystemLoader.getSystem(uuid)).
                                    getAdvice(adviceRef) instanceof PostAdvice) {
                                pointcut.addAfterAdvice(adviceRef);
                            }
                        }
                    }
                    // add the call pointcut
                    aspect.addCallPointcut(pointcut);
                }
            }
            catch (NullPointerException e) {
                throw new DefinitionException("call pointcuts in aspect <" + aspect.getName() + "> are not properly defined");
            }
            catch (Exception e) {
                throw new WrappedRuntimeException(e);
            }
        }
View Full Code Here

Examples of org.codehaus.aspectwerkz.AspectMetaData

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

            for (Iterator it2 = aspectDef.getAllAdvices().iterator(); it2.hasNext();) {
                AdviceDefinition adviceDef = (AdviceDefinition)it2.next();
                Expression expression = adviceDef.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 =
                                aspectDef.getPointcutDef(value.getName());

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

                        // register the cflow advices in the system and create the cflow system aspect
                        // (if it does not already exist)
                        if (!SystemLoader.getSystem(uuid).hasAspect(CFlowSystemAspect.NAME)) {
                            AspectDefinition cflowAspect = new AspectDefinition(
                                    CFlowSystemAspect.NAME,
                                    CFlowSystemAspect.CLASS_NAME,
                                    CFlowSystemAspect.DEPLOYMENT_MODEL
                            );
                            cflowAspect.addPointcut(cflowPointcutDef);

                            Class cflowAspectClass = CFlowSystemAspect.class;
                            try {
                                // add the cflow pre advice
                                cflowAspect.addBeforeAdvice(new AdviceDefinition(
                                        CFlowSystemAspect.PRE_ADVICE,
                                        cflowAspect.getName(),
                                        cflowAspect.getClassName(),
                                        value,
                                        cflowAspectClass.getDeclaredMethod(
                                                CFlowSystemAspect.PRE_ADVICE,
                                                new Class[]{JoinPoint.class}),
                                        CFlowSystemAspect.PRE_ADVICE_INDEX,
                                        cflowAspect
                                ));

                                // add the cflow post advice
                                cflowAspect.addAfterAdvice(new AdviceDefinition(
                                        CFlowSystemAspect.POST_ADVICE,
                                        cflowAspect.getName(),
                                        cflowAspect.getClassName(),
                                        value,
                                        cflowAspectClass.getDeclaredMethod(
                                                CFlowSystemAspect.POST_ADVICE,
                                                new Class[]{JoinPoint.class}),
                                        CFlowSystemAspect.POST_ADVICE_INDEX,
                                        cflowAspect
                                ));
                            } catch (NoSuchMethodException e) {
                                ;
                            }

                            // add the advice to the aspectwerkz definition
                            definition.addAspect(cflowAspect);

                            // add the advice to the aspectwerkz system
                            registerAspect(uuid, cflowAspect, new HashMap());
                        }

                        // add the pointcut definition to the method pointcut
                        pointcut.addPointcutDef(cflowPointcutDef);

                        // add references to the cflow advices to the cflow pointcut
                        pointcut.addBeforeAdvice(CFlowSystemAspect.PRE_ADVICE);
                        pointcut.addAfterAdvice(CFlowSystemAspect.POST_ADVICE);

                        // add the method pointcut
                        aspect.addCallPointcut(pointcut);



                    //TODO USELESS - does not support NOT IN
                    // impl a visitor
                    aspect.addMethodToCflowExpressionMap(expression, value);
                }
            }
                    //
//
//                    // add a mapping between the cflow pattern and the method patterns affected
View Full Code Here

Examples of org.codehaus.aspectwerkz.AspectMetaData

    private static void registerSetPointcuts(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 set pointcut
                    Expression expression = bindAdviceRule.getExpression();
                    if (!expression.getType().equals(PointcutType.SET)) {
                        continue;
                    }
                    SetPointcut pointcut = new SetPointcut(uuid, expression);

                    // add before and after advices
                    List adviceRefs = bindAdviceRule.getAdviceRefs();
                    for (Iterator it3 = adviceRefs.iterator(); it3.hasNext();) {
                        String adviceRef = (String)it3.next();
                        if (((XmlDefSystem)SystemLoader.getSystem(uuid)).
                                getAdvice(adviceRef) instanceof PreAdvice) {
                            pointcut.addBeforeAdvice(adviceRef);
                        }
                        else if (((XmlDefSystem)SystemLoader.getSystem(uuid)).
                                getAdvice(adviceRef) instanceof PostAdvice) {
                            pointcut.addAfterAdvice(adviceRef);
                        }
                    }

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

                        adviceRefs = adviceStackDefinition.getAdviceRefs();
                        for (Iterator it4 = adviceRefs.iterator(); it4.hasNext();) {
                            String adviceRef = (String)it4.next();
                            if (((XmlDefSystem)SystemLoader.getSystem(uuid)).
                                    getAdvice(adviceRef) instanceof PreAdvice) {
                                pointcut.addBeforeAdvice(adviceRef);
                            }
                            else if (((XmlDefSystem)SystemLoader.getSystem(uuid)).
                                    getAdvice(adviceRef) instanceof PostAdvice) {
                                pointcut.addAfterAdvice(adviceRef);
                            }
                        }
                    }

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

Examples of org.codehaus.aspectwerkz.AspectMetaData

    private static void registerThrowsPointcuts(final String uuid,
                                                final AspectWerkzDefinitionImpl definition) {
        for (Iterator it = definition.getAspectDefinitions().iterator(); it.hasNext();) {
            AspectDefinition aspectDef = (AspectDefinition)it.next();

            AspectMetaData aspectMetaData = SystemLoader.getSystem(uuid).getAspectMetaData(aspectDef.getName());

            List aroundAdvices = aspectDef.getAroundAdvices();
            for (Iterator it2 = aroundAdvices.iterator(); it2.hasNext();) {
                AdviceDefinition adviceDef = (AdviceDefinition)it2.next();

                if (adviceDef.getExpression().getType().equals(PointcutType.THROWS)) {
                    ThrowsPointcut pointcut = aspectMetaData.getThrowsPointcut(
                            adviceDef.getExpression().getExpression()
                    );
                    if (pointcut == null) {
                        pointcut = new ThrowsPointcut(uuid, adviceDef.getExpression());
                        aspectMetaData.addThrowsPointcut(pointcut);
                    }
                    pointcut.addAdvice(adviceDef.getName());
                }
            }
        }
View Full Code Here

Examples of org.springframework.aop.aspectj.annotation.AspectMetadata

    adrian1.setAge(explicitlySetAge);

    assertEquals("Setter does not initiate advice", explicitlySetAge, adrian1.getAge());
    // Fire aspect

    AspectMetadata am = new AspectMetadata(AbstractAspectJAdvisorFactoryTests.PerTargetAspect.class, "someBean");
    assertTrue(am.getPerClausePointcut().getMethodMatcher().matches(TestBean.class.getMethod("getSpouse"), null));

    adrian1.getSpouse();

    assertEquals("Advice has now been instantiated", 0, adrian1.getAge());
    adrian1.setAge(11);
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.