Module org.eclipse.persistence.jpa
Class MethodWeaver
java.lang.Object
org.eclipse.persistence.asm.MethodVisitor
org.eclipse.persistence.asm.EclipseLinkMethodVisitor
org.eclipse.persistence.internal.jpa.weaving.MethodWeaver
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
FieldsModifier and TypeFieldDescriptionprotected Stringprotected Stringprotected booleanDetermines if we are at the first line of a method.protected ClassWeaverFields inherited from class org.eclipse.persistence.asm.EclipseLinkMethodVisitor
methodVisitorFields inherited from class org.eclipse.persistence.asm.MethodVisitor
customMethodVisitor -
Constructor Summary
ConstructorsConstructorDescriptionMethodWeaver(ClassWeaver tcw, String methodName, String methodDescriptor, MethodVisitor mv) -
Method Summary
Modifier and TypeMethodDescriptionvisitAnnotation(String desc, boolean visible) voidvisitAttribute(Attribute attr) voidvisitEnd()voidvisitFieldInsn(int opcode, String owner, String name, String desc) voidvisitIincInsn(int var, int increment) voidvisitInsn(int opcode) voidvisitIntInsn(int opcode, int operand) voidvisitJumpInsn(int opcode, Label label) voidvisitLabel(Label label) voidvisitLdcInsn(Object cst) voidvisitLineNumber(int line, Label start) voidvoidvisitLookupSwitchInsn(Label dflt, int[] keys, Label[] labels) voidvisitMaxs(int maxStack, int maxLocals) voidvisitMethodInsn(int opcode, String owner, String name, String desc, boolean intf) voidvisitMultiANewArrayInsn(String desc, int dims) voidvisitTableSwitchInsn(int min, int max, Label dflt, Label... labels) voidvisitTryCatchBlock(Label start, Label end, Label handler, String type) voidvisitTypeInsn(int opcode, String desc) voidvisitVarInsn(int opcode, int var) voidweaveAttributesIfRequired(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.voidMakes modifications to the beginning of a method.voidModifies methods just before the return.Methods inherited from class org.eclipse.persistence.asm.EclipseLinkMethodVisitor
unwrap, visitAnnotationSuper, visitAttributeSuper, visitCode, visitFieldInsnSuper, visitFrame, visitIincInsnSuper, visitInsnSuper, visitIntInsnSuper, visitJumpInsnSuper, visitLabelSuper, visitLdcInsnSuper, visitLineNumberSuper, visitLocalVariableSuper, visitLookupSwitchInsnSuper, visitMaxsSuper, visitMethodInsnSuper, visitMultiANewArrayInsnSuper, visitTableSwitchInsnSuper, visitTryCatchBlockSuper, visitTypeInsnSuper, visitVarInsnSuperMethods inherited from class org.eclipse.persistence.asm.MethodVisitor
setCustomMethodVisitor
-
Field Details
-
tcw
-
methodName
-
methodDescriptor
-
methodStarted
protected boolean methodStartedDetermines if we are at the first line of a method.
-
-
Constructor Details
-
MethodWeaver
-
-
Method Details
-
visitInsn
public void visitInsn(int opcode) - Overrides:
visitInsnin classEclipseLinkMethodVisitor
-
visitIntInsn
public void visitIntInsn(int opcode, int operand) - Overrides:
visitIntInsnin classEclipseLinkMethodVisitor
-
visitVarInsn
public void visitVarInsn(int opcode, int var) - Overrides:
visitVarInsnin classEclipseLinkMethodVisitor
-
visitTypeInsn
- Overrides:
visitTypeInsnin classEclipseLinkMethodVisitor
-
visitFieldInsn
- Overrides:
visitFieldInsnin classEclipseLinkMethodVisitor
-
visitMethodInsn
- Overrides:
visitMethodInsnin classEclipseLinkMethodVisitor
-
visitJumpInsn
- Overrides:
visitJumpInsnin classEclipseLinkMethodVisitor
-
visitLabel
- Overrides:
visitLabelin classEclipseLinkMethodVisitor
-
visitLdcInsn
- Overrides:
visitLdcInsnin classEclipseLinkMethodVisitor
-
visitIincInsn
public void visitIincInsn(int var, int increment) - Overrides:
visitIincInsnin classEclipseLinkMethodVisitor
-
visitTableSwitchInsn
- Overrides:
visitTableSwitchInsnin classEclipseLinkMethodVisitor
-
visitLookupSwitchInsn
- Overrides:
visitLookupSwitchInsnin classEclipseLinkMethodVisitor
-
visitMultiANewArrayInsn
- Overrides:
visitMultiANewArrayInsnin classEclipseLinkMethodVisitor
-
visitTryCatchBlock
- Overrides:
visitTryCatchBlockin classEclipseLinkMethodVisitor
-
visitMaxs
public void visitMaxs(int maxStack, int maxLocals) - Overrides:
visitMaxsin classEclipseLinkMethodVisitor
-
visitLocalVariable
public void visitLocalVariable(String name, String desc, String signature, Label start, Label end, int index) - Overrides:
visitLocalVariablein classEclipseLinkMethodVisitor
-
visitLineNumber
- Overrides:
visitLineNumberin classEclipseLinkMethodVisitor
-
visitAttribute
- Overrides:
visitAttributein classEclipseLinkMethodVisitor
-
visitAnnotation
- Overrides:
visitAnnotationin classEclipseLinkMethodVisitor
-
visitEnd
public void visitEnd()- Overrides:
visitEndin classEclipseLinkMethodVisitor
-
weaveAttributesIfRequired
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) -
weaveBeginningOfMethodIfRequired
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 -
weaveEndOfMethodIfRequired
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.
-