Package org.codehaus.aspectwerkz.expression

Examples of org.codehaus.aspectwerkz.expression.ExpressionContext


    // ============ method attribute test =============
    public void testMethodAttributes1() throws Exception {
        assertTrue(
                new ExpressionInfo("call(void test.expression.Target.attributes1())", NAMESPACE).getExpression()
                .match(new ExpressionContext(PointcutType.CALL, attributes1, null))
        );
        assertTrue(
                new ExpressionInfo("call(@Requires void test.expression.Target.attributes1())", NAMESPACE)
                .getExpression().match(new ExpressionContext(PointcutType.CALL, attributes1, null))
        );
        assertFalse(
                new ExpressionInfo("call(@RequiresNew void test.expression.Target.attributes1())", NAMESPACE)
                .getExpression().match(new ExpressionContext(PointcutType.CALL, attributes1, null))
        );
        assertFalse(
                new ExpressionInfo(
                        "call(@Requires @RequiresNew void test.expression.Target.attributes1())",
                        NAMESPACE
                ).getExpression().match(new ExpressionContext(PointcutType.CALL, attributes1, null))
        );
    }
View Full Code Here


    // ============ field modifier test =============
    public void testFieldModifiers1() throws Exception {
        assertTrue(
                new ExpressionInfo("set(int test.expression.Target.modifier1)", NAMESPACE).getExpression().match(
                        new ExpressionContext(PointcutType.SET, modifier1, null)
                )
        );
        assertFalse(
                new ExpressionInfo("set(public int test.expression.Target.modifier1)", NAMESPACE).getExpression()
                .match(new ExpressionContext(PointcutType.SET, modifier1, null))
        );
        assertFalse(
                new ExpressionInfo("set(public int test.expression.Target.modifier1)", NAMESPACE).getExpression()
                .match(new ExpressionContext(PointcutType.SET, modifier1, null))
        );
    }
View Full Code Here

    }

    public void testFieldModifiers2() throws Exception {
        assertTrue(
                new ExpressionInfo("set(int test.expression.Target.modifier2)", NAMESPACE).getExpression().match(
                        new ExpressionContext(PointcutType.SET, modifier2, null)
                )
        );
        assertTrue(
                new ExpressionInfo("set(public int test.expression.Target.modifier2)", NAMESPACE).getExpression()
                .match(new ExpressionContext(PointcutType.SET, modifier2, null))
        );
        assertTrue(
                new ExpressionInfo("set(static public int test.expression.Target.modifier2)", NAMESPACE)
                .getExpression().match(new ExpressionContext(PointcutType.SET, modifier2, null))
        );
        assertTrue(
                new ExpressionInfo("set(static int test.expression.Target.modifier2)", NAMESPACE).getExpression()
                .match(new ExpressionContext(PointcutType.SET, modifier2, null))
        );
        assertFalse(
                new ExpressionInfo("set(protected int test.expression.Target.modifier2)", NAMESPACE)
                .getExpression().match(new ExpressionContext(PointcutType.SET, modifier2, null))
        );
    }
View Full Code Here

    }

    public void testFieldModifiers3() throws Exception {
        assertTrue(
                new ExpressionInfo("set(int test.expression.Target.modifier3)", NAMESPACE).getExpression().match(
                        new ExpressionContext(PointcutType.SET, modifier3, null)
                )
        );
        assertTrue(
                new ExpressionInfo("set(protected int test.expression.Target.modifier3)", NAMESPACE).getExpression()
                .match(new ExpressionContext(PointcutType.SET, modifier3, null))
        );
        assertTrue(
                new ExpressionInfo("set(static protected int test.expression.Target.modifier3)", NAMESPACE)
                .getExpression().match(new ExpressionContext(PointcutType.SET, modifier3, null))
        );
        assertTrue(
                new ExpressionInfo("set(static int test.expression.Target.modifier3)", NAMESPACE).getExpression()
                .match(new ExpressionContext(PointcutType.SET, modifier3, null))
        );
        assertTrue(
                new ExpressionInfo("set(transient int test.expression.Target.modifier3)", NAMESPACE).getExpression()
                .match(new ExpressionContext(PointcutType.SET, modifier3, null))
        );
        assertTrue(
                new ExpressionInfo(
                        "set(static transient protected final int test.expression.Target.modifier3)",
                        NAMESPACE
                ).getExpression().match(new ExpressionContext(PointcutType.SET, modifier3, null))
        );
        assertFalse(
                new ExpressionInfo("set(public int test.expression.Target.modifier3)", NAMESPACE).getExpression()
                .match(new ExpressionContext(PointcutType.SET, modifier3, null))
        );
    }
