Search in sources :

Example 1 with Type

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

the class JobClassMetaInfoManager method registerJobMetaInfo.

public void registerJobMetaInfo(JobClassMetaInfo metaInfo) {
    String className = Type.getObjectType(metaInfo.className()).getClassName();
    jobs.put(className, metaInfo);
    if (metaInfo.isJob()) {
        Type superType = metaInfo.superType();
        if (!AsmTypes.OBJECT_TYPE.equals(superType)) {
            JobClassMetaInfo superInfo = jobMetaInfo(superType.getClassName());
            if (null == superInfo) {
                List<JobClassMetaInfo> subTypes = subTypeInfo.get(superType);
                if (null == subTypes) {
                    subTypes = new ArrayList<>();
                }
                subTypes.add(metaInfo);
            }
        }
    }
    List<JobClassMetaInfo> subTypes = subTypeInfo.get(metaInfo.type());
    if (null != subTypes) {
        subTypeInfo.remove(metaInfo.type());
    }
    logger.trace("Job meta info registered for: %s", className);
}
Also used : Type(act.asm.Type)

Example 2 with Type

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

the class AsmTypesTest method testMethodDescWithoutReturnType.

@Test
public void testMethodDescWithoutReturnType() throws Exception {
    Method m = AsmTypesTest.class.getDeclaredMethod("testMethodDescWithoutReturnType");
    Type mt = Type.getType(m);
    eq(mt.getDescriptor(), AsmTypes.methodDesc(Void.class));
}
Also used : Type(act.asm.Type) Method(java.lang.reflect.Method) Test(org.junit.Test)

Example 3 with Type

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

the class AsmTypesTest method testMethodDescWithParamAndReturnType.

@Test
public void testMethodDescWithParamAndReturnType() throws Exception {
    Method m = ActionContext.class.getDeclaredMethod("paramVal", String.class);
    Type mt = Type.getType(m);
    eq(mt.getDescriptor(), AsmTypes.methodDesc(String.class, String.class));
}
Also used : Type(act.asm.Type) Method(java.lang.reflect.Method) Test(org.junit.Test)

Example 4 with Type

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

the class SingletonEnhancer method visitAnnotation.

@Override
public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
    Type type = Type.getType(desc);
    if (Singleton.class.getName().equals(type.getClassName())) {
        shouldAddAnnotation = false;
        shouldEnhance = true;
    }
    return super.visitAnnotation(desc, visible);
}
Also used : Type(act.asm.Type) Singleton(javax.inject.Singleton)

Example 5 with Type

use of act.asm.Type 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)

Aggregations

Type (act.asm.Type)5 Method (java.lang.reflect.Method)2 Test (org.junit.Test)2 AnnotationVisitor (act.asm.AnnotationVisitor)1 MethodVisitor (act.asm.MethodVisitor)1 ByteCodeVisitor (act.util.ByteCodeVisitor)1 Singleton (javax.inject.Singleton)1