Package org.codehaus.aspectwerkz.expression

Examples of org.codehaus.aspectwerkz.expression.ExpressionContext


        // thread safe reentrant
        for (Iterator it = definitions.iterator(); it.hasNext();) {
            final SystemDefinition definition = (SystemDefinition) it.next();
            final CtClass ctClass = klass.getCtClass();
            ClassInfo classInfo = JavassistClassInfo.getClassInfo(ctClass, context.getLoader());
            if (classFilter(definition, new ExpressionContext(PointcutType.HANDLER, classInfo, classInfo), ctClass)) {
                continue;
            }
            ctClass.instrument(new ExprEditor() {
                public void edit(Handler handlerExpr) throws CannotCompileException {
                    try {
                        CtClass exceptionClass = null;
                        try {
                            exceptionClass = handlerExpr.getType();
                        } catch (NullPointerException e) {
                            return;
                        }
                        CtBehavior where = null;
                        try {
                            where = handlerExpr.where();
                        } catch (RuntimeException e) {
                            // <clinit> access leads to a bug in Javassist
                            where = ctClass.getClassInitializer();
                        }
                        MemberInfo withinMethodInfo = null;
                        if (where instanceof CtMethod) {
                            withinMethodInfo = JavassistMethodInfo.getMethodInfo((CtMethod) where, context.getLoader());
                        } else if (where instanceof CtConstructor) {
                            withinMethodInfo = JavassistConstructorInfo.getConstructorInfo(
                                (CtConstructor) where,
                                context.getLoader());
                        }
                        ClassInfo exceptionClassInfo = JavassistClassInfo.getClassInfo(exceptionClass, context
                                .getLoader());
                        ExpressionContext ctx = new ExpressionContext(
                            PointcutType.HANDLER,
                            exceptionClassInfo,
                            withinMethodInfo);
                        if (definition.hasPointcut(ctx)) {
                            // call the wrapper method instead of the callee
View Full Code Here


        List definitions = context.getDefinitions();
        for (Iterator it = definitions.iterator(); it.hasNext();) {
            SystemDefinition definition = (SystemDefinition) it.next();
            final CtClass ctClass = klass.getCtClass();
            ClassInfo classMetaData = JavassistClassInfo.getClassInfo(ctClass, context.getLoader());
            if (classFilter(definition, new ExpressionContext(PointcutType.ANY, classMetaData, classMetaData), ctClass)) {
                continue;
            }
            JavassistHelper.addStaticClassField(ctClass, context);
            JavassistHelper.addJoinPointManagerField(ctClass, definition, context);
        }
View Full Code Here

        List definitions = context.getDefinitions();
        for (Iterator it = definitions.iterator(); it.hasNext();) {
            final SystemDefinition definition = (SystemDefinition) it.next();
            final CtClass ctClass = klass.getCtClass();
            ClassInfo classInfo = JavassistClassInfo.getClassInfo(ctClass, context.getLoader());
            if (classFilter(definition, new ExpressionContext(PointcutType.CALL, classInfo, classInfo), ctClass)) {
                return;
            }
            ctClass.instrument(new ExprEditor() {
                public void edit(MethodCall methodCall) throws CannotCompileException {
                    try {
View Full Code Here

                    withinInfo =
                    callerClassInfo.getMethod(AsmHelper.calculateMethodHash(callerMethodName, callerMethodDesc));
                }
        }

        final ExpressionContext ctx = new ExpressionContext(pointcutType, reflectionInfo, withinInfo);
        final AdviceInfoContainer adviceContainer = getAdviceInfoContainerForJoinPoint(
                ctx, callerClass.getClassLoader()
        );
        final CompilationInfo.Model compilationModel = new CompilationInfo.Model(
                emittedJoinPoint, adviceContainer, thisClassInfo
View Full Code Here

            AspectDefinition aspectDef = (AspectDefinition) it.next();
            List advices = aspectDef.getAdviceDefinitions();
            for (Iterator it2 = advices.iterator(); it2.hasNext();) {
                AdviceDefinition adviceDef = (AdviceDefinition) it2.next();
                for (int i = 0; i < ctxs.length; i++) {
                    ExpressionContext ctx = ctxs[i];
                    final ExpressionInfo expressionInfo = adviceDef.getExpressionInfo();
                    if (expressionInfo == null) {
                        continue;
                    }
                    if (expressionInfo.getAdvisedClassFilterExpression().match(ctx) /*||
                        expressionInfo.getAdvisedCflowClassFilterExpression().match(ctx) ALEX XXX CFLOW*/) {
                        if (AspectWerkzPreProcessor.DETAILS) {
                            System.out.println(
                                    "[TRACE - earlymatch: " + expressionInfo + " @ "
                                    + aspectDef.getQualifiedName() + "/" +
                                    adviceDef.getName()
                            );
                            System.out.println("[       for          " + ctx.getReflectionInfo());
                            System.out.println("[       within       " + ctx.getWithinReflectionInfo());
                            System.out.println("[       type         " + ctx.getPointcutType().toString());
                        }
                        return true;
                    }
                }
            }
View Full Code Here

    }

    // ============ constructor signature test =============
    public void testConstructor() throws Exception {
        assertTrue(new ExpressionInfo("call(test.expression.Target.new())", NAMESPACE).getExpression().match(
            new ExpressionContext(PointcutType.CALL, constructor, null)));
        assertFalse(new ExpressionInfo("call(test.expression.Target.new(String))", NAMESPACE).getExpression().match(
            new ExpressionContext(PointcutType.CALL, constructor, null)));
        //AW-112 below
        assertTrue(new ExpressionInfo("within(test.expression.Target) && execution(new())", NAMESPACE).getExpression().match(
            new ExpressionContext(PointcutType.EXECUTION, constructor, null)));
        assertTrue(new ExpressionInfo("within(test..*) && execution(*.expression.Target.new())", NAMESPACE).getExpression().match(
            new ExpressionContext(PointcutType.EXECUTION, constructor, constructor.getDeclaringType())));
        assertTrue(new ExpressionInfo("within(test..*.*) && execution(*.expression.Target.new())", NAMESPACE).getExpression().match(
            new ExpressionContext(PointcutType.EXECUTION, constructor, constructor.getDeclaringType())));
    }
View Full Code Here

    }

    // ============ constructor modifiers test =============
    public void testConstructorModifiers1() throws Exception {
        assertTrue(new ExpressionInfo("call(public test.expression.Target.new())", NAMESPACE).getExpression().match(
            new ExpressionContext(PointcutType.CALL, constructor, null)));
        assertFalse(new ExpressionInfo("call(private test.expression.Target.new())", NAMESPACE).getExpression().match(
            new ExpressionContext(PointcutType.CALL, constructor, null)));
    }
View Full Code Here

    }

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

                .match(new ExpressionContext(PointcutType.EXECUTION, constructor, null)));
    }

    public void testConstructorAnnotations2() throws Exception {
        assertTrue(new ExpressionInfo("execution(@Requires *..*.new(..))", NAMESPACE).getExpression().match(
            new ExpressionContext(PointcutType.EXECUTION, constructor, null)));
        assertFalse(new ExpressionInfo("execution(RequiresNew *..*.new(..))", NAMESPACE).getExpression().match(
            new ExpressionContext(PointcutType.EXECUTION, constructor, null)));
        assertTrue(new ExpressionInfo("call(@Requires *..*.new(..))", NAMESPACE).getExpression().match(
            new ExpressionContext(PointcutType.CALL, constructor, null)));
        assertFalse(new ExpressionInfo("call(RequiresNew *..*.new(..))", NAMESPACE).getExpression().match(
            new ExpressionContext(PointcutType.CALL, constructor, null)));
    }
View Full Code Here

    }

    // ============ method modifiers test =============
    public void testMethodModifiers1() throws Exception {
        assertFalse(new ExpressionInfo("call(public void test.expression.Target.modifiers1())", NAMESPACE)
                .getExpression().match(new ExpressionContext(PointcutType.CALL, modifiers1, null)));
        assertTrue(new ExpressionInfo("call(void test.expression.Target.modifiers1())", NAMESPACE).getExpression()
                .match(new ExpressionContext(PointcutType.CALL, modifiers1, null)));
        assertFalse(new ExpressionInfo("call(static final void test.expression.Target.modifiers1())", NAMESPACE)
                .getExpression().match(new ExpressionContext(PointcutType.CALL, modifiers1, null)));
    }
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.