View Full Code Here

    //    }
    // ============ field type test =============
    public void testFieldType1() throws Exception {
        assertTrue(
                new ExpressionInfo("set(int test.expression.Target.type1)", NAMESPACE).getExpression().match(
                        new ExpressionContext(PointcutType.SET, type1, null)
                )
        );
        assertTrue(
                new ExpressionInfo("set(* test.expression.Target.type1)", NAMESPACE).getExpression().match(
                        new ExpressionContext(PointcutType.SET, type1, null)
                )
        );
        assertFalse(
                new ExpressionInfo("set(Integer test.expression.Target.type1)", NAMESPACE).getExpression().match(
                        new ExpressionContext(PointcutType.SET, type1, null)
                )
        );
        assertFalse(
                new ExpressionInfo("set(int[] test.expression.Target.type1)", NAMESPACE).getExpression().match(
                        new ExpressionContext(PointcutType.SET, type1, null)
                )
        );
    }
View Full Code Here

    }

    public void testFieldType2() throws Exception {
        assertFalse(
                new ExpressionInfo("set(int test.expression.Target.type2)", NAMESPACE).getExpression().match(
                        new ExpressionContext(PointcutType.SET, type2, null)
                )
        );
        assertTrue(
                new ExpressionInfo("set(* test.expression.Target.type2)", NAMESPACE).getExpression().match(
                        new ExpressionContext(PointcutType.SET, type2, null)
                )
        );
        assertFalse(
                new ExpressionInfo("set(Integer test.expression.Target.type2)", NAMESPACE).getExpression().match(
                        new ExpressionContext(PointcutType.SET, type2, null)
                )
        );
        assertFalse(
                new ExpressionInfo("set(int[] test.expression.Target.type2)", NAMESPACE).getExpression().match(
                        new ExpressionContext(PointcutType.SET, type2, null)
                )
        );
        assertTrue(
                new ExpressionInfo("set(int[][] test.expression.Target.type2)", NAMESPACE).getExpression().match(
                        new ExpressionContext(PointcutType.SET, type2, null)
                )
        );
    }
View Full Code Here

    }

    public void testFieldType3() throws Exception {
        assertTrue(
                new ExpressionInfo("set(String test.expression.Target.type3)", NAMESPACE).getExpression().match(
                        new ExpressionContext(PointcutType.SET, type3, null)
                )
        );
        assertTrue(
                new ExpressionInfo("set(java.lang.String test.expression.Target.type3)", NAMESPACE).getExpression()
                .match(new ExpressionContext(PointcutType.SET, type3, null))
        );
        assertFalse(
                new ExpressionInfo("set(java.lang.string test.expression.Target.type3)", NAMESPACE).getExpression()
                .match(new ExpressionContext(PointcutType.SET, type3, null))
        );
        assertTrue(
                new ExpressionInfo("set(java..* test.expression.Target.type3)", NAMESPACE).getExpression().match(
                        new ExpressionContext(PointcutType.SET, type3, null)
                )
        );
        assertTrue(
                new ExpressionInfo("set(java.*.String test.expression.Target.type3)", NAMESPACE).getExpression()
                .match(new ExpressionContext(PointcutType.SET, type3, null))
        );
        assertTrue(
                new ExpressionInfo("set(java.lang.String* test.expression.Target.type3)", NAMESPACE).getExpression()
                .match(new ExpressionContext(PointcutType.SET, type3, null))
        );
        assertTrue(
                new ExpressionInfo("set(* test.expression.Target.type3)", NAMESPACE).getExpression().match(
                        new ExpressionContext(PointcutType.SET, type3, null)
                )
        );
        assertFalse(
                new ExpressionInfo("set(StringBuffer test.expression.Target.type3)", NAMESPACE).getExpression()
                .match(new ExpressionContext(PointcutType.SET, type3, null))
        );
        assertFalse(
                new ExpressionInfo("set(java.lang.StringBuffer test.expression.Target.type3)", NAMESPACE)
                .getExpression().match(new ExpressionContext(PointcutType.SET, type3, null))
        );
        assertFalse(
                new ExpressionInfo("set(String[] test.expression.Target.type3)", NAMESPACE).getExpression().match(
                        new ExpressionContext(PointcutType.SET, type3, null)
                )
        );
        assertFalse(
                new ExpressionInfo("set(java.lang.String[] test.expression.Target.type3)", NAMESPACE)
                .getExpression().match(new ExpressionContext(PointcutType.SET, type3, null))
        );
    }
