Search in sources :

Example 1 with AnnotationInfo

use of jodd.proxetta.AnnotationInfo in project jodd by oblac.

the class TargetClassInfoReader method visitEnd.

/**
	 * Stores signatures for all super public methods not already overridden by target class.
	 * All this methods will be accepted for proxyfication.
	 */
@Override
public void visitEnd() {
    // prepare class annotations
    if (classAnnotations != null) {
        annotations = classAnnotations.toArray(new AnnotationInfo[classAnnotations.size()]);
        classAnnotations = null;
    }
    List<String> superList = new ArrayList<>();
    Set<String> allInterfaces = new HashSet<>();
    if (nextInterfaces != null) {
        allInterfaces.addAll(nextInterfaces);
    }
    // check all public super methods that are not overridden in superclass
    while (nextSupername != null) {
        InputStream inputStream = null;
        ClassReader cr = null;
        try {
            inputStream = ClassLoaderUtil.getClassAsStream(nextSupername, classLoader);
            cr = new ClassReader(inputStream);
        } catch (IOException ioex) {
            throw new ProxettaException("Unable to inspect super class: " + nextSupername, ioex);
        } finally {
            StreamUtil.close(inputStream);
        }
        superList.add(nextSupername);
        // remember the super class reader
        superClassReaders.add(cr);
        cr.accept(new SuperClassVisitor(), 0);
        if (cr.getInterfaces() != null) {
            Collections.addAll(allInterfaces, cr.getInterfaces());
        }
    }
    superClasses = superList.toArray(new String[superList.size()]);
    // check all interface methods that are not overridden in super-interface
    for (String next : allInterfaces) {
        InputStream inputStream = null;
        ClassReader cr = null;
        try {
            inputStream = ClassLoaderUtil.getClassAsStream(next, classLoader);
            cr = new ClassReader(inputStream);
        } catch (IOException ioex) {
            throw new ProxettaException("Unable to inspect super interface: " + next, ioex);
        } finally {
            StreamUtil.close(inputStream);
        }
        // remember the super class reader
        superClassReaders.add(cr);
        cr.accept(new SuperClassVisitor(), 0);
    }
}
Also used : ProxettaException(jodd.proxetta.ProxettaException) InputStream(java.io.InputStream) ArrayList(java.util.ArrayList) ClassReader(jodd.asm5.ClassReader) IOException(java.io.IOException) AnnotationInfo(jodd.proxetta.AnnotationInfo) HashSet(java.util.HashSet)

Example 2 with AnnotationInfo

use of jodd.proxetta.AnnotationInfo in project jodd by oblac.

the class ProxyPointcutSupport method getAnnotation.

/**
	 * Returns <code>true</code> if method is annotated with provided annotation.
	 */
public AnnotationInfo getAnnotation(MethodInfo methodInfo, Class<? extends Annotation> mi) {
    AnnotationInfo[] anns = methodInfo.getAnnotations();
    if (anns == null) {
        return null;
    }
    String anName = mi.getName();
    for (AnnotationInfo ann : anns) {
        if (ann.getAnnotationClassname().equals(anName)) {
            return ann;
        }
    }
    return null;
}
Also used : AnnotationInfo(jodd.proxetta.AnnotationInfo)

Example 3 with AnnotationInfo

use of jodd.proxetta.AnnotationInfo in project jodd by oblac.

the class ProxyPointcutSupport method getAnnotation.

/**
	 * Finds annotation in class info. Returns <code>null</code> if annotation doesn't exist.
	 */
public AnnotationInfo getAnnotation(ClassInfo classInfo, Class<? extends Annotation> an) {
    AnnotationInfo[] anns = classInfo.getAnnotations();
    if (anns == null) {
        return null;
    }
    String anName = an.getName();
    for (AnnotationInfo ann : anns) {
        if (ann.getAnnotationClassname().equals(anName)) {
            return ann;
        }
    }
    return null;
}
Also used : AnnotationInfo(jodd.proxetta.AnnotationInfo)

Aggregations

AnnotationInfo (jodd.proxetta.AnnotationInfo)3 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 ClassReader (jodd.asm5.ClassReader)1 ProxettaException (jodd.proxetta.ProxettaException)1