Package org.codehaus.aspectwerkz.reflect

Examples of org.codehaus.aspectwerkz.reflect.MethodInfo


            if (node.getDeclaringTypePattern().matchType(classInfo)) {
                return Boolean.TRUE;
            }
            return Boolean.FALSE;
        } else if (data instanceof MethodInfo) {
            MethodInfo methodInfo = (MethodInfo) data;
            if (node.getDeclaringTypePattern().matchType(methodInfo.getDeclaringType())) {
                return null;// it might not match further because of modifiers etc
            }
            return Boolean.FALSE;
        }
        return Boolean.FALSE;
View Full Code Here


        final Class clazz = Virtual.class;
        final String aspectName = clazz.getName();
        ClassInfo aspectClassInfo = JavaClassInfo.getClassInfo(clazz);
        final AspectDefinition aspectDef = new AspectDefinition(aspectName, aspectClassInfo, definition);
        try {
            MethodInfo methodInfo = JavaMethodInfo.getMethodInfo(clazz.getDeclaredMethod("virtual", new Class[]{}));
            aspectDef.addBeforeAdviceDefinition(
                    new AdviceDefinition(
                            methodInfo.getName(),
                            AdviceType.BEFORE,
                            null,
                            aspectName,
                            aspectName,
                            null,
View Full Code Here

                String type = adviceElement.attributeValue("type");
                String bindTo = adviceElement.attributeValue("bind-to");

                //FIXME is that comment OK ? if so remove - need to dig the consequence
                String adviceName = /*aspectClassInfo.getName() + '.' +*/ name;
                MethodInfo method = null;
                for (Iterator it3 = methodList.iterator(); it3.hasNext();) {
                    MethodInfo methodCurrent = (MethodInfo) it3.next();
                    if (aspectDef.isAspectWerkzAspect()) {
                        if (matchMethodAsAdvice(methodCurrent, name)) {
                            method = methodCurrent;
                            break;
                        }
                    } else {
                        // TODO support matchMethodAsAdvice(..) for all aspect models? if so use stuff below
//                        AspectModel aspectModel = AspectModelManager.getModelFor(aspectDef.getAspectModel());
//                        if (aspectModel.matchMethodAsAdvice(methodCurrent, name)) {
//                            method = methodCurrent;
//                            break;
//                        }
                        if (methodCurrent.getName().equals(name)) {
                            method = methodCurrent;
                            break;
                        }
                    }
                }
View Full Code Here

                                    final Advice advice,
                                    final MethodInfo[] methods) {
        ExpressionInfo expressionInfo = new ExpressionInfo("execution(" + methodPattern + ')', EXPRESSION_NAMESPACE);
        ExpressionVisitor expression = expressionInfo.getExpression();
        for (int i = 0; i < methods.length; i++) {
            MethodInfo method = methods[i];
            if (method.getName().startsWith(TransformationConstants.SYNTHETIC_MEMBER_PREFIX)) {
                continue;
            }
            if (expression.match(new ExpressionContext(PointcutType.EXECUTION, method, null))) {
                int joinPointHash = AsmHelper.calculateMethodHash(method.getName(), method.getSignature());
                addAroundAdvice(advice, joinPointHash);
                addBeforeAdvice(advice, joinPointHash);
                addAfterAdvice(advice, joinPointHash);
                addAfterReturningAdvice(advice, joinPointHash);
                addAfterThrowingAdvice(advice, joinPointHash);
View Full Code Here

                                         final Class adviceClass,
                                         final MethodInfo[] methods) {
        ExpressionInfo expressionInfo = new ExpressionInfo("execution(" + methodPattern + ')', EXPRESSION_NAMESPACE);
        ExpressionVisitor expression = expressionInfo.getExpression();
        for (int i = 0; i < methods.length; i++) {
            MethodInfo method = methods[i];
            if (method.getName().startsWith(TransformationConstants.SYNTHETIC_MEMBER_PREFIX)) {
                continue;
            }
            if (expression.match(new ExpressionContext(PointcutType.EXECUTION, method, null))) {
                int joinPointHash = AsmHelper.calculateMethodHash(method.getName(), method.getSignature());
                removeAroundAdvice(adviceClass, joinPointHash);
                removeBeforeAdvice(adviceClass, joinPointHash);
                removeAfterAdvice(adviceClass, joinPointHash);
                removeAfterReturningAdvice(adviceClass, joinPointHash);
                removeAfterThrowingAdvice(adviceClass, joinPointHash);
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

     */
    private AdviceDefinition handleAdviceInfo(final ClassInfo classInfo,
                                              final AspectDefinition aspectDef,
                                              final AdviceInfo ajAdviceInfo) {

        MethodInfo adviceMethod = null;
        MethodInfo[] methods = classInfo.getMethods();
        for (int i = 0; i < methods.length; i++) {
            MethodInfo method = methods[i];
            if (method.getName().equals(ajAdviceInfo.adviceMethodName)) {
                adviceMethod = method;
                break;
            }
        }
        if (adviceMethod == null) {
View Full Code Here

            name.startsWith(WRAPPER_METHOD_PREFIX)) {
            return cv.visitMethod(access, name, desc, exceptions, attrs);
        }

        int hash = AsmHelper.calculateMethodHash(name, desc);
        MethodInfo methodInfo = m_classInfo.getMethod(hash);
        if (methodInfo == null) {
            System.err.println(
                    "AW::WARNING " +
                    "metadata structure could not be build for method ["
                    + m_classInfo.getName().replace('/', '.')
View Full Code Here

            // handle regular methods.
            Arrays.sort(
                    methods, new Comparator() {
                        public int compare(Object o1, Object o2) {
                            try {
                                MethodInfo m1 = (MethodInfo) o1;
                                MethodInfo m2 = (MethodInfo) o2;
                                int value = m1.getName().compareTo(m2.getName());
                                if (value == 0) {
                                    value = m1.getSignature().compareTo(m2.getSignature());
                                }
                                return value;
                            } catch (Exception e) {
                                throw new WrappedRuntimeException(e);
                            }
                        }
                    }
            );
            for (int i = 0; i < methods.length; i++) {
                MethodInfo method = methods[i];
                int mods = method.getModifiers();
                if ((mods & Constants.ACC_PRIVATE) == 0) {
                    out.writeUTF(method.getName());
                    out.writeInt(mods & filterSynthetic());
                    out.writeUTF(method.getSignature().replace('/', '.'));
                }
            }

            // calculate hash.
            out.flush();
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.