Package org.codehaus.aspectwerkz.expression

Examples of org.codehaus.aspectwerkz.expression.ExpressionContext


        // loop over all the definitions
        for (Iterator it = definitions.iterator(); it.hasNext();) {
            SystemDefinition definition = (SystemDefinition) it.next();
            final CtClass ctClass = klass.getCtClass();
            ClassInfo classInfo = JavassistClassInfo.getClassInfo(ctClass, context.getLoader());
            ExpressionContext ctx = new ExpressionContext(PointcutType.ANY, classInfo, classInfo);
            if (classFilter(ctClass, ctx, definition)) {
                continue;
            }
            addInterfaceIntroductions(definition, ctClass, context, ctx);
        }
View Full Code Here


        // not 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.CALL, classInfo, classInfo), ctClass)) {
                continue;
            }
            ctClass.instrument(new ExprEditor() {
                public void edit(NewExpr newExpr) throws CannotCompileException {
                    try {
                        CtBehavior where = null;
                        try {
                            where = newExpr.where();
                        } catch (RuntimeException e) {
                            // <clinit> access leads to a bug in Javassist
                            where = ctClass.getClassInitializer();
                        }

                        // filter caller methods
                        if (methodFilterCaller(where)) {
                            return;
                        }
                        CtConstructor ctConstructor = newExpr.getConstructor();
                        String calleeClassName = newExpr.getClassName();

                        // filter callee classes
                        if (!definition.inIncludePackage(calleeClassName)) {
                            return;
                        }

                        // filter the constructors
                        if (constructorFilter(ctConstructor)) {
                            return;
                        }

                        // create the caller method info
                        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());
                        }

                        // create the constructor info
                        CtConstructor constructor = newExpr.getConstructor();
                        ConstructorInfo calleeSideConstructorInfo = JavassistConstructorInfo.getConstructorInfo(
                            constructor,
                            context.getLoader());
                        ExpressionContext ctx = new ExpressionContext(
                            PointcutType.CALL,
                            calleeSideConstructorInfo,
                            withinMethodInfo);

                        // is this a caller side method pointcut?
View Full Code Here

        // loop over all the definitions
        for (Iterator it = definitions.iterator(); it.hasNext();) {
            SystemDefinition definition = (SystemDefinition) it.next();
            final CtClass ctClass = klass.getCtClass();
            ClassInfo classInfo = JavassistClassInfo.getClassInfo(ctClass, context.getLoader());
            ExpressionContext ctx = new ExpressionContext(PointcutType.ANY, classInfo, classInfo);
            if (classFilter(ctClass, ctx, definition)) {
                continue;
            }
            addMethodIntroductions(definition, context, ctx, ctClass);
        }
View Full Code Here

        MethodInfo methodInfo = m_classInfo.getMethod(hash);
        if (methodInfo == null) {
            throw new Error("method info metadata structure could not be build for method: " + name + " " + desc);
        }

        ExpressionContext ctx = new ExpressionContext(PointcutType.EXECUTION, methodInfo, methodInfo);

        if (methodFilter(m_ctx.getDefinitions(), ctx, methodInfo)) {
            return cv.visitMethod(access, name, desc, exceptions, attrs);
        } else {
            m_sequence++; // single place of incrementation, is used in multiple places
View Full Code Here

            ClassInfo classInfo = AsmClassInfo.getClassInfo(bytecode, loader);

            List definitions = context.getDefinitions();
            ExpressionContext[] ctxs = new ExpressionContext[]{
                new ExpressionContext(PointcutType.EXECUTION, classInfo, classInfo),
                new ExpressionContext(PointcutType.CALL, classInfo, 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),

                // TODO: should only ANY be used?
                new ExpressionContext(PointcutType.ANY, classInfo, classInfo)
            };
            if (classFilter(definitions, ctxs, classInfo)) {
                return;
            }
            System.out.println("AW INFO: weaving class = " + className + " in class loader " + loader);
View Full Code Here

                    );
                }
            }

            if (opcode == PUTFIELD) {
                ExpressionContext ctx = new ExpressionContext(PointcutType.SET, fieldInfo, m_callerMethodInfo);

                if (fieldFilter(m_ctx.getDefinitions(), ctx, fieldInfo)) {
                    super.visitFieldInsn(opcode, className, fieldName, fieldDesc);
                } else {
                    m_ctx.markAsAdvised();
View Full Code Here

                            + calleeMethodDesc
                    );
                }
            }

            ExpressionContext ctx = new ExpressionContext(PointcutType.CALL, calleeMethodInfo, m_callerMethodInfo);

            if (methodFilter(m_ctx.getDefinitions(), ctx, calleeMethodInfo)) {
                super.visitMethodInsn(opcode, calleeClassName, calleeMethodName, calleeMethodDesc);
            } else {
                m_ctx.markAsAdvised();
View Full Code Here

                    ':' +
                    desc
            );
        }

        ExpressionContext ctx = new ExpressionContext(PointcutType.SET, fieldInfo, null);

        if (fieldFilter(m_ctx.getDefinitions(), ctx, fieldInfo) || Modifier.isPublic(access)) {
            super.visitField(access, name, desc, value, attrs);
        } else {
            int modifiers = ACC_PUBLIC;
View Full Code Here

                    ':' +
                    desc
            );
        }

        ExpressionContext ctx = new ExpressionContext(PointcutType.EXECUTION, methodInfo, methodInfo);
        //FIXME - match for CALL pc as well ??

        if (methodFilter(m_ctx.getDefinitions(), ctx, methodInfo)) {
            return cv.visitMethod(access, name, desc, exceptions, attrs);
        } else {
View Full Code Here

        // thread safe

        final CtClass ctClass = klass.getCtClass();
        ClassInfo classInfo = JavassistClassInfo.getClassInfo(ctClass, context.getLoader());
       
        if (classFilter(definitions, new ExpressionContext(PointcutType.EXECUTION, classInfo, classInfo), ctClass)) {
            return;
        }
        final CtMethod[] methods = ctClass.getDeclaredMethods();

        // Compute the method sequence number no matter the method is advised to
        // support multi weaving.
        // Javassist.getDeclaredMethods() does not always return methods in the
        // same order so we have
        // to sort the method list before computation.
        // @TODO: filter init/clinit/prefixed methods
        final List sortedMethods = Arrays.asList(methods);
        Collections.sort(sortedMethods, JavassistMethodComparator.getInstance());
        final TObjectIntHashMap methodSequences = new TObjectIntHashMap();
        final List sortedMethodTuples = new ArrayList(sortedMethods.size());
        for (Iterator methodsIt = sortedMethods.iterator(); methodsIt.hasNext();) {
            CtMethod method = (CtMethod) methodsIt.next();
            MethodInfo methodInfo = JavassistMethodInfo.getMethodInfo(method, context.getLoader());
            int sequence = 1;
            if (methodSequences.containsKey(method.getName())) {
                sequence = methodSequences.get(method.getName());
                methodSequences.remove(method.getName());
                sequence++;
            }
            methodSequences.put(method.getName(), sequence);
            ExpressionContext ctx = new ExpressionContext(PointcutType.EXECUTION, methodInfo, methodInfo);
            MethodSequenceTuple tuple = new MethodSequenceTuple(method, sequence);
            int status = methodFilter(definitions, ctx, method);
            tuple.setStatus(status);

            // @TODO filter out "skip" status
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.