Search in sources :

Example 6 with MethodVisitor

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();
}
Also used : MethodVisitor(org.apache.xbean.asm5.MethodVisitor)

Example 7 with MethodVisitor

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();
}
Also used : MethodVisitor(org.apache.xbean.asm5.MethodVisitor)

Example 8 with MethodVisitor

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();
}
Also used : MethodVisitor(org.apache.xbean.asm5.MethodVisitor)

Example 9 with MethodVisitor

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();
}
Also used : MethodVisitor(org.apache.xbean.asm5.MethodVisitor)

Example 10 with MethodVisitor

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();
}
Also used : MethodVisitor(org.apache.xbean.asm5.MethodVisitor)

Aggregations

MethodVisitor (org.apache.xbean.asm5.MethodVisitor)28 MethodVisitor (jodd.asm5.MethodVisitor)6 ClassWriter (org.apache.xbean.asm5.ClassWriter)6 Label (org.apache.xbean.asm5.Label)5 Method (java.lang.reflect.Method)3 ArrayList (java.util.ArrayList)2 Arrays.asList (java.util.Arrays.asList)2 HashMap (java.util.HashMap)2 List (java.util.List)2 Map (java.util.Map)2 EmptyClassVisitor (jodd.asm.EmptyClassVisitor)2 EmptyMethodVisitor (jodd.asm.EmptyMethodVisitor)2 Label (jodd.asm5.Label)2 Field (java.lang.reflect.Field)1 MethodAdapter (jodd.asm.MethodAdapter)1 FieldVisitor (jodd.asm5.FieldVisitor)1 Type (jodd.asm5.Type)1 ProxettaException (jodd.proxetta.ProxettaException)1 Type (org.apache.xbean.asm5.Type)1