Package org.codehaus.aspectwerkz.expression

Examples of org.codehaus.aspectwerkz.expression.ExpressionInfo


            NAMESPACE).getExpression().match(new ExpressionContext(PointcutType.CALL, modifier1, null)));
    }

    public void testGrammar() throws Throwable {
        // test parsing
        new ExpressionInfo("args(..)", NAMESPACE);
        new ExpressionInfo("args(foo, java, String[], foo, ..)", NAMESPACE);
        new ExpressionInfo("args(foo, String+)", NAMESPACE);
        new ExpressionInfo("args(.., String+)", NAMESPACE);
        new ExpressionInfo("args(java.lang.String, ..)", NAMESPACE);
        new ExpressionInfo("args(.., String+, ..)", NAMESPACE); // TODO this syntax is a bit dangerous
    }
View Full Code Here


        new ExpressionInfo("args(.., String+, ..)", NAMESPACE); // TODO this syntax is a bit dangerous
    }

    // ============ args() test =============
    public void testMethodArgs1() throws Exception {
        assertTrue(new ExpressionInfo("call(void test.expression.Target.parameters1(..)) && args(..)", NAMESPACE)
                .getExpression().match(new ExpressionContext(PointcutType.CALL, parameters1, null)));
        assertTrue(new ExpressionInfo("call(void test.expression.Target.parameters1(..)) && args()", NAMESPACE)
                .getExpression().match(new ExpressionContext(PointcutType.CALL, parameters1, null)));
        assertFalse(new ExpressionInfo("call(void test.expression.Target.parameters1(..)) && args(int)", NAMESPACE)
                .getExpression().match(new ExpressionContext(PointcutType.CALL, parameters1, null)));
        assertFalse(new ExpressionInfo(
            "execution(void test.expression.Target.parameters1(..)) && args(.., int)",
            NAMESPACE).getExpression().match(new ExpressionContext(PointcutType.CALL, parameters1, null)));
        assertFalse(new ExpressionInfo(
            "execution(void test.expression.Target.parameters1(..)) && args(.., int)",
            NAMESPACE).getExpression().match(new ExpressionContext(PointcutType.CALL, parameters1, null)));
    }
View Full Code Here

            "execution(void test.expression.Target.parameters1(..)) && args(.., int)",
            NAMESPACE).getExpression().match(new ExpressionContext(PointcutType.CALL, parameters1, null)));
    }

    public void testMethodArgs2() throws Exception {
        assertTrue(new ExpressionInfo("call(void test.expression.Target.parameters2(..)) && args(..)", NAMESPACE)
                .getExpression().match(new ExpressionContext(PointcutType.CALL, parameters2, null)));
        assertFalse(new ExpressionInfo("call(void test.expression.Target.parameters2(..)) && args()", NAMESPACE)
                .getExpression().match(new ExpressionContext(PointcutType.CALL, parameters2, null)));
        assertFalse(new ExpressionInfo("call(void test.expression.Target.parameters2(..)) && args(int)", NAMESPACE)
                .getExpression().match(new ExpressionContext(PointcutType.CALL, parameters2, null)));
        assertTrue(new ExpressionInfo(
            "call(void test.expression.Target.parameters2(..)) && args(int, float, byte)",
            NAMESPACE).getExpression().match(new ExpressionContext(PointcutType.CALL, parameters2, null)));
        assertTrue(new ExpressionInfo(
            "call(void test.expression.Target.parameters2(..)) && args(.., float, byte)",
            NAMESPACE).getExpression().match(new ExpressionContext(PointcutType.CALL, parameters2, null)));
        assertTrue(new ExpressionInfo("call(void test.expression.Target.parameters2(..)) && args(.., byte)", NAMESPACE)
                .getExpression().match(new ExpressionContext(PointcutType.CALL, parameters2, null)));
        assertTrue(new ExpressionInfo(
            "call(void test.expression.Target.parameters2(..)) && args(int, float, ..)",
            NAMESPACE).getExpression().match(new ExpressionContext(PointcutType.CALL, parameters2, null)));
        assertTrue(new ExpressionInfo("call(void test.expression.Target.parameters2(..)) && args(int, ..)", NAMESPACE)
                .getExpression().match(new ExpressionContext(PointcutType.CALL, parameters2, null)));
        assertFalse(new ExpressionInfo(
            "call(void test.expression.Target.parameters2(..)) && args(WRONG, ..)",
            NAMESPACE).getExpression().match(new ExpressionContext(PointcutType.CALL, parameters2, null)));
        assertFalse(new ExpressionInfo(
            "call(void test.expression.Target.parameters2(..)) && args(.., WRONG)",
            NAMESPACE).getExpression().match(new ExpressionContext(PointcutType.CALL, parameters2, null)));
        assertFalse(new ExpressionInfo(
            "call(void test.expression.Target.parameters2(..)) && args(int, float, WRONG)",
            NAMESPACE).getExpression().match(new ExpressionContext(PointcutType.CALL, parameters2, null)));
        assertFalse(new ExpressionInfo(
            "call(void test.expression.Target.parameters2(..)) && args(int, float, byte, WRONG)",
            NAMESPACE).getExpression().match(new ExpressionContext(PointcutType.CALL, parameters2, null)));
    }
