Package org.codehaus.aspectwerkz.metadata

Examples of org.codehaus.aspectwerkz.metadata.FieldMetaData$NullFieldMetaData


                                        final String signature = currentGetFieldIns.getFieldType(cpg).
                                                toString() + " " + fieldName;
                                        final Type joinPointType = TransformationUtil.STATIC_FIELD_SET_JOIN_POINT_TYPE;
                                        final String joinPointClass = TransformationUtil.STATIC_FIELD_SET_JOIN_POINT_CLASS;

                                        FieldMetaData fieldMetaData =
                                                BcelMetaDataMaker.createFieldMetaData(currentGetFieldIns, cpg);

                                        String uuid = setFieldFilter(definition, classMetaData, fieldMetaData);

                                        // do we have to set a joinpoint ?
                                        if (uuid != null) {
                                            final String fieldClassName = currentGetFieldIns.getClassName(cpg);

                                            if (fieldClassName.equals(cg.getClassName())) {
                                                isMethodAdvised = true;

                                                insertPreAdvice(il, ih, cg, fieldName, factory, joinPointType);
                                                insertPostAdvice(il, ih.getNext().getNext(), cg, fieldName, factory, joinPointType);

                                                // skip the creation of the set join point if we
                                                // already have one
                                                if (!setFieldJoinPoints.contains(fieldName)) {
                                                    setFieldJoinPoints.add(fieldName);

                                                    addStaticJoinPointField(cpg, cg, fieldName, joinPointType);

                                                    if (noClInitMethod && clInitMethod==null) {
                                                        // were no clinit and first creation of clinit
                                                        clInitMethod = createClInitMethodWithStaticJoinPointField(
                                                                cpg, cg, fieldName, signature, factory,
                                                                joinPointType, joinPointClass, uuid);
                                                    }
                                                    else if (noClInitMethod) {
                                                        // we are modyfing the newly created clinit
                                                        clInitMethod = createStaticJoinPointField(
                                                                cpg, cg, clInitMethod, fieldName, signature,
                                                                factory, joinPointType, joinPointClass, uuid);
                                                    }
                                                    else {
                                                        // the clinit method was existing
                                                        methods[clinitIndex] = createStaticJoinPointField(
                                                                cpg, cg, methods[clinitIndex], fieldName, signature,
                                                                factory, joinPointType, joinPointClass, uuid);
                                                    }
                                                }

                                                // add one step more to the InstructionList (GETFIELD(current) INVOKEINTERFACE with jp)
                                                ih = ih.getNext();
                                                ins = ih.getInstruction();
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    // handle the GETSTATIC instructions
                    // (if we have set a getstatic for collection modification jp the ins has been altered)
                    if (ins instanceof GETSTATIC) {
                        FieldInstruction gfIns = (FieldInstruction)ins;

                        String fieldName = gfIns.getName(cpg);
                        String signature = gfIns.getFieldType(cpg).toString() + " " + fieldName;
                        Type joinPointType = TransformationUtil.STATIC_FIELD_GET_JOIN_POINT_TYPE;
                        String joinPointClass = TransformationUtil.STATIC_FIELD_GET_JOIN_POINT_CLASS;

                        FieldMetaData fieldMetaData =
                                BcelMetaDataMaker.createFieldMetaData(gfIns, cpg);

                        String uuid = getFieldFilter(definition, classMetaData, fieldMetaData);
                        if (uuid != null) {

                            String fieldClassName = gfIns.getClassName(cpg);
                            if (fieldClassName.equals(cg.getClassName())) {
                                isMethodAdvised = true;

                                insertPreAdvice(il, ih, cg, fieldName, factory, joinPointType);
                                insertPostAdvice(il, ih.getNext(), cg, fieldName, factory, joinPointType);

                                // skip the creation of the join point if we
                                // already have one
                                if (!getFieldJoinPoints.contains(fieldName)) {
                                    getFieldJoinPoints.add(fieldName);

                                    addStaticJoinPointField(cpg, cg, fieldName, joinPointType);

                                    if (noClInitMethod && clInitMethod==null) {
                                        // were no clinit and first creation of clinit
                                        clInitMethod = createClInitMethodWithStaticJoinPointField(
                                                cpg, cg, fieldName, signature, factory,
                                                joinPointType, joinPointClass, uuid);
                                    }
                                    else if (noClInitMethod) {
                                        // we are modyfing the newly created clinit
                                        clInitMethod = createStaticJoinPointField(
                                                cpg, cg, clInitMethod, fieldName, signature,
                                                factory, joinPointType, joinPointClass, uuid);
                                    }
                                    else {
                                        // the clinit method was existing
                                        methods[clinitIndex] = createStaticJoinPointField(
                                                cpg, cg, methods[clinitIndex], fieldName, signature,
                                                factory, joinPointType, joinPointClass, uuid);
                                    }
                                }
                            }
                        }
                    }
                    else if (ins instanceof PUTSTATIC) {
                        FieldInstruction pfIns = (FieldInstruction)ins;

                        String fieldName = pfIns.getName(cpg);
                        String signature = pfIns.getFieldType(cpg).toString() + " " + fieldName;
                        Type joinPointType = TransformationUtil.STATIC_FIELD_SET_JOIN_POINT_TYPE;
                        String joinPointClass = TransformationUtil.STATIC_FIELD_SET_JOIN_POINT_CLASS;

                        FieldMetaData fieldMetaData =
                                BcelMetaDataMaker.createFieldMetaData(pfIns, cpg);

                        String uuid = setFieldFilter(definition, classMetaData, fieldMetaData);
                        if (uuid != null) {
View Full Code Here


            Expression.registerExpressionTemplate(Expression.createExpressionTemplate("namespace", "* test.ExpressionTest.m_type", "", "pc2", PointcutType.SET));
            Expression root = Expression.createRootExpression("namespace", "pc1 || pc2");

            ClassMetaData classMetaData1 = ReflectionMetaDataMaker.createClassMetaData(ExpressionTest.class);
            ClassMetaData classMetaData2 = ReflectionMetaDataMaker.createClassMetaData(ExpressionException.class);
            FieldMetaData fieldMetaData1 = ReflectionMetaDataMaker.createFieldMetaData(ExpressionTest.class.getDeclaredField("m_name"));
            FieldMetaData fieldMetaData2 = ReflectionMetaDataMaker.createFieldMetaData(ExpressionTest.class.getDeclaredField("m_type"));

            assertTrue(root.match(classMetaData1));
            assertFalse(root.match(classMetaData2));
            assertTrue(root.match(classMetaData1, fieldMetaData1));
            assertTrue(root.match(classMetaData1, fieldMetaData2));
View Full Code Here

            Expression.registerExpressionTemplate(Expression.createExpressionTemplate("namespace", "* test.ExpressionTest.m_type", "", "pc2", PointcutType.GET));
            Expression root = Expression.createRootExpression("namespace", "pc1 || pc2");

            ClassMetaData classMetaData1 = ReflectionMetaDataMaker.createClassMetaData(ExpressionTest.class);
            ClassMetaData classMetaData2 = ReflectionMetaDataMaker.createClassMetaData(ExpressionException.class);
            FieldMetaData fieldMetaData1 = ReflectionMetaDataMaker.createFieldMetaData(ExpressionTest.class.getDeclaredField("m_name"));
            FieldMetaData fieldMetaData2 = ReflectionMetaDataMaker.createFieldMetaData(ExpressionTest.class.getDeclaredField("m_type"));

            assertTrue(root.match(classMetaData1));
            assertFalse(root.match(classMetaData2));
            assertTrue(root.match(classMetaData1, fieldMetaData1));
            assertTrue(root.match(classMetaData1, fieldMetaData2));
View Full Code Here

            Expression.registerExpressionTemplate(Expression.createExpressionTemplate("namespace", "* test.ExpressionTest.m_type", "", "pc2", PointcutType.SET));
            Expression root = Expression.createRootExpression("namespace", "!pc1 && pc2");

            ClassMetaData classMetaData1 = ReflectionMetaDataMaker.createClassMetaData(ExpressionTest.class);
            ClassMetaData classMetaData2 = ReflectionMetaDataMaker.createClassMetaData(ExpressionException.class);
            FieldMetaData fieldMetaData1 = ReflectionMetaDataMaker.createFieldMetaData(ExpressionTest.class.getDeclaredField("m_name"));
            FieldMetaData fieldMetaData2 = ReflectionMetaDataMaker.createFieldMetaData(ExpressionTest.class.getDeclaredField("m_type"));

            assertTrue(root.match(classMetaData1));
            assertFalse(root.match(classMetaData2));
            assertFalse(root.match(classMetaData1, fieldMetaData1));
            assertTrue(root.match(classMetaData1, fieldMetaData2));
View Full Code Here

            Expression.registerExpressionTemplate(Expression.createExpressionTemplate("namespace", "* test.ExpressionTest.m_type", "", "pc2", PointcutType.GET));
            Expression root = Expression.createRootExpression("namespace", "!pc1 && pc2");

            ClassMetaData classMetaData1 = ReflectionMetaDataMaker.createClassMetaData(ExpressionTest.class);
            ClassMetaData classMetaData2 = ReflectionMetaDataMaker.createClassMetaData(ExpressionException.class);
            FieldMetaData fieldMetaData1 = ReflectionMetaDataMaker.createFieldMetaData(ExpressionTest.class.getDeclaredField("m_name"));
            FieldMetaData fieldMetaData2 = ReflectionMetaDataMaker.createFieldMetaData(ExpressionTest.class.getDeclaredField("m_type"));

            assertTrue(root.match(classMetaData1));
            assertFalse(root.match(classMetaData2));
            assertFalse(root.match(classMetaData1, fieldMetaData1));
            assertTrue(root.match(classMetaData1, fieldMetaData2));
View Full Code Here

            Expression.registerExpressionTemplate(Expression.createExpressionTemplate("namespace", "pc1 || pc2", "", "pc3", PointcutType.SET));
            Expression.registerExpressionTemplate(Expression.createExpressionTemplate("namespace", "* test.ExpressionTest.m_dummy", "", "pc4", PointcutType.SET));
            Expression root = Expression.createRootExpression("namespace", "pc3 && !pc4");

            ClassMetaData classMetaData1 = ReflectionMetaDataMaker.createClassMetaData(ExpressionTest.class);
            FieldMetaData fieldMetaData1 = ReflectionMetaDataMaker.createFieldMetaData(ExpressionTest.class.getDeclaredField("m_name"));
            FieldMetaData fieldMetaData2 = ReflectionMetaDataMaker.createFieldMetaData(ExpressionTest.class.getDeclaredField("m_type"));
            FieldMetaData fieldMetaData3 = ReflectionMetaDataMaker.createFieldMetaData(ExpressionTest.class.getDeclaredField("m_dummy"));

            assertTrue(root.match(classMetaData1));
            assertTrue(root.match(classMetaData1, fieldMetaData1));
            assertTrue(root.match(classMetaData1, fieldMetaData2));
            assertFalse(root.match(classMetaData1, fieldMetaData3));
View Full Code Here

            Expression.registerExpressionTemplate(Expression.createExpressionTemplate("namespace", "pc1 || pc2", "", "pc3", PointcutType.GET));
            Expression.registerExpressionTemplate(Expression.createExpressionTemplate("namespace", "* test.ExpressionTest.m_dummy", "", "pc4", PointcutType.GET));
            Expression root = Expression.createRootExpression("namespace", "pc3 && !pc4");

            ClassMetaData classMetaData1 = ReflectionMetaDataMaker.createClassMetaData(ExpressionTest.class);
            FieldMetaData fieldMetaData1 = ReflectionMetaDataMaker.createFieldMetaData(ExpressionTest.class.getDeclaredField("m_name"));
            FieldMetaData fieldMetaData2 = ReflectionMetaDataMaker.createFieldMetaData(ExpressionTest.class.getDeclaredField("m_type"));
            FieldMetaData fieldMetaData3 = ReflectionMetaDataMaker.createFieldMetaData(ExpressionTest.class.getDeclaredField("m_dummy"));

            assertTrue(root.match(classMetaData1));
            assertTrue(root.match(classMetaData1, fieldMetaData1));
            assertTrue(root.match(classMetaData1, fieldMetaData2));
            assertFalse(root.match(classMetaData1, fieldMetaData3));
View Full Code Here

    public void testMatchHierachicalExpression_SET() {
        try {
            Expression root = Expression.createRootExpression("namespace", "* *..TestCase+.m_dummy", PointcutType.SET);
            ClassMetaData classMetaData1 = ReflectionMetaDataMaker.createClassMetaData(ExpressionTest.class);
            FieldMetaData fieldMetaData1 = ReflectionMetaDataMaker.createFieldMetaData(ExpressionTest.class.getDeclaredField("m_name"));
            FieldMetaData fieldMetaData2 = ReflectionMetaDataMaker.createFieldMetaData(ExpressionTest.class.getDeclaredField("m_type"));
            FieldMetaData fieldMetaData3 = ReflectionMetaDataMaker.createFieldMetaData(ExpressionTest.class.getDeclaredField("m_dummy"));
            assertTrue(root.match(classMetaData1));
            assertFalse(root.match(classMetaData1, fieldMetaData1));
            assertFalse(root.match(classMetaData1, fieldMetaData2));
            assertTrue(root.match(classMetaData1, fieldMetaData3));
        }
View Full Code Here

                    String fieldName = gfIns.getName(cpg);
                    String signature = gfIns.getFieldType(cpg).toString() + " " + fieldName;
                    Type joinPointType = TransformationUtil.STATIC_FIELD_GET_JOIN_POINT_TYPE;
                    String joinPointClass = TransformationUtil.STATIC_FIELD_GET_JOIN_POINT_CLASS;

                    FieldMetaData fieldMetaData =
                            BcelMetaDataMaker.createFieldMetaData(gfIns, cpg);

                    String uuid = getFieldFilter(classMetaData, fieldMetaData);
                    if (uuid != null) {

                        String fieldClassName = gfIns.getClassName(cpg);
                        if (fieldClassName.equals(cg.getClassName())) {
                            isClassAdvised = true;

                            // in static context
                            if (mg.isStatic()) {
                                insertPreAdvice(il, ih, cg, fieldName, factory, joinPointType);
                                insertPostAdvice(il, ih.getNext(), cg, fieldName, factory, joinPointType);

                                // skip the creation of the join point if we
                                // already have one
                                if (!getFieldJoinPoints.contains(fieldName)) {
                                    getFieldJoinPoints.add(fieldName);

                                    addStaticJoinPointField(cpg, cg, fieldName, joinPointType);

                                    if (noClInitMethod) {
                                        clInitMethod = createClInitMethodWithStaticJoinPointField(
                                                cpg, cg, fieldName, signature, factory,
                                                joinPointType, joinPointClass, uuid);
                                    }
                                    else {
                                        methods[clinitIndex] = createStaticJoinPointField(
                                                cpg, cg, methods[clinitIndex], fieldName, signature,
                                                factory, joinPointType, joinPointClass, uuid);
                                    }
                                }
                            }
                        }
                    }
                }
                else if (ins instanceof PUTFIELD || ins instanceof PUTSTATIC) {
                    FieldInstruction pfIns = (FieldInstruction)ins;

                    String fieldName = pfIns.getName(cpg);
                    String signature = pfIns.getFieldType(cpg).toString() + " " + fieldName;
                    Type joinPointType = TransformationUtil.STATIC_FIELD_SET_JOIN_POINT_TYPE;
                    String joinPointClass = TransformationUtil.STATIC_FIELD_SET_JOIN_POINT_CLASS;

                    FieldMetaData fieldMetaData =
                            BcelMetaDataMaker.createFieldMetaData(pfIns, cpg);

                    String uuid = setFieldFilter(classMetaData, fieldMetaData);
                    if (uuid != null) {
View Full Code Here

                            final String fieldName = currentGetFieldIns.getName(cpg);
                            final String signature = currentGetFieldIns.getFieldType(cpg).
                                    toString() + " " + fieldName;
                            final Type joinPointType = TransformationUtil.MEMBER_FIELD_SET_JOIN_POINT_TYPE;

                            FieldMetaData fieldMetaData =
                                    BcelMetaDataMaker.createFieldMetaData(currentGetFieldIns, cpg);

                            String uuid = setFieldFilter(classMetaData, fieldMetaData);

                            if (uuid != null) {
                                final String fieldClassName = currentGetFieldIns.getClassName(cpg);

                                if (fieldClassName.equals(cg.getClassName())) {

                                    // is NOT in static context
                                    if (!mg.isStatic()) {
                                        isClassAdvised = true;

                                        insertPreAdvice(
                                                il, ih, cg, fieldName,
                                                factory, joinPointType);

                                        insertPostAdvice(
                                                il, ih.getNext(), cg,
                                                fieldName, factory, joinPointType);

                                        // store the join point field data
                                        JoinPointFieldData data = new JoinPointFieldData(
                                                fieldName, signature, joinPointType, uuid);

                                        if (!setFieldJoinPoints.contains(data)) {
                                            setFieldJoinPoints.add(data);
                                        }
                                    }
                                }
                                // set the current get field instruction to null
                                currentGetFieldIns = null;
                            }
                        }
                    }
                }
                // handle the getField instructions
                else if (ins instanceof GETFIELD || ins instanceof GETSTATIC) {
                    final FieldInstruction gfIns = (FieldInstruction)ins;

                    String fieldName = gfIns.getName(cpg);
                    String signature = gfIns.getFieldType(cpg).toString() + " " + fieldName;
                    Type joinPointType = TransformationUtil.MEMBER_FIELD_GET_JOIN_POINT_TYPE;

                    FieldMetaData fieldMetaData = BcelMetaDataMaker.createFieldMetaData(gfIns, cpg);

                    String uuid = getFieldFilter(classMetaData, fieldMetaData);
                    if (uuid != null) {

                        final String fieldClassName = gfIns.getClassName(cpg);
                        if (fieldClassName.equals(cg.getClassName())) {

                            // is NOT in static context
                            if (!mg.isStatic()) {
                                isClassAdvised = true;

                                insertPreAdvice(
                                        il, ih, cg, fieldName,
                                        factory, joinPointType);

                                insertPostAdvice(
                                        il, ih.getNext(), cg,
                                        fieldName, factory, joinPointType);

                                // store the join point field data
                                JoinPointFieldData data = new JoinPointFieldData(
                                        fieldName, signature, joinPointType, uuid);

                                if (!getFieldJoinPoints.contains(data)) {
                                    getFieldJoinPoints.add(data);
                                }
                            }
                        }
                    }
                }
                // handle the setField instructions
                else if (ins instanceof PUTFIELD || ins instanceof PUTSTATIC) {
                    final FieldInstruction pfIns = (FieldInstruction)ins;

                    String fieldName = pfIns.getName(cpg);
                    String signature = pfIns.getFieldType(cpg).toString() + " " + fieldName;
                    Type joinPointType = TransformationUtil.MEMBER_FIELD_SET_JOIN_POINT_TYPE;

                    FieldMetaData fieldMetaData =
                            BcelMetaDataMaker.createFieldMetaData(pfIns, cpg);

                    String uuid = setFieldFilter(classMetaData, fieldMetaData);
                    if (uuid != null) {
View Full Code Here

TOP

Related Classes of org.codehaus.aspectwerkz.metadata.FieldMetaData$NullFieldMetaData

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.