use of act.asm.AnnotationVisitor in project act-ebean by actframework.
the class ModelBaseEnhancer method addAnnotation.
private void addAnnotation() {
AnnotationVisitor av = visitAnnotation(Type.getType(MappedSuperclass.class).getDescriptor(), true);
av.visitEnd();
}
use of act.asm.AnnotationVisitor in project actframework by actframework.
the class MetricContextScanner method byteCodeVisitor.
@Override
public ByteCodeVisitor byteCodeVisitor() {
return new ByteCodeVisitor() {
private String className;
@Override
public void visit(int version, int access, String name, String signature, String superName, String[] interfaces) {
super.visit(version, access, name, signature, superName, interfaces);
className = Type.getObjectType(name).getClassName();
}
@Override
public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
AnnotationVisitor av = super.visitAnnotation(desc, visible);
if (DESC_METRIC_CONTEXT.equals(desc)) {
return new AnnotationVisitor(ASM5, av) {
@Override
public void visit(String name, Object value) {
super.visit(name, value);
if ("value".equals(name)) {
repo.registerMetricContext(className, value.toString());
}
}
};
}
return av;
}
};
}
use of act.asm.AnnotationVisitor in project actframework by actframework.
the class ConfigurationByteCodeScanner method byteCodeVisitor.
@Override
public ByteCodeVisitor byteCodeVisitor() {
return new ByteCodeVisitor() {
@Override
public FieldVisitor visitField(int access, final String name, String desc, String signature, Object value) {
FieldVisitor fv = super.visitField(access, name, desc, signature, value);
boolean isStatic = AsmTypes.isStatic(access);
if (!isStatic) {
return fv;
}
final String fieldName = name;
return new FieldVisitor(ASM5, fv) {
@Override
public AnnotationVisitor visitAnnotation(String desc, boolean visible) {
AnnotationVisitor av = super.visitAnnotation(desc, visible);
if (S.eq(CONF_DESC, desc)) {
return new AnnotationVisitor(ASM5, av) {
@Override
public void visit(String name, Object value) {
staticConfigurationFields.put(fieldName, S.string(value));
super.visit(name, value);
}
};
}
return av;
}
};
}
};
}
use of act.asm.AnnotationVisitor in project actframework by actframework.
the class CommanderEnhancer 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);
if (null == metaInfo || isConstructor(name)) {
return mv;
}
final CommandMethodMetaInfo methodInfo = metaInfo.command(name);
if (null == methodInfo) {
return mv;
}
if (isPublic(access) && !isConstructor(name)) {
return new MethodVisitor(ASM5, mv) {
private Set<Integer> skipNaming = new HashSet<Integer>();
@Override
public AnnotationVisitor visitParameterAnnotation(int parameter, String desc, boolean visible) {
if ("Ljavax/inject/Named;".equals(desc)) {
skipNaming.add(parameter);
}
return super.visitParameterAnnotation(parameter, desc, visible);
}
@Override
public void visitEnd() {
int sz = methodInfo.paramCount();
for (int i = 0; i < sz; ++i) {
if (!skipNaming.contains(i)) {
String name = methodInfo.param(i).name();
AnnotationVisitor av = mv.visitParameterAnnotation(i, "Ljavax/inject/Named;", true);
av.visit("value", name);
}
}
super.visitEnd();
}
};
}
return mv;
}
use of act.asm.AnnotationVisitor in project act-ebean by actframework.
the class TimestampAuditorEnhancer method visitField.
@Override
public FieldVisitor visitField(int access, String name, String desc, String signature, Object value) {
FieldVisitor fv = super.visitField(access, name, desc, signature, value);
if (null == createdAt && null == lastModifiedAt) {
return fv;
}
final boolean isCreatedAt = name.equals(createdAt);
final boolean isLastModified = !isCreatedAt && name.equals(lastModifiedAt);
if (!isCreatedAt && !isLastModified) {
return fv;
}
return new FieldVisitor(ASM5, fv) {
@Override
public void visitEnd() {
AnnotationVisitor av;
if (isCreatedAt) {
av = fv.visitAnnotation("Lcom/avaje/ebean/annotation/WhenCreated;", true);
} else {
av = fv.visitAnnotation("Lcom/avaje/ebean/annotation/WhenModified;", true);
}
av.visitEnd();
super.visitEnd();
}
};
}
Aggregations