Search in sources :

Example 6 with MethodVisitor

use of act.asm.MethodVisitor in project actframework by actframework.

the class GenieFactoryFinder method byteCodeVisitor.

@Override
public ByteCodeVisitor byteCodeVisitor() {
    return new ByteCodeVisitor() {

        private boolean isPublic;

        @Override
        public void visit(int version, int access, String name, String signature, String superName, String[] interfaces) {
            super.visit(version, access, name, signature, superName, interfaces);
            isPublic = AsmTypes.isPublic(access);
            isModule = Module.class.getName().equals(Type.getObjectType(superName).getClassName());
        }

        @Override
        public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
            MethodVisitor mv = super.visitMethod(access, name, desc, signature, exceptions);
            return !isPublic || isModule || isFactory ? mv : new MethodVisitor(ASM5, mv) {

                @Override
                public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
                    Type annoType = Type.getType(desc);
                    if (AsmTypes.PROVIDES.asmType().equals(annoType)) {
                        isFactory = true;
                    }
                    return super.visitAnnotation(desc, visible);
                }
            };
        }
    };
}
Also used : Type(act.asm.Type) ByteCodeVisitor(act.util.ByteCodeVisitor) AnnotationVisitor(act.asm.AnnotationVisitor) MethodVisitor(act.asm.MethodVisitor)

Example 7 with MethodVisitor

use of act.asm.MethodVisitor in project actframework by actframework.

the class MailerEnhancer method visitMethod.

@Override
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
    MethodVisitor mv = super.visitMethod(access, name, desc, signature, exceptions);
    SenderMethodMetaInfo info = methodInfo(name, access);
    if (null == info) {
        return mv;
    }
    logger.debug(">>>About to enhance mailer method: %s", name);
    return new SenderEnhancer(mv, info, access, name, desc, signature, exceptions);
}
Also used : SenderMethodMetaInfo(act.mail.meta.SenderMethodMetaInfo) MethodVisitor(act.asm.MethodVisitor)

Aggregations

MethodVisitor (act.asm.MethodVisitor)7 AnnotationVisitor (act.asm.AnnotationVisitor)2 ClassWriter (act.asm.ClassWriter)1 Type (act.asm.Type)1 GeneratorAdapter (act.asm.commons.GeneratorAdapter)1 Method (act.asm.commons.Method)1 CommandMethodMetaInfo (act.cli.meta.CommandMethodMetaInfo)1 HandlerMethodMetaInfo (act.controller.meta.HandlerMethodMetaInfo)1 SenderMethodMetaInfo (act.mail.meta.SenderMethodMetaInfo)1 ByteCodeVisitor (act.util.ByteCodeVisitor)1 FileOutputStream (java.io.FileOutputStream)1 PrintStream (java.io.PrintStream)1 HashSet (java.util.HashSet)1 Set (java.util.Set)1