Top Description Fields Constructors Methods
org.eclipse.persistence.internal.jpa.weaving

public Class MethodWeaver

extends EclipseLinkMethodVisitor
Class Inheritance
Imports
org.eclipse.persistence.asm.ASMFactory, .AnnotationVisitor, .Attribute, .Label, .EclipseLinkMethodVisitor, .MethodVisitor, .Opcodes, .Type, org.eclipse.persistence.internal.descriptors.VirtualAttributeMethodInfo

Processes all the methods of a class to weave in persistence code such as, lazy value holder, change tracking and fetch groups. For FIELD access, changes references to GETFIELD and PUTFIELD to call weaved get/set methods. For Property access, modifies the getters and setters.

Field Summary

Modifier and TypeField and Description
protected String
protected String
protected boolean
methodStarted

Determines if we are at the first line of a method.

protected ClassWeaver
Inherited from org.eclipse.persistence.asm.EclipseLinkMethodVisitor:
methodVisitor

Constructor Summary

AccessConstructor and Description
public
MethodWeaver(ClassWeaver tcw, String methodName, String methodDescriptor, MethodVisitor mv)

Method Summary

Modifier and TypeMethod and Description
public AnnotationVisitor
public void
public void
public void
visitFieldInsn(final int opcode, final String owner, final String name, final String desc)

Overrides org.eclipse.persistence.asm.EclipseLinkMethodVisitor.visitFieldInsn.

public void
public void
public void
public void
public void
public void
public void
public void
visitLocalVariable(final String name, final String desc, String signature, final Label start, final Label end, final int index)

Overrides org.eclipse.persistence.asm.EclipseLinkMethodVisitor.visitLocalVariable.

public void
public void
visitMaxs(final int maxStack, final int maxLocals)

Overrides org.eclipse.persistence.asm.EclipseLinkMethodVisitor.visitMaxs.

public void
visitMethodInsn(final int opcode, final String owner, final String name, final String desc, boolean intf)

Overrides org.eclipse.persistence.asm.EclipseLinkMethodVisitor.visitMethodInsn.

public void
public void
visitTableSwitchInsn(final int min, final int max, final Label dflt, final Label... labels)

Overrides org.eclipse.persistence.asm.EclipseLinkMethodVisitor.visitTableSwitchInsn.

public void
public void
public void
public void
weaveAttributesIfRequired(int opcode, String owner, String name, String desc)

Change GETFIELD and PUTFIELD for fields that use attribute access to make use of new convenience methods.

public void
weaveBeginningOfMethodIfRequired()

Makes modifications to the beginning of a method.

public void
weaveEndOfMethodIfRequired()

Modifies methods just before the return.

Inherited from org.eclipse.persistence.asm.EclipseLinkMethodVisitor:
unwrapvisitAnnotationSupervisitAttributeSupervisitCodevisitFieldInsnSupervisitFramevisitIincInsnSupervisitInsnSupervisitIntInsnSupervisitJumpInsnSupervisitLabelSupervisitLdcInsnSupervisitLineNumberSupervisitLocalVariableSupervisitLookupSwitchInsnSupervisitMaxsSupervisitMethodInsnSupervisitMultiANewArrayInsnSupervisitTableSwitchInsnSupervisitTryCatchBlockSupervisitTypeInsnSupervisitVarInsnSuper

Field Detail

methodDescriptorback to summary
protected String methodDescriptor
methodNameback to summary
protected String methodName
methodStartedback to summary
protected boolean methodStarted

Determines if we are at the first line of a method.

tcwback to summary
protected ClassWeaver tcw

Constructor Detail

MethodWeaverback to summary
public MethodWeaver(ClassWeaver tcw, String methodName, String methodDescriptor, MethodVisitor mv)

Method Detail

visitAnnotationback to summary
public AnnotationVisitor visitAnnotation(String desc, boolean visible)

Overrides org.eclipse.persistence.asm.EclipseLinkMethodVisitor.visitAnnotation.

Annotations
@Override
visitAttributeback to summary
public void visitAttribute(final Attribute attr)

Overrides org.eclipse.persistence.asm.EclipseLinkMethodVisitor.visitAttribute.

Annotations
@Override
visitEndback to summary
public void visitEnd()

Overrides org.eclipse.persistence.asm.EclipseLinkMethodVisitor.visitEnd.

Annotations
@Override
visitFieldInsnback to summary
public void visitFieldInsn(final int opcode, final String owner, final String name, final String desc)

Overrides org.eclipse.persistence.asm.EclipseLinkMethodVisitor.visitFieldInsn.

Annotations
@Override
visitIincInsnback to summary
public void visitIincInsn(final int var, final int increment)

Overrides org.eclipse.persistence.asm.EclipseLinkMethodVisitor.visitIincInsn.

Annotations
@Override
visitInsnback to summary
public void visitInsn(final int opcode)

Overrides org.eclipse.persistence.asm.EclipseLinkMethodVisitor.visitInsn.

Annotations
@Override
visitIntInsnback to summary
public void visitIntInsn(final int opcode, final int operand)

Overrides org.eclipse.persistence.asm.EclipseLinkMethodVisitor.visitIntInsn.

Annotations
@Override
visitJumpInsnback to summary
public void visitJumpInsn(final int opcode, final Label label)

Overrides org.eclipse.persistence.asm.EclipseLinkMethodVisitor.visitJumpInsn.

Annotations
@Override
visitLabelback to summary
public void visitLabel(final Label label)

Overrides org.eclipse.persistence.asm.EclipseLinkMethodVisitor.visitLabel.

Annotations
@Override
visitLdcInsnback to summary
public void visitLdcInsn(final Object cst)

