Search in sources :

Example 1 with ProxyGenerationException

use of org.apache.openejb.util.proxy.ProxyGenerationException in project tomee by apache.

the class DynamicSubclass method copyMethodAnnotations.

private static void copyMethodAnnotations(final Class<?> classToProxy, final Map<String, MethodVisitor> visitors) throws ProxyGenerationException {
    // Move all the annotations onto the newly implemented methods
    // Ensures CDI and JAX-RS and JAX-WS still work
    Class clazz = classToProxy;
    while (clazz != null && !clazz.equals(Object.class)) {
        try {
            final ClassReader classReader = new ClassReader(readClassFile(clazz));
            final ClassVisitor copyMethodAnnotations = new CopyMethodAnnotations(visitors);
            classReader.accept(copyMethodAnnotations, ClassReader.SKIP_CODE);
        } catch (final IOException e) {
            throw new ProxyGenerationException(e);
        }
        clazz = clazz.getSuperclass();
    }
}
Also used : ProxyGenerationException(org.apache.openejb.util.proxy.ProxyGenerationException) ClassReader(org.apache.xbean.asm5.ClassReader) ClassVisitor(org.apache.xbean.asm5.ClassVisitor) IOException(java.io.IOException)

Example 2 with ProxyGenerationException

use of org.apache.openejb.util.proxy.ProxyGenerationException in project tomee by apache.

the class DynamicSubclass method copyClassAnnotations.

private static void copyClassAnnotations(final Class<?> clazz, final ClassVisitor newClass) throws ProxyGenerationException {
    try {
        final ClassReader classReader = new ClassReader(readClassFile(clazz));
        final ClassVisitor visitor = new CopyClassAnnotations(newClass);
        classReader.accept(visitor, ClassReader.SKIP_CODE);
    } catch (final IOException e) {
        throw new ProxyGenerationException(e);
    }
}
Also used : ProxyGenerationException(org.apache.openejb.util.proxy.ProxyGenerationException) ClassReader(org.apache.xbean.asm5.ClassReader) ClassVisitor(org.apache.xbean.asm5.ClassVisitor) IOException(java.io.IOException)

Aggregations

IOException (java.io.IOException)2 ProxyGenerationException (org.apache.openejb.util.proxy.ProxyGenerationException)2 ClassReader (org.apache.xbean.asm5.ClassReader)2 ClassVisitor (org.apache.xbean.asm5.ClassVisitor)2