View Full Code Here

            "call(void test.expression.Target.parameters2(..)) && args(int, float, byte, WRONG)",
            NAMESPACE).getExpression().match(new ExpressionContext(PointcutType.CALL, parameters2, null)));
    }

    public void testMethodArgs3() throws Exception {
        assertFalse(new ExpressionInfo("call(void test.expression.Target.parameters3())", NAMESPACE).getExpression()
                .match(new ExpressionContext(PointcutType.CALL, parameters3, null)));
        assertTrue(new ExpressionInfo("call(void test.expression.Target.parameters3(..))", NAMESPACE).getExpression()
                .match(new ExpressionContext(PointcutType.CALL, parameters3, null)));
        assertFalse(new ExpressionInfo("call(void test.expression.Target.parameters3(int, ..))", NAMESPACE)
                .getExpression().match(new ExpressionContext(PointcutType.CALL, parameters3, null)));
        assertTrue(new ExpressionInfo("call(void test.expression.Target.parameters3(String, ..))", NAMESPACE)
                .getExpression().match(new ExpressionContext(PointcutType.CALL, parameters3, null)));
        assertFalse(new ExpressionInfo(
            "call(void test.expression.Target.parameters3(String, String, String))",
            NAMESPACE).getExpression().match(new ExpressionContext(PointcutType.CALL, parameters3, null)));
        assertTrue(new ExpressionInfo(
            "call(void test.expression.Target.parameters3(String, StringBuffer, String))",
            NAMESPACE).getExpression().match(new ExpressionContext(PointcutType.CALL, parameters3, null)));
        assertTrue(new ExpressionInfo(
            "call(void test.expression.Target.parameters3(String, java.io.Serializable+, String))",
            NAMESPACE).getExpression().match(new ExpressionContext(PointcutType.CALL, parameters3, null)));
        assertFalse(new ExpressionInfo(
            "call(void test.expression.Target.parameters3(String, StringBuffer, String, *))",
            NAMESPACE).getExpression().match(new ExpressionContext(PointcutType.CALL, parameters3, null)));
    }
View Full Code Here

            "call(void test.expression.Target.parameters3(String, StringBuffer, String, *))",
            NAMESPACE).getExpression().match(new ExpressionContext(PointcutType.CALL, parameters3, null)));
    }

    public void testMethodArgs4() throws Exception {
        assertTrue(new ExpressionInfo("call(void test.expression.Target.parameters4(..)) && args(..)", NAMESPACE)
                .getExpression().match(new ExpressionContext(PointcutType.CALL, parameters4, null)));
        assertTrue(new ExpressionInfo(
            "call(void test.expression.Target.parameters4(..)) && args(java.lang.Object[])",
            NAMESPACE).getExpression().match(new ExpressionContext(PointcutType.CALL, parameters4, null)));
        //use of abbreviation on java.lang.*, up to 2 dimension array, see regexp.Pattern
        assertTrue(new ExpressionInfo("call(void test.expression.Target.parameters4(..)) && args(Object[])", NAMESPACE)
                .getExpression().match(new ExpressionContext(PointcutType.CALL, parameters4, null)));
        assertFalse(new ExpressionInfo(
            "call(void test.expression.Target.parameters4(..)) && args(java.lang.Object[][])",
            NAMESPACE).getExpression().match(new ExpressionContext(PointcutType.CALL, parameters4, null)));
    }
