Package org.codehaus.aspectwerkz.definition

Examples of org.codehaus.aspectwerkz.definition.PointcutDefinition


            final AspectWerkzDefinition aspectwerkz = XmlDefinitionParser.parseNoCache(m_input.toURL());
            Iterator itl = aspectwerkz.getAspectDefinitions().iterator();
            itl.next(); // SystemAspect @todo validate with Jonas (side effect of precedence fix)
            Iterator it = ((AspectDefinition)itl.next()).getPointcutDefs().iterator();
            it.next();//skip "start"
            PointcutDefinition pointcut2 = (PointcutDefinition)it.next();
            assertEquals("method", pointcut2.getType());
            assertEquals("stop", pointcut2.getName());
            assertEquals("services.*", pointcut2.getClassPattern());
            assertEquals("* stop(..)", pointcut2.getPattern());
            // absract aspect pointcut are added thereafter
            // @todo review precedence
            it.next();//skip "callerSideTest"
            PointcutDefinition pointcut1 = (PointcutDefinition)it.next();
            assertEquals("setField", pointcut1.getType());
            assertEquals("setFieldTest", pointcut1.getName());
            assertEquals("services.*", pointcut1.getClassPattern());
            assertEquals("boolean m_isRunning", pointcut1.getPattern());
        }
        catch (Exception e) {
            System.out.println(e);
            fail();
        }
View Full Code Here


                // get the user defined name for the cflow pointcut
                String name = attributes[0];

                // create and add a new pointcut def
                PointcutDefinition pointcutDef = new PointcutDefinition();
                pointcutDef.setName(name);
                pointcutDef.setExpression(createCallerSidePattern("*", className, javaMethods[i]));
                pointcutDef.setType(PointcutType.CFLOW);
                aspectDef.addPointcutDef(pointcutDef);

                ExpressionNamespace.getExpressionNamespace(aspectDef.getName())
                        .registerExpression(
                        pointcutDef.getExpression(), "", name, PointcutType.CFLOW
                );

                break;
            }
        }
View Full Code Here

                        // 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);
View Full Code Here

                        // 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);
View Full Code Here

     * @param pointcutName the pointcut name
     * @return the pointcut definition
     */
    public PointcutDefinition getPointcutDef(final String pointcutName) {
        for (Iterator it = m_pointcutDefs.iterator(); it.hasNext();) {
            PointcutDefinition pointcutDef = (PointcutDefinition)it.next();
            if (pointcutDef.getName().equals(pointcutName)) {
                return pointcutDef;
            }
        }
        return null;
    }
View Full Code Here

     * Validates pointcut definitions
     * @param pointcutDefs a Collection of PointcutDefinitions
     */
    private void validatePointcuts(Collection pointcutDefs) {
        for (Iterator i = pointcutDefs.iterator(); i.hasNext();) {
            PointcutDefinition def = (PointcutDefinition)i.next();
            validateSyntax(def.getName(), "pointcut");
        }
    }
View Full Code Here

            final AspectWerkzDefinition aspectwerkz = (AspectWerkzDefinition)XmlParser.parseNoCache(m_input.toURL()).get(0);
            Iterator itl = aspectwerkz.getAspectDefinitions().iterator();
            itl.next(); // SystemAspect @todo validate with Jonas (side effect of precedence fix)
            Iterator it = ((AspectDefinition)itl.next()).getPointcutDefs().iterator();
            it.next();//skip "start"
            PointcutDefinition pointcut2 = (PointcutDefinition)it.next();
            assertEquals("method", pointcut2.getType());
            assertEquals("stop", pointcut2.getName());
            assertEquals("* services.*.stop(..)", pointcut2.getExpression());
            // absract aspect pointcut are added thereafter
            // @todo review precedence
            it.next();//skip "callerSideTest"
            PointcutDefinition pointcut1 = (PointcutDefinition)it.next();
            assertEquals("setField", pointcut1.getType());
            assertEquals("setFieldTest", pointcut1.getName());
            assertEquals("boolean services.*.m_isRunning", pointcut1.getExpression());
        }
        catch (Exception e) {
            System.out.println(e);
            fail();
        }
View Full Code Here

     * @param aspectDef the aspect definition
     */
    private static void handlePointcutDefinitions(final Element aspectElement,
                                                  final AspectDefinition aspectDef) {
        for (Iterator it2 = aspectDef.getPointcutDefs().iterator(); it2.hasNext();) {
            PointcutDefinition pointcutDef = (PointcutDefinition)it2.next();

            Element pointcutDefElement = aspectElement.addElement("pointcut-def");
            pointcutDefElement.addAttribute("name", pointcutDef.getName());
            // TODO remove all non-reentrant things
            //pointcutDefElement.addAttribute("non-reentrant", pointcutDef.getNonReentrant());

            PointcutType pointcutType = pointcutDef.getType();
            if (pointcutType.equals(PointcutType.EXECUTION)) {
                pointcutDefElement.addAttribute("type", "method");
            }
            else if (pointcutType.equals(PointcutType.CALL)) {
                pointcutDefElement.addAttribute("type", "callerSide");
            }
            else if (pointcutType.equals(PointcutType.GET)) {
                pointcutDefElement.addAttribute("type", "getField");
            }
            else if (pointcutType.equals(PointcutType.SET)) {
                pointcutDefElement.addAttribute("type", "setField");
            }
            else if (pointcutType.equals(PointcutType.CFLOW)) {
                pointcutDefElement.addAttribute("type", "cflow");
            }
            else if (pointcutType.equals(PointcutType.THROWS)) {
                pointcutDefElement.addAttribute("type", "throws");
            }
            else if (pointcutType.equals(PointcutType.CLASS)) {
                pointcutDefElement.addAttribute("type", "class");
            }
            else {
                throw new ExpressionException("pointcut type not supported: " + pointcutType);
            }

            pointcutDefElement.addAttribute("pattern", pointcutDef.getExpression());
        }
    }
View Full Code Here

                    String attribute = attributes[k];

                    String expression = pointcutName + counter;

                    // create and add a new pointcut definition
                    PointcutDefinition pointcutDef = new PointcutDefinition();
                    pointcutDef.setName(pointcutName);
                    pointcutDef.setExpression(expression);
                    pointcutDef.setType(PointcutType.EXECUTION);
                    definition.getAspectDefinition(AspectWerkzDefinition.SYSTEM_ASPECT).
                            addPointcutDef(pointcutDef);

                    // create a new controller definition
                    ControllerDefinition controllerDef = new ControllerDefinition();
View Full Code Here

                    for (Iterator it2 = definition.getAdviceDefinitions().iterator(); it2.hasNext();) {
                        String expression = pointcutName + counter;

                        // create and add a new pointcut def
                        PointcutDefinition pointcutDef = new PointcutDefinition();
                        pointcutDef.setName(expression);
                        pointcutDef.setExpression(createExecutionPattern(className, javaMethods[i]));
                        pointcutDef.setType(PointcutType.EXECUTION);
                        pointcutDef.setNonReentrant(isNonReentrant);
                        aspectDef.addPointcutDef(pointcutDef);

                        ExpressionNamespace.getExpressionNamespace(aspectDef.getName())
                            .registerExpression(pointcutDef.getExpression(), "", expression, PointcutType.EXECUTION);

                        String adviceAttribute = ((AdviceDefinition)it2.next()).getAttribute();
                        if (adviceAttribute == null) {
                            continue;
                        }
View Full Code Here

TOP

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

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.