Package org.codehaus.aspectwerkz.reflect

Examples of org.codehaus.aspectwerkz.reflect.FieldInfo


            return true;
        }
        if (!(o instanceof FieldInfo)) {
            return false;
        }
        FieldInfo fieldInfo = (FieldInfo) o;
        if (!m_declaringTypeName.equals(fieldInfo.getDeclaringType().getName().toString())) {
            return false;
        }
        if (!m_member.name.equals(fieldInfo.getName().toString())) {
            return false;
        }
        ClassInfo fieldType = fieldInfo.getType();
        if (!m_type.getName().toString().equals(fieldType.getName().toString())) {
            return false;
        }
        return true;
    }
View Full Code Here


                        .getWrapperConstructor();
                constructorInfo = JavaConstructorInfo.getConstructorInfo(wrapperConstructor);
                registerJoinPoint(PointcutType.CALL, system, constructorInfo, withinInfo, joinPointMetaDataMap);
                break;
            case JoinPointType.FIELD_SET:
                FieldInfo fieldInfo = JavaFieldInfo
                        .getFieldInfo(AspectRegistry.getField(declaringClass, joinPointHash));
                registerJoinPoint(PointcutType.SET, system, fieldInfo, withinInfo, joinPointMetaDataMap);
                break;
            case JoinPointType.FIELD_GET:
                fieldInfo = JavaFieldInfo.getFieldInfo(AspectRegistry.getField(declaringClass, joinPointHash));
View Full Code Here

    }

    // ============ pointcut type tests =============
    public void testPointcutTypes() throws Exception {
        MethodInfo method = JavaMethodInfo.getMethodInfo(Target.class.getDeclaredMethod("modifiers1", new Class[] {}));
        FieldInfo field = JavaFieldInfo.getFieldInfo(Target.class.getDeclaredField("modifier1"));
        assertTrue(new ExpressionInfo("execution(void test.expression.Target.modifiers1())", NAMESPACE).getExpression()
                .match(new ExpressionContext(PointcutType.EXECUTION, method, null)));
        assertFalse(new ExpressionInfo("execution(void test.expression.Target.modifiers1())", NAMESPACE)
                .getExpression().match(new ExpressionContext(PointcutType.CALL, method, null)));
        assertTrue(new ExpressionInfo("set(int test.expression.Target.modifier1)", NAMESPACE).getExpression().match(
View Full Code Here


            final Type fieldType = Type.getType(fieldDesc);
            final int joinPointHash = AsmHelper.calculateFieldHash(fieldName, fieldDesc);
            final ClassInfo classInfo = AsmClassInfo.getClassInfo(className, m_loader);
            final FieldInfo fieldInfo = getFieldInfo(classInfo, className, fieldName, fieldDesc, joinPointHash);

            if (opcode == PUTFIELD || opcode == PUTSTATIC) {
                handleFieldModification(fieldInfo, opcode, className, fieldName, fieldDesc, joinPointHash);
            } else if (opcode == GETFIELD || opcode == GETSTATIC) {
                handleFieldAccess(fieldInfo, opcode, className, fieldName, fieldDesc, joinPointHash, fieldType);
View Full Code Here

        private FieldInfo getFieldInfo(final ClassInfo classInfo,
                                       final String className,
                                       final String fieldName,
                                       final String fieldDesc,
                                       final int joinPointHash) {
            FieldInfo fieldInfo = classInfo.getField(joinPointHash);
            if (fieldInfo == null) {
                throw new Error(
                        "field info metadata structure could not be build for field: "
                        + className
                        + '.'
View Full Code Here

            if (node.getDeclaringTypePattern().matchType(classInfo)) {
                // we matched but the actual match result may be false
                return Boolean.TRUE;
            }
        } else if (data instanceof FieldInfo) {
            FieldInfo fieldInfo = (FieldInfo) data;
            if (node.getDeclaringTypePattern().matchType(fieldInfo.getDeclaringType())) {
                return null;// it might not match further because of modifiers etc
            }
            return Boolean.FALSE;
        }
        return Boolean.FALSE;
View Full Code Here

                                   final Advice advice,
                                   final FieldInfo[] fields) {
        ExpressionInfo expressionInfo = new ExpressionInfo("set(" + fieldPattern + ')', EXPRESSION_NAMESPACE);
        ExpressionVisitor expression = expressionInfo.getExpression();
        for (int i = 0; i < fields.length; i++) {
            FieldInfo field = fields[i];
            if (field.getName().startsWith(TransformationConstants.SYNTHETIC_MEMBER_PREFIX)) {
                continue;
            }
            if (expression.match(new ExpressionContext(PointcutType.SET, field, null))) {
                int joinPointHash = AsmHelper.calculateFieldHash(field.getName(), field.getSignature());
                addAroundAdvice(advice, joinPointHash);
                addBeforeAdvice(advice, joinPointHash);
                addAfterAdvice(advice, joinPointHash);
                addAfterReturningAdvice(advice, joinPointHash);
                addAfterThrowingAdvice(advice, joinPointHash);
View Full Code Here

                                        final Class adviceClass,
                                        final FieldInfo[] fields) {
        ExpressionInfo expressionInfo = new ExpressionInfo("set(" + fieldPattern + ')', EXPRESSION_NAMESPACE);
        ExpressionVisitor expression = expressionInfo.getExpression();
        for (int i = 0; i < fields.length; i++) {
            FieldInfo field = fields[i];
            if (field.getName().startsWith(TransformationConstants.SYNTHETIC_MEMBER_PREFIX)) {
                continue;
            }
            if (expression.match(new ExpressionContext(PointcutType.SET, field, null))) {
                int joinPointHash = AsmHelper.calculateFieldHash(field.getName(), field.getSignature());
                removeAroundAdvice(adviceClass, joinPointHash);
                removeBeforeAdvice(adviceClass, joinPointHash);
                removeAfterAdvice(adviceClass, joinPointHash);
                removeAfterReturningAdvice(adviceClass, joinPointHash);
                removeAfterThrowingAdvice(adviceClass, joinPointHash);
View Full Code Here

            FieldInfo[] fields = classInfo.getFields();
            if (fields != null) {
                Arrays.sort(
                        fields, new Comparator() {
                            public int compare(Object o1, Object o2) {
                                FieldInfo field1 = (FieldInfo) o1;
                                FieldInfo field2 = (FieldInfo) o2;
                                return field1.getName().compareTo(field2.getName());
                            }
                        }
                );
                for (int i = 0; i < fields.length; i++) {
                    FieldInfo field = fields[i];
                    int mods = field.getModifiers();
                    if (((mods & Constants.ACC_PRIVATE) == 0) ||
                        ((mods & (Constants.ACC_STATIC |
                                  Constants.ACC_TRANSIENT)) == 0)) {
                        out.writeUTF(field.getName());
                        out.writeInt(mods & filterSynthetic());
                        out.writeUTF(field.getSignature());
                    }
                }
            }

            // handle static initialization.
View Full Code Here

     * @return the annotation or null
     */
    public static Annotation getAnnotation(final String annotationName, final Field field) {
        ClassLoader loader = field.getDeclaringClass().getClassLoader();
        ClassInfo classInfo = AsmClassInfo.getClassInfo(field.getDeclaringClass().getName(), loader);
        FieldInfo fieldInfo = classInfo.getField(ReflectHelper.calculateHash(field));
        return AsmAnnotations.getAnnotation(annotationName, fieldInfo);
    }
View Full Code Here

TOP

Related Classes of org.codehaus.aspectwerkz.reflect.FieldInfo

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.