View Full Code Here

            "call(void test.expression.Target.parameters4(..)) && args(java.lang.Object[][])",
            NAMESPACE).getExpression().match(new ExpressionContext(PointcutType.CALL, parameters4, null)));
    }

    public void testMethodArgs5() throws Exception {
        assertTrue(new ExpressionInfo("call(void test.expression.Target.parameters5(..)) && args(..)", NAMESPACE)
                .getExpression().match(new ExpressionContext(PointcutType.CALL, parameters5, null)));
        assertTrue(new ExpressionInfo("call(void test.expression.Target.parameters5(..)) && args(int[][])", NAMESPACE)
                .getExpression().match(new ExpressionContext(PointcutType.CALL, parameters5, null)));
        assertFalse(new ExpressionInfo("call(void test.expression.Target.parameters5(..)) && args(int[])", NAMESPACE)
                .getExpression().match(new ExpressionContext(PointcutType.CALL, parameters5, null)));
    }
View Full Code Here

        assertFalse(new ExpressionInfo("call(void test.expression.Target.parameters5(..)) && args(int[])", NAMESPACE)
                .getExpression().match(new ExpressionContext(PointcutType.CALL, parameters5, null)));
    }

    public void testMethodArgsBinding() throws Exception {
        ExpressionInfo info = null;

        info = new ExpressionInfo("call(void test.expression.Target.parameters2(..)) && args(i, f, b)", NAMESPACE);
        info.addArgument("i", "int");
        info.addArgument("f", "float");
        info.addArgument("b", "byte");
        assertTrue(info.getExpression().match(new ExpressionContext(PointcutType.CALL, parameters2, null)));

        info = new ExpressionInfo("call(void test.expression.Target.parameters2(..)) && args(i, f, byte)", NAMESPACE);
        info.addArgument("i", "int");
        info.addArgument("f", "float");
        assertTrue(info.getExpression().match(new ExpressionContext(PointcutType.CALL, parameters2, null)));

        info = new ExpressionInfo("call(void test.expression.Target.parameters2(..)) && args(i, f, b)", NAMESPACE);
        info.addArgument("i", "int");
        info.addArgument("f", "WRONG");
        // b will be considered as a type
        assertFalse(info.getExpression().match(new ExpressionContext(PointcutType.CALL, parameters2, null)));
    }
View Full Code Here

            if (aspectDef != null) {

                final Set newExpressions = new HashSet();
                for (Iterator it2 = aspectDef.getAdviceDefinitions().iterator(); it2.hasNext();) {
                    AdviceDefinition adviceDef = (AdviceDefinition) it2.next();
                    ExpressionInfo oldExpression = adviceDef.getExpressionInfo();
                    if (oldExpression == null) { // if null, then already undeployed
                        continue;
                    }
                    adviceDef.setExpressionInfo(null);
                    newExpressions.add(oldExpression);
View Full Code Here

     * @param expressions the expressions that will pick out the join points that are affected
     */
    private static void redefine(final Set expressions) {
        final Set allMatchingJoinPoints = new HashSet();
        for (Iterator itExpr = expressions.iterator(); itExpr.hasNext();) {
            ExpressionInfo expression = (ExpressionInfo) itExpr.next();
            Set matchingJoinPoints = JoinPointFactory.getJoinPointsMatching(expression);
            allMatchingJoinPoints.addAll(matchingJoinPoints);
        }

        final ChangeSet changeSet = new ChangeSet();
View Full Code Here

        systemDef.addAspectOverwriteIfExists(newAspectDef);

        final Set newExpressions = new HashSet();
        for (Iterator it2 = newAspectDef.getAdviceDefinitions().iterator(); it2.hasNext();) {
            AdviceDefinition adviceDef = (AdviceDefinition) it2.next();
            ExpressionInfo oldExpression = adviceDef.getExpressionInfo();
            if (oldExpression == null) {
                continue;
            }
            deploymentHandle.registerDefinitionChange(adviceDef, oldExpression);

            final ExpressionInfo newExpression = deploymentScope.newExpressionInfo(oldExpression);
            adviceDef.setExpressionInfo(newExpression);
            newExpressions.add(newExpression);
        }
        return newExpressions;
    }
View Full Code Here

TOP

Related Classes of org.codehaus.aspectwerkz.expression.ExpressionInfo

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.