Search in sources :

Example 11 with AnnotationVisitor

use of org.mvel2.asm.AnnotationVisitor in project drools by kiegroup.

the class DefaultBeanClassBuilder method buildClassAnnotations.

protected void buildClassAnnotations(ClassDefinition classDef, ClassVisitor cw) {
    for (AnnotationDefinition ad : classDef.getAnnotations()) {
        AnnotationVisitor av = cw.visitAnnotation("L" + BuildUtils.getInternalType(ad.getName()) + ";", true);
        addAnnotationAttribute(ad, av);
        av.visitEnd();
    }
}
Also used : AnnotationDefinition(org.drools.core.factmodel.AnnotationDefinition) AnnotationVisitor(org.mvel2.asm.AnnotationVisitor)

Example 12 with AnnotationVisitor

use of org.mvel2.asm.AnnotationVisitor in project drools by kiegroup.

the class DefaultBeanClassBuilder method addAnnotationAttribute.

public static void addAnnotationAttribute(AnnotationDefinition ad, AnnotationVisitor av) {
    for (String key : ad.getValues().keySet()) {
        AnnotationDefinition.AnnotationPropertyVal apv = ad.getValues().get(key);
        switch(apv.getValType()) {
            case STRINGARRAY:
                AnnotationVisitor subAv = av.visitArray(apv.getProperty());
                Object[] array = (Object[]) apv.getValue();
                for (Object o : array) {
                    subAv.visit(null, o);
                }
                subAv.visitEnd();
                break;
            case PRIMARRAY:
                av.visit(apv.getProperty(), apv.getValue());
                break;
            case ENUMARRAY:
                AnnotationVisitor subEnav = av.visitArray(apv.getProperty());
                Enum[] enArray = (Enum[]) apv.getValue();
                String aenumType = "L" + BuildUtils.getInternalType(enArray[0].getClass().getName()) + ";";
                for (Enum enumer : enArray) {
                    subEnav.visitEnum(null, aenumType, enumer.name());
                }
                subEnav.visitEnd();
                break;
            case CLASSARRAY:
                AnnotationVisitor subKlav = av.visitArray(apv.getProperty());
                Class[] klarray = (Class[]) apv.getValue();
                for (Class klass : klarray) {
                    subKlav.visit(null, Type.getType("L" + BuildUtils.getInternalType(klass.getName()) + ";"));
                }
                subKlav.visitEnd();
                break;
            case ENUMERATION:
                String enumType = "L" + BuildUtils.getInternalType(apv.getType().getName()) + ";";
                av.visitEnum(apv.getProperty(), enumType, ((Enum) apv.getValue()).name());
                break;
            case KLASS:
                String klassName = BuildUtils.getInternalType(((Class) apv.getValue()).getName());
                av.visit(apv.getProperty(), Type.getType("L" + klassName + ";"));
                break;
            case PRIMITIVE:
                av.visit(apv.getProperty(), apv.getValue());
                break;
            case STRING:
                av.visit(apv.getProperty(), apv.getValue());
                break;
        }
    }
}
Also used : AnnotationDefinition(org.drools.core.factmodel.AnnotationDefinition) AnnotationVisitor(org.mvel2.asm.AnnotationVisitor) ReactiveObject(org.drools.core.phreak.ReactiveObject)

Example 13 with AnnotationVisitor

use of org.mvel2.asm.AnnotationVisitor in project mvel by mvel.

the class TraceAnnotationVisitor method visitArray.

@Override
public AnnotationVisitor visitArray(final String name) {
    Printer p = this.p.visitArray(name);
    AnnotationVisitor av = this.av == null ? null : this.av.visitArray(name);
    return new TraceAnnotationVisitor(av, p);
}
Also used : AnnotationVisitor(org.mvel2.asm.AnnotationVisitor)

Example 14 with AnnotationVisitor

use of org.mvel2.asm.AnnotationVisitor in project mvel by mvel.

the class TraceAnnotationVisitor method visitAnnotation.

@Override
public AnnotationVisitor visitAnnotation(final String name, final String desc) {
    Printer p = this.p.visitAnnotation(name, desc);
    AnnotationVisitor av = this.av == null ? null : this.av.visitAnnotation(name, desc);
    return new TraceAnnotationVisitor(av, p);
}
Also used : AnnotationVisitor(org.mvel2.asm.AnnotationVisitor)

Example 15 with AnnotationVisitor

use of org.mvel2.asm.AnnotationVisitor in project mvel by mvel.

the class TraceFieldVisitor method visitTypeAnnotation.

@Override
public AnnotationVisitor visitTypeAnnotation(int typeRef, TypePath typePath, String desc, boolean visible) {
    Printer p = this.p.visitFieldTypeAnnotation(typeRef, typePath, desc, visible);
    AnnotationVisitor av = fv == null ? null : fv.visitTypeAnnotation(typeRef, typePath, desc, visible);
    return new TraceAnnotationVisitor(av, p);
}
Also used : AnnotationVisitor(org.mvel2.asm.AnnotationVisitor)

Aggregations

AnnotationVisitor (org.mvel2.asm.AnnotationVisitor)26 AnnotationDefinition (org.drools.core.factmodel.AnnotationDefinition)5 ClassWriter (org.mvel2.asm.ClassWriter)4 Type (org.mvel2.asm.Type)3 Externalizable (java.io.Externalizable)2 IOException (java.io.IOException)2 ObjectInput (java.io.ObjectInput)2 ObjectOutput (java.io.ObjectOutput)2 Serializable (java.io.Serializable)2 Constructor (java.lang.reflect.Constructor)2 Method (java.lang.reflect.Method)2 BitSet (java.util.BitSet)2 Collection (java.util.Collection)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 Set (java.util.Set)2 FieldDefinition (org.drools.core.factmodel.FieldDefinition)2 GeneratedFact (org.drools.core.factmodel.GeneratedFact)2 ReactiveObject (org.drools.core.phreak.ReactiveObject)2 ClassGenerator.createClassWriter (org.drools.core.rule.builder.dialect.asm.ClassGenerator.createClassWriter)2