Class LazyLoadAccessorsBytecodeTransformer

java.lang.Object
rife.database.querymanagers.generic.instrument.LazyLoadAccessorsBytecodeTransformer

public abstract class LazyLoadAccessorsBytecodeTransformer extends Object
This utility class will modify property accessors of classes that implement the Constrained interface and add lazy loading for properties with manyToOne constraints.

This is done by modifying the bytecode of the getters by checking if the value that is returned is null, and in that case performing the actual database call to fetch the property value. After that, the property value is stored in a map that is stored in an added class field so that it will not be fetched at subsequent calls of the getter. The setter is modified to remove the values from this map when it is executed, so that users can still provide their own values for the properties.

WARNING: this class is not supposed to be used directly, it is made public since the general RIFE EngineClassLoader has to be able to access it.

Since:
1.0
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    The name of the synthetic class field that will be added so that the instance of the GenericQueryManager that restored the bean can be used afterwards to lazily load the relations.
    static final String
    The name of the synthetic class field that will be added so that already restored lazy relations can be cached.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static byte[]
    addLazyLoadToBytes(byte[] origBytes)
    Performs the actual modification of the bean class's bytecode.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • GQM_VAR_NAME

      public static final String GQM_VAR_NAME
      The name of the synthetic class field that will be added so that the instance of the GenericQueryManager that restored the bean can be used afterwards to lazily load the relations.
      See Also:
    • LAZY_LOADED_VAR_NAME

      public static final String LAZY_LOADED_VAR_NAME
      The name of the synthetic class field that will be added so that already restored lazy relations can be cached.
      See Also:
  • Constructor Details

    • LazyLoadAccessorsBytecodeTransformer

      public LazyLoadAccessorsBytecodeTransformer()
  • Method Details

    • addLazyLoadToBytes

      public static byte[] addLazyLoadToBytes(byte[] origBytes)
      Performs the actual modification of the bean class's bytecode.
      Parameters:
      origBytes - the bytes of the bean class that should be modified
      Returns:
      the modified bytes
      Since:
      1.0