Package org.codehaus.aspectwerkz.reflect

Examples of org.codehaus.aspectwerkz.reflect.MethodInfo


        MethodInfo[] annotationMethods = annotationClassInfo.getMethods();

        for (int i = 0; i < annotationMethods.length; i++) {

            MethodInfo annotationMethod = annotationMethods[i];

            for (Iterator iterator = annotationMethod.getAnnotations().iterator(); iterator.hasNext();) {

                AnnotationInfo annotationInfo = (AnnotationInfo) iterator.next();

                // handles AnnotationDefault attribute that we have wrapped. See AnnotationDefault.

                if (annotationInfo.getName().equals(AnnotationDefault.NAME)) {

                    Object value = ((AnnotationDefault)annotationInfo.getAnnotation()).value();

                    Object valueHolder = getAnnotationValueHolder(value, loader);

                    annotationElementValueHoldersByName.put(annotationMethod.getName(),

                                                            new AnnotationElement(annotationMethod.getName(),

                                                                                  valueHolder)

                    );
View Full Code Here


     * @return the annotation or null
     */
    public static Annotation getAnnotation(final String annotationName, final Method method) {
        ClassLoader loader = method.getDeclaringClass().getClassLoader();
        ClassInfo classInfo = AsmClassInfo.getClassInfo(method.getDeclaringClass().getName(), loader);
        MethodInfo methodInfo = classInfo.getMethod(ReflectHelper.calculateHash(method));
        return AsmAnnotations.getAnnotation(annotationName, methodInfo);
    }
View Full Code Here

     * @return the annotations in a list (can be empty)
     */
    public static List getAnnotations(final String annotationName, final Method method) {
        ClassLoader loader = method.getDeclaringClass().getClassLoader();
        ClassInfo classInfo = AsmClassInfo.getClassInfo(method.getDeclaringClass().getName(), loader);
        MethodInfo methodInfo = classInfo.getMethod(ReflectHelper.calculateHash(method));
        return AsmAnnotations.getAnnotations(annotationName, methodInfo);
    }
View Full Code Here

     */
    public static List getAnnotationInfos(final Method method) {
        ClassLoader loader = method.getDeclaringClass().getClassLoader();
        ClassInfo classInfo = AsmClassInfo.getClassInfo(method.getDeclaringClass().getName(), loader);
        // AW methods like aw$initJoinPoints may not be visible
        MethodInfo methodInfo = classInfo.getMethod(ReflectHelper.calculateHash(method));
        if (methodInfo != null) {
            return methodInfo.getAnnotations();
        } else {
            return EMPTY_LIST;
        }
    }
View Full Code Here

        // iterate first on all method to lookup @Expression Pointcut annotations so that they can be resolved
        parsePointcutAttributes(methodList, aspectDef);

        // iterate on the advice annotations
        for (Iterator it = methodList.iterator(); it.hasNext();) {
            MethodInfo method = (MethodInfo) it.next();
            try {
                // create the advice name out of the class and method name, <classname>.<methodname>
                parseAroundAttributes(method, aspectName, aspectClassName, aspectDef);
                parseBeforeAttributes(method, aspectName, aspectClassName, aspectDef);
                parseAfterAttributes(method, aspectName, aspectClassName, aspectDef);
View Full Code Here

     * @param methodList
     * @param aspectDef
     */
    private void parsePointcutAttributes(final List methodList, final AspectDefinition aspectDef) {
        for (Iterator it = methodList.iterator(); it.hasNext();) {
            MethodInfo method = (MethodInfo) it.next();

            // Pointcut with signature
            List expressionAnnotations = AsmAnnotations.getAnnotations(AnnotationConstants.EXPRESSION, method);
            for (Iterator iterator = expressionAnnotations.iterator(); iterator.hasNext();) {
                Expression annotation = (Expression) iterator.next();
View Full Code Here

        );
    }

    // Tests: http://jira.codehaus.org/browse/AW-223
    public void testClassAttribute2() throws Exception {
        MethodInfo method = JavaMethodInfo.getMethodInfo(Target.class.getDeclaredMethod("modifiers1", new Class[]{}));
        assertTrue(
                new ExpressionInfo(
                        "execution(void test.expression.*.*(..)) AND within(@Serializable *..*)", NAMESPACE
                ).getExpression().match(new ExpressionContext(PointcutType.EXECUTION, method, s_declaringType))
        );
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))
        );
View Full Code Here

    }

    // ============ cflow type tests =============
    public void testFindCflowPointcut() throws Exception {
        MethodInfo method1 = JavaMethodInfo.getMethodInfo(Target.class.getDeclaredMethod("modifiers1", new Class[]{}));
        MethodInfo method2 = JavaMethodInfo.getMethodInfo(Target.class.getDeclaredMethod("modifiers2", new Class[]{}));
        MethodInfo method3 = JavaMethodInfo.getMethodInfo(Target.class.getDeclaredMethod("modifiers3", new Class[]{}));
        s_namespace.addExpressionInfo(
                "pc1", new ExpressionInfo(
                        "execution(void test.expression.Target.modifiers2())",
                        NAMESPACE
                )
View Full Code Here

        );
        assertTrue(CflowBinding.getCflowBindingsForCflowOf(expression).size() == 0);
    }

    public void testCflowTypes() throws Exception {
        MethodInfo method1 = JavaMethodInfo.getMethodInfo(Target.class.getDeclaredMethod("modifiers1", new Class[]{}));
        MethodInfo method2 = JavaMethodInfo.getMethodInfo(Target.class.getDeclaredMethod("modifiers2", new Class[]{}));
        MethodInfo method3 = JavaMethodInfo.getMethodInfo(Target.class.getDeclaredMethod("modifiers3", new Class[]{}));
        s_namespace.addExpressionInfo(
                "pc1", new ExpressionInfo(
                        "execution(void test.expression.Target.modifiers2())",
                        NAMESPACE
                )
View Full Code Here

TOP

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

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.