View Full Code Here

    }

    public void testFieldType4() throws Exception {
        assertFalse(
                new ExpressionInfo("set(String test.expression.Target.type4)", NAMESPACE).getExpression().match(
                        new ExpressionContext(PointcutType.SET, type4, null)
                )
        );
        assertFalse(
                new ExpressionInfo("set(java.lang.String test.expression.Target.type4)", NAMESPACE).getExpression()
                .match(new ExpressionContext(PointcutType.SET, type4, null))
        );
        assertTrue(
                new ExpressionInfo("set(String[] test.expression.Target.type4)", NAMESPACE).getExpression().match(
                        new ExpressionContext(PointcutType.SET, type4, null)
                )
        );
        assertTrue(
                new ExpressionInfo("set(java.lang.String[] test.expression.Target.type4)", NAMESPACE)
                .getExpression().match(new ExpressionContext(PointcutType.SET, type4, null))
        );
        assertTrue(
                new ExpressionInfo("set(* test.expression.Target.type4)", NAMESPACE).getExpression().match(
                        new ExpressionContext(PointcutType.SET, type4, null)
                )
        );
        assertFalse(
                new ExpressionInfo("set(String[][] test.expression.Target.type4)", NAMESPACE).getExpression()
                .match(new ExpressionContext(PointcutType.SET, type4, null))
        );
        assertFalse(
                new ExpressionInfo("set(int[] test.expression.Target.type4)", NAMESPACE).getExpression().match(
                        new ExpressionContext(PointcutType.SET, type4, null)
                )
        );
    }
View Full Code Here

            final ClassLoader loader = context.getLoader();

            ClassInfo classInfo = AsmClassInfo.getClassInfo(bytecode, loader);
            final Set definitions = context.getDefinitions();
            final ExpressionContext[] ctxs = new ExpressionContext[]{
                new ExpressionContext(PointcutType.EXECUTION, classInfo, classInfo),
                new ExpressionContext(PointcutType.CALL, null, classInfo),
                new ExpressionContext(PointcutType.GET, classInfo, classInfo),
                new ExpressionContext(PointcutType.SET, classInfo, classInfo),
                new ExpressionContext(PointcutType.HANDLER, classInfo, classInfo),
                new ExpressionContext(PointcutType.STATIC_INITIALIZATION, classInfo, classInfo),
                new ExpressionContext(PointcutType.WITHIN, classInfo, classInfo)
            };

            if (classFilter(definitions, ctxs, classInfo)) {
                return;
            }

            // build the ClassInfo from the bytecode to avoid loading it from the loader resource stream later
            // to support stub weaving
            AsmClassInfo.getClassInfo(bytecode, loader);

            // compute CALL + GET/SET early matching results to avoid registering useless visitors
            final boolean filterForCall = classFilterFor(
                    definitions, new ExpressionContext[]{
                        new ExpressionContext(PointcutType.CALL, null, classInfo),
                        new ExpressionContext(PointcutType.WITHIN, classInfo, classInfo)
                    }
            );//FIXME - within make match all
            final boolean filterForGetSet = classFilterFor(
                    definitions, new ExpressionContext[]{
                        new ExpressionContext(PointcutType.GET, classInfo, classInfo),
                        new ExpressionContext(PointcutType.SET, classInfo, classInfo),
                        new ExpressionContext(PointcutType.WITHIN, classInfo, classInfo)
                    }
            );//FIXME - within make match all
            final boolean filterForHandler = classFilterFor(
                    definitions, new ExpressionContext[]{
                        new ExpressionContext(PointcutType.HANDLER, null, classInfo),
                        new ExpressionContext(PointcutType.WITHIN, classInfo, classInfo)
                    }
            );//FIXME - within make match all

            // prepare ctor call jp
            final ClassReader crLookahead = new ClassReader(bytecode);
View Full Code Here

        // thread safe and reentrant
        for (Iterator it = definitions.iterator(); it.hasNext();) {
            SystemDefinition definition = (SystemDefinition) it.next();
            final CtClass ctClass = klass.getCtClass();
            ClassInfo classInfo = JavassistClassInfo.getClassInfo(ctClass, context.getLoader());
            if (classFilter(definition, new ExpressionContext(PointcutType.EXECUTION, classInfo, classInfo), ctClass)) {
                continue;
            }
            final CtConstructor[] constructors = ctClass.getConstructors();
            for (int i = 0; i < constructors.length; i++) {
                CtConstructor constructor = constructors[i];
                ConstructorInfo constructorInfo = JavassistConstructorInfo.getConstructorInfo(constructor, context
                        .getLoader());
                ExpressionContext ctx = new ExpressionContext(PointcutType.EXECUTION, constructorInfo, constructorInfo);
                if (constructorFilter(definition, ctx)) {
                    continue;
                }
                if (addPrefixToConstructor(ctClass, constructor)) {
                    context.markAsAdvised();
View Full Code Here

TOP

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

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.