use of jodd.asm5.MethodVisitor in project tomee by apache.
the class Cmp2Generator method createEjbActivate.
public void createEjbActivate() {
final MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, "ejbActivate", "()V", null, null);
mv.visitCode();
mv.visitInsn(RETURN);
mv.visitMaxs(0, 1);
mv.visitEnd();
}
use of jodd.asm5.MethodVisitor in project tomee by apache.
the class Cmp2Generator method createCmrSetter.
/**
* Generate a setter method for a CMR field. The
* setter method will delegate the setting responsibility
* to the accessor object store the associated Cmr field.
*
* @param cmrField The field we're generating the setter for.
*/
private void createCmrSetter(final CmrField cmrField) {
// no back reference. We don't generate a getter method for this
if (cmrField.isSynthetic()) {
return;
}
final String methodName = setterName(cmrField.getName());
final MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, methodName, "(" + cmrField.getProxyDescriptor() + ")V", null, null);
mv.visitCode();
// the Set with the new values from the new value source.
if (cmrField.getCmrStyle() != CmrStyle.SINGLE) {
mv.visitVarInsn(ALOAD, 0);
mv.visitFieldInsn(GETFIELD, implClassName, cmrField.getName() + "Cmr", cmrField.getAccessorDescriptor());
mv.visitVarInsn(ALOAD, 0);
mv.visitFieldInsn(GETFIELD, implClassName, cmrField.getName(), cmrField.getDescriptor());
mv.visitVarInsn(ALOAD, 1);
mv.visitMethodInsn(INVOKEVIRTUAL, cmrField.getAccessorInternalName(), "set", cmrField.getCmrStyle().getSetterDescriptor(), false);
mv.visitInsn(RETURN);
} else {
// this is a single value. We pass the existing value and the old value to
// the accessor, then must cast the accessor return value to the target type
// so we can store it in the real CMR field.
mv.visitVarInsn(ALOAD, 0);
mv.visitVarInsn(ALOAD, 0);
mv.visitFieldInsn(GETFIELD, implClassName, cmrField.getName() + "Cmr", cmrField.getAccessorDescriptor());
mv.visitVarInsn(ALOAD, 0);
mv.visitFieldInsn(GETFIELD, implClassName, cmrField.getName(), cmrField.getDescriptor());
mv.visitVarInsn(ALOAD, 1);
mv.visitMethodInsn(INVOKEVIRTUAL, cmrField.getAccessorInternalName(), "set", cmrField.getCmrStyle().getSetterDescriptor(), false);
mv.visitTypeInsn(CHECKCAST, cmrField.getType().getInternalName());
mv.visitFieldInsn(PUTFIELD, implClassName, cmrField.getName(), cmrField.getDescriptor());
mv.visitInsn(RETURN);
}
mv.visitMaxs(0, 0);
mv.visitEnd();
}
use of jodd.asm5.MethodVisitor in project tomee by apache.
the class Cmp2Generator method createUnsetEntityContext.
public void createUnsetEntityContext() {
final MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, "unsetEntityContext", "()V", null, null);
mv.visitCode();
mv.visitInsn(RETURN);
mv.visitMaxs(0, 1);
mv.visitEnd();
}
use of jodd.asm5.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 jodd.asm5.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();
}
Aggregations