Overrides org.eclipse.persistence.asm.EclipseLinkMethodVisitor.visitLdcInsn.

Annotations
@Override
visitLineNumberback to summary
public void visitLineNumber(final int line, final Label start)

Overrides org.eclipse.persistence.asm.EclipseLinkMethodVisitor.visitLineNumber.

Annotations
@Override
visitLocalVariableback to summary
public void visitLocalVariable(final String name, final String desc, String signature, final Label start, final Label end, final int index)

Overrides org.eclipse.persistence.asm.EclipseLinkMethodVisitor.visitLocalVariable.

Annotations
@Override
visitLookupSwitchInsnback to summary
public void visitLookupSwitchInsn(final Label dflt, final int[] keys, final Label[] labels)

Overrides org.eclipse.persistence.asm.EclipseLinkMethodVisitor.visitLookupSwitchInsn.

Annotations
@Override
visitMaxsback to summary
public void visitMaxs(final int maxStack, final int maxLocals)

Overrides org.eclipse.persistence.asm.EclipseLinkMethodVisitor.visitMaxs.

Annotations
@Override
visitMethodInsnback to summary
public void visitMethodInsn(final int opcode, final String owner, final String name, final String desc, boolean intf)

Overrides org.eclipse.persistence.asm.EclipseLinkMethodVisitor.visitMethodInsn.

Annotations
@Override
visitMultiANewArrayInsnback to summary
public void visitMultiANewArrayInsn(final String desc, final int dims)

Overrides org.eclipse.persistence.asm.EclipseLinkMethodVisitor.visitMultiANewArrayInsn.

Annotations
@Override
visitTableSwitchInsnback to summary
public void visitTableSwitchInsn(final int min, final int max, final Label dflt, final Label... labels)

Overrides org.eclipse.persistence.asm.EclipseLinkMethodVisitor.visitTableSwitchInsn.

Annotations
@Override
visitTryCatchBlockback to summary
public void visitTryCatchBlock(final Label start, final Label end, final Label handler, final String type)

Overrides org.eclipse.persistence.asm.EclipseLinkMethodVisitor.visitTryCatchBlock.

Annotations
@Override
visitTypeInsnback to summary
public void visitTypeInsn(final int opcode, final String desc)

Overrides org.eclipse.persistence.asm.EclipseLinkMethodVisitor.visitTypeInsn.

Annotations
@Override
visitVarInsnback to summary
public void visitVarInsn(final int opcode, final int var)

Overrides org.eclipse.persistence.asm.EclipseLinkMethodVisitor.visitVarInsn.

Annotations
@Override
weaveAttributesIfRequiredback to summary
public void weaveAttributesIfRequired(int opcode, String owner, String name, String desc)

Change GETFIELD and PUTFIELD for fields that use attribute access to make use of new convenience methods. A GETFIELD for an attribute named 'variableName' will be replaced by a call to: _persistence_get_variableName() A PUTFIELD for an attribute named 'variableName' will be replaced by a call to: _persistence_set_variableName(variableName)

weaveBeginningOfMethodIfRequiredback to summary
public void weaveBeginningOfMethodIfRequired()

Makes modifications to the beginning of a method. 1. Modifies getter method for attributes using property access In a getter method for 'attributeName', the following lines are added at the beginning of the method _persistence_checkFetched("attributeName"); _persistence_initialize_attributeName_vh(); if (!_persistence_attributeName_vh.isInstantiated()) { PropertyChangeListener temp_persistence_listener = _persistence_listener; _persistence_listener = null; setAttributeName((AttributeType)_persistence_attributeName_vh.getValue()); _persistence_listener = temp_persistence_listener; } 2. Modifies setter methods to store old value of attribute If weaving for fetch groups: // if weaving for change tracking: if(_persistence_listener != null) // for Objects AttributeType oldAttribute = getAttribute() // for primitives AttributeWrapperType oldAttribute = new AttributeWrapperType(getAttribute()); e.g. Double oldAttribute = Double.valueOf(getAttribute()); else _persistence_checkFetchedForSet("attributeName"); _persistence_propertyChange("attributeName", oldAttribute, argument); otherwise (not weaving for fetch groups): // for Objects AttributeType oldAttribute = getAttribute() // for primitives AttributeWrapperType oldAttribute = new AttributeWrapperType(getAttribute()); e.g. Double oldAttribute = Double.valueOf(getAttribute()); _persistence_propertyChange("attributeName", oldAttribute, argument); // if not weaving for change tracking, but for fetch groups only: _persistence_checkFetchedForSet("attributeName"); 3. Modifies getter Method for attributes using virtual access add: _persistence_checkFetched(name); 4. Modifies setter Method for attributes using virtual access add code of the following form: Object obj = null; if(_persistence_listener != null){ obj = get(name); } else { _persistence_checkFetchedForSet(name); } _persistence_propertyChange(name, obj, value); _persistence_checkFetchedForSet(name) call will be excluded if weaving of fetch groups is not enabled _persistence_propertyChange(name, obj, value); will be excluded if weaving of change tracking is not enabled

weaveEndOfMethodIfRequiredback to summary
public void weaveEndOfMethodIfRequired()

Modifies methods just before the return. In a setter method for a LAZY mapping, for 'attributeName', the following lines are added at the end of the method. _persistence_initialize_attributeName_vh(); _persistence_attributeName_vh.setValue(argument); _persistence_attributeName_vh.setIsCoordinatedWithProperty(true); In a setter method for a non-LAZY mapping, the followings lines are added if change tracking is activated: _persistence_propertyChange("attributeName", oldAttribute, argument); Note: This code will wrap primitives by adding a call to the primitive constructor.