use of org.apache.xbean.asm9.MethodVisitor in project tomee by apache.
the class Cmp2Generator method createOpenEJB_removeCmr.
// private void createPrintln(MethodVisitor mv, String message) {
// mv.visitFieldInsn(GETSTATIC, "java/lang/System", "out", "Ljava/io/PrintStream;");
// mv.visitLdcInsn(message);
// mv.visitMethodInsn(INVOKEVIRTUAL, "java/io/PrintStream", "println", "(Ljava/lang/String;)V");
// }
// private void createPrintField(MethodVisitor mv, String fieldName, String descriptor) {
// mv.visitFieldInsn(GETSTATIC, "java/lang/System", "out", "Ljava/io/PrintStream;");
// mv.visitLdcInsn(fieldName + "=");
// mv.visitMethodInsn(INVOKEVIRTUAL, "java/io/PrintStream", "print", "(Ljava/lang/String;)V");
//
// mv.visitFieldInsn(GETSTATIC, "java/lang/System", "out", "Ljava/io/PrintStream;");
// mv.visitVarInsn(ALOAD, 0);
// mv.visitFieldInsn(GETFIELD, implClassName, fieldName, descriptor);
// mv.visitMethodInsn(INVOKEVIRTUAL, "java/io/PrintStream", "println", "(Ljava/lang/Object;)V");
// }
/**
* Emit the remove logic for an individual CMR field.
* Like the addCmr logic, each field is guarded by an
* if test on the property name.
*
* @param mv
* @param cmrField
*/
private void createOpenEJB_removeCmr(final MethodVisitor mv, final CmrField cmrField) {
// if (${cmrField.name}.equals(arg1))
mv.visitLdcInsn(cmrField.getName());
mv.visitVarInsn(ALOAD, 1);
mv.visitMethodInsn(INVOKEVIRTUAL, "java/lang/String", "equals", "(Ljava/lang/Object;)Z", false);
// if not equal jump to end
final Label end = new Label();
mv.visitJumpInsn(IFEQ, end);
// collection valued CMR field. Remove the object from the collection.
if (cmrField.getCmrStyle() != CmrStyle.SINGLE) {
// ${cmrField.name}.remove(arg2)
mv.visitVarInsn(ALOAD, 0);
mv.visitFieldInsn(GETFIELD, implClassName, cmrField.getName(), cmrField.getDescriptor());
mv.visitVarInsn(ALOAD, 2);
mv.visitMethodInsn(INVOKEINTERFACE, cmrField.getCmrStyle().getCollectionType().getInternalName(), "remove", "(Ljava/lang/Object;)Z", true);
mv.visitInsn(POP);
// return;
mv.visitInsn(RETURN);
} else {
// single valued, so just null out the field.
// this.${cmrField.name} = null;
mv.visitVarInsn(ALOAD, 0);
mv.visitInsn(ACONST_NULL);
mv.visitFieldInsn(PUTFIELD, implClassName, cmrField.getName(), cmrField.getDescriptor());
// return;
mv.visitInsn(RETURN);
}
// end of if statement
mv.visitLabel(end);
}
use of org.apache.xbean.asm9.MethodVisitor in project tomee by apache.
the class Cmp2Generator method createEjbStore.
public void createEjbStore() {
final MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, "ejbStore", "()V", null, null);
mv.visitCode();
mv.visitInsn(RETURN);
mv.visitMaxs(0, 1);
mv.visitEnd();
}
use of org.apache.xbean.asm9.MethodVisitor in project tomee by apache.
the class Cmp2Generator method createEjbRemove.
public void createEjbRemove() {
final MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, "ejbRemove", "()V", null, null);
mv.visitCode();
mv.visitInsn(RETURN);
mv.visitMaxs(0, 1);
mv.visitEnd();
}
use of org.apache.xbean.asm9.MethodVisitor in project tomee by apache.
the class Cmp2Generator method createGetter.
/**
* Generate a concrete getter field for a CMP field.
* At this point, we're just generating a simple
* accessor for the field, given the type. The
* JPA engine when it makes this implementation class
* a managed class define whatever additional logic
* might be required.
*
* @param cmpField The CMP field backing this getter method.
*/
private void createGetter(final CmpField cmpField) {
final String methodName = cmpField.getGetterMethod().getName();
final MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, methodName, "()" + cmpField.getDescriptor(), null, null);
mv.visitCode();
mv.visitVarInsn(ALOAD, 0);
mv.visitFieldInsn(GETFIELD, implClassName, cmpField.getName(), cmpField.getDescriptor());
mv.visitInsn(cmpField.getType().getOpcode(IRETURN));
mv.visitMaxs(0, 0);
mv.visitEnd();
}
use of org.apache.xbean.asm9.MethodVisitor in project tomee by apache.
the class Cmp2Generator method createSetEntityContext.
public void createSetEntityContext() {
final MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, "setEntityContext", "(Ljavax/ejb/EntityContext;)V", null, null);
mv.visitCode();
mv.visitInsn(RETURN);
mv.visitMaxs(0, 2);
mv.visitEnd();
}
Aggregations