Package org.codehaus.aspectwerkz.reflect

Examples of org.codehaus.aspectwerkz.reflect.FieldInfo


     * @return the annotations in a list (can be empty)
     */
    public static List getAnnotations(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.getAnnotations(annotationName, fieldInfo);
    }
View Full Code Here


     */
    public static List getAnnotationInfos(final Field field) {
        ClassLoader loader = field.getDeclaringClass().getClassLoader();
        ClassInfo classInfo = AsmClassInfo.getClassInfo(field.getDeclaringClass().getName(), loader);
        // AW fields like aw$instanceLevelAspects may not be visible
        FieldInfo fieldInfo = classInfo.getField(ReflectHelper.calculateHash(field));
        if (fieldInfo != null) {
            return fieldInfo.getAnnotations();
        } else {
            return EMPTY_LIST;
        }
    }
View Full Code Here

            return;
        }

        FieldInfo[] fieldList = classInfo.getFields();
        for (int i = 0; i < fieldList.length; i++) {
            FieldInfo field = fieldList[i];
            for (Iterator iterator = field.getAnnotations().iterator(); iterator.hasNext();) {
                AnnotationInfo annotationInfo = (AnnotationInfo) iterator.next();
                if (annotationInfo.getAnnotation() == null) {
                    continue;
                }
                if (AnnotationConstants.EXPRESSION.equals(annotationInfo.getName())) {
                    if (field.getType().getName().equals(DeploymentScope.class.getName())) {
                        DefinitionParserHelper.createAndAddDeploymentScopeDef(
                                field.getName(),
                                ((Expression) annotationInfo.getAnnotation()).value(),
                                aspectDef.getSystemDefinition()
                        );
                    } else {
                        DefinitionParserHelper.createAndAddPointcutDefToAspectDef(
                                field.getName(),
                                ((Expression) annotationInfo.getAnnotation()).value(),
                                aspectDef
                        );
                    }
                } else if (AnnotationConstants.INTRODUCE.equals(annotationInfo.getName())) {
                    DefinitionParserHelper.createAndAddInterfaceIntroductionDefToAspectDef(
                            ((Introduce) annotationInfo.getAnnotation()).value(),
                            field.getName(),
                            field.getType().getName(),
                            aspectDef
                    );
                }
            }
        }
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(
View Full Code Here

        return Boolean.FALSE;
    }

    public Object visit(ASTFieldPattern node, Object data) {
        if (data instanceof FieldInfo) {
            FieldInfo fieldInfo = (FieldInfo) data;
            if (node.getFieldNamePattern().matches(fieldInfo.getName())
                && node.getDeclaringTypePattern().matchType(fieldInfo.getDeclaringType())
                && node.getFieldTypePattern().matchType(fieldInfo.getType())
                && visitModifiers(node, fieldInfo)) {
                return Boolean.TRUE;
            }
        }
        return Boolean.FALSE;
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

            m_declaringTypeName = name;
            m_mixinFields = new HashMap();

            // populate with fields already present for mixins from previous weaving
            for (int i = 0; i < m_classInfo.getFields().length; i++) {
                FieldInfo fieldInfo = m_classInfo.getFields()[i];
                if (fieldInfo.getName().startsWith(MIXIN_FIELD_NAME)) {
                    m_mixinFields.put(fieldInfo.getType(), fieldInfo);
                }
            }

            // add fields and method for (not already there) mixins
            addMixinMembers();
View Full Code Here

     *
     * @param hash
     * @return
     */
    public FieldInfo getField(final int hash) {
        FieldInfo field = (FieldInfo) m_fields.get(hash);
        if (field == null && getSuperclass() != null) {
            field = getSuperclass().getField(hash);
        }
        return field;
    }
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

     *
     * @param hash
     * @return
     */
    public FieldInfo getField(final int hash) {
        FieldInfo field = (FieldInfo) m_fields.get(hash);
        if (field == null && getSuperclass() != null) {
            field = getSuperclass().getField(hash);
        }
        return field;
    }
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.