Package org.codehaus.aspectwerkz.definition

Examples of org.codehaus.aspectwerkz.definition.PointcutDefinition


                                              final String packageName) {
        for (Iterator it2 = aspect.elementIterator(); it2.hasNext();) {
            final Element nestedAdviceElement = (Element)it2.next();
            if (nestedAdviceElement.getName().trim().equals("pointcut-def")) {
                try {
                    final PointcutDefinition pointcutDef = new PointcutDefinition();

                    for (Iterator it3 = nestedAdviceElement.attributeIterator(); it3.hasNext();) {
                        Attribute attribute = (Attribute)it3.next();
                        final String name = attribute.getName().trim();
                        final String value = attribute.getValue().trim();
                        if (name.equals("name")) {
                            pointcutDef.setName(value);
                        }
                        else if (name.equals("type")) {
                            PointcutType type = null;
                            if (value.equalsIgnoreCase(METHOD)) {
                                type = PointcutType.EXECUTION;
                                String expression = nestedAdviceElement.attributeValue("pattern");
                                pointcutDef.setExpression(PatternFactory.createMethodPattern(
                                        expression, packageName
                                ));
                            }
                            else if (value.equalsIgnoreCase(CFLOW)) {
                                type = PointcutType.CFLOW;
                            }
                            else if (value.equalsIgnoreCase(SET_FIELD)) {
                                type = PointcutType.SET;
                            }
                            else if (value.equalsIgnoreCase(GET_FIELD)) {
                                type = PointcutType.GET;
                            }
                            else if (value.equalsIgnoreCase(THROWS)) {
                                type = PointcutType.THROWS;
                            }
                            else if (value.equalsIgnoreCase(CALLER_SIDE)) {
                                type = PointcutType.CALL;
                            }
                            else if (value.equalsIgnoreCase(CLASS)) {
                                type = PointcutType.CLASS;
                            }
                            pointcutDef.setType(type);
                        }
                        else if (name.equals("non-reentrant")) {
                            pointcutDef.setNonReentrant(value);
                        }
                    }
                    aspectDef.addPointcutDef(pointcutDef);
                }
                catch (Exception e) {
View Full Code Here


     */
    protected void createAndAddPointcutDefToAspectDef(final String name,
                                                      final PointcutType type,
                                                      final String expression,
                                                      final AspectDefinition aspectDef) {
        PointcutDefinition pointcutDef = new PointcutDefinition();
        pointcutDef.setName(name);
        pointcutDef.setType(type);
        pointcutDef.setExpression(expression);
        aspectDef.addPointcut(pointcutDef);

        // create and add a new expression template
        ExpressionTemplate expressionTemplate = Expression.createExpressionTemplate(
                aspectDef.getName(), expression, "", name, type
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(expression);
                    pointcutDef.setClassPattern(className);
                    pointcutDef.setPattern(createMethodPattern(javaMethods[i]));
                    pointcutDef.setType(PointcutDefinition.METHOD);
                    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.setClassPattern(className);
                        pointcutDef.setPattern(createMethodPattern(javaMethods[i]));
                        pointcutDef.setType(PointcutDefinition.METHOD);
                        pointcutDef.setNonReentrant(isNonReentrant);
                        definition.getAspectDefinition(AspectWerkzDefinition.SYSTEM_ASPECT).
                                addPointcutDef(pointcutDef);

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

                    String attribute = setFieldAttributes[k];
                    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.setClassPattern(className);
                        pointcutDef.setPattern(createFieldPattern(javaFields[i]));
                        pointcutDef.setType(PointcutDefinition.SET_FIELD);
                        definition.getAspectDefinition(AspectWerkzDefinition.SYSTEM_ASPECT).
                                addPointcutDef(pointcutDef);

                        String adviceAttribute = ((AdviceDefinition)it2.next()).getAttribute();
                        if (adviceAttribute == null) {
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.setClassPattern(className);
                        pointcutDef.setPattern(createFieldPattern(javaFields[i]));
                        pointcutDef.setType(PointcutDefinition.GET_FIELD);
                        definition.getAspectDefinition(AspectWerkzDefinition.SYSTEM_ASPECT).
                                addPointcutDef(pointcutDef);

                        String adviceAttribute = ((AdviceDefinition)it2.next()).getAttribute();
                        if (adviceAttribute == null) {
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.setClassPattern(className);
                        pointcutDef.setPattern(createThrowsPattern(
                                exceptionClassPattern, javaMethods[i]));
                        pointcutDef.setType(PointcutDefinition.THROWS);
                        definition.getAspectDefinition(AspectWerkzDefinition.SYSTEM_ASPECT).
                                addPointcutDef(pointcutDef);

                        String adviceAttribute = ((AdviceDefinition)it2.next()).getAttribute();
                        if (adviceAttribute == null) {
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.setClassPattern(callerClassPattern);
                        pointcutDef.setPattern(createCallerSidePattern(className, javaMethods[i]));
                        pointcutDef.setType(PointcutDefinition.CALLER_SIDE);
                        definition.getAspectDefinition(AspectWerkzDefinition.SYSTEM_ASPECT).
                                addPointcutDef(pointcutDef);

                        String adviceAttribute = ((AdviceDefinition)it2.next()).getAttribute();
                        if (adviceAttribute == null) {
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.setClassPattern("*");
                String callerSidePattern = createCallerSidePattern(className, javaMethods[i]);
                pointcutDef.setPattern(callerSidePattern);
                pointcutDef.setType(PointcutDefinition.CFLOW);

                definition.getAspectDefinition(AspectWerkzDefinition.SYSTEM_ASPECT).
                        addPointcutDef(pointcutDef);

                // create and add a new weaving rule def
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());
            pointcutDefElement.addAttribute("type", pointcutDef.getType());
            pointcutDefElement.addAttribute("non-reentrant", pointcutDef.getNonReentrant());

            StringBuffer fullPattern = new StringBuffer();
            String type = pointcutDef.getType();
            if (type.equalsIgnoreCase(PointcutDefinition.METHOD) ||
                    type.equalsIgnoreCase(PointcutDefinition.GET_FIELD) ||
                    type.equalsIgnoreCase(PointcutDefinition.SET_FIELD)) {
                String classPattern = pointcutDef.getClassPattern();
                String pattern = pointcutDef.getPattern();
                int space = pattern.indexOf(' ');
                String returnType = pattern.substring(0, space + 1);
                String methodName = pattern.substring(space + 1);
                fullPattern.append(returnType);
                fullPattern.append(classPattern);
                if (pointcutDef.isHierarchical()) {
                    fullPattern.append('+');
                }
                fullPattern.append('.');
                fullPattern.append(methodName);
            }
            else if (type.equalsIgnoreCase(PointcutDefinition.THROWS)) {
                String classPattern = pointcutDef.getClassPattern();
                String pattern = pointcutDef.getPattern();
                int delimiter = pattern.indexOf('#');
                String methodPattern = pattern.substring(0, delimiter);
                String exception = pattern.substring(delimiter + 1);
                int space = methodPattern.indexOf(' ');
                String returnType = methodPattern.substring(0, space + 1);
                String methodName = methodPattern.substring(space + 1);
                fullPattern.append(returnType);
                fullPattern.append(classPattern);
                fullPattern.append('.');
                fullPattern.append(methodName);
                fullPattern.append('#');
                fullPattern.append(exception);
            }
            else if (type.equalsIgnoreCase(PointcutDefinition.CALLER_SIDE)) {
                String callerClassPattern = pointcutDef.getClassPattern();
                String pattern = pointcutDef.getPattern();
                int delimiter = pattern.indexOf('#');
                String calleeClassPattern = pattern.substring(0, delimiter);
                String methodPattern = pattern.substring(delimiter + 1);
                int space = methodPattern.indexOf(' ');
                String returnType = methodPattern.substring(0, space + 1);
                String methodName = methodPattern.substring(space + 1);
                fullPattern.append(callerClassPattern);
                fullPattern.append("->");
                fullPattern.append(returnType);
                fullPattern.append(calleeClassPattern);
                fullPattern.append(".");
                fullPattern.append(methodName);
                ;
            }
            else if (type.equals(PointcutDefinition.CFLOW)) {
                String pattern = pointcutDef.getPattern();
                int delimiter = pattern.indexOf('#');
                String classPattern = pattern.substring(0, delimiter);
                String methodPattern = pattern.substring(delimiter + 1);
                int space = methodPattern.indexOf(' ');
                String returnType = methodPattern.substring(0, space + 1);
                String methodName = methodPattern.substring(space + 1);
                fullPattern.append(returnType);
                fullPattern.append(classPattern);
                fullPattern.append(".");
                fullPattern.append(methodName);
            }
            else {
                throw new RuntimeException("invalid pointcut type: " + pointcutDef.getType());
            }

            pointcutDefElement.addAttribute("pattern", fullPattern.toString());
        }
    }
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.