Interface EnhancementContext
-
- All Known Implementing Classes:
DefaultEnhancementContext
,EnhancementContextWrapper
,EnhancerTestContext
public interface EnhancementContext
The context for performing an enhancement. Enhancement can happen in any number of ways:- Build time, via Ant
- Build time, via Maven
- Build time, via Gradle
- Runtime, via agent
- Runtime, via JPA constructs
This interface isolates the code that actually does the enhancement from the underlying context in which the enhancement is being performed.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Deprecated Methods Modifier and Type Method Description boolean
doBiDirectionalAssociationManagement(UnloadedField field)
Should we manage association of bi-directional persistent attributes for this field?boolean
doDirtyCheckingInline(UnloadedClass classDescriptor)
Deprecated, for removal: This API element is subject to removal in a future version.Will be removed without replacement.boolean
doExtendedEnhancement(UnloadedClass classDescriptor)
Should we enhance field access to entities from this class?default BytecodeProvider
getBytecodeProvider()
Allows to force the use of a specific instance of BytecodeProvider to perform the enhancement.ClassLoader
getLoadingClassLoader()
Obtain access to the ClassLoader that can be used to load Class references.default UnsupportedEnhancementStrategy
getUnsupportedEnhancementStrategy()
boolean
hasLazyLoadableAttributes(UnloadedClass classDescriptor)
Deprecated, for removal: This API element is subject to removal in a future version.Will be removed without replacement.boolean
isCompositeClass(UnloadedClass classDescriptor)
Does the given class name represent an embeddable/component class?boolean
isDiscoveredType(UnloadedClass classDescriptor)
boolean
isEntityClass(UnloadedClass classDescriptor)
Does the given class descriptor represent an entity class?boolean
isLazyLoadable(UnloadedField field)
Determine if a field is lazy loadable.boolean
isMappedCollection(UnloadedField field)
boolean
isMappedSuperclassClass(UnloadedClass classDescriptor)
Does the given class name represent a MappedSuperclass class?boolean
isPersistentField(UnloadedField ctField)
Does the field represent persistent state? Persistent fields will be "enhanced".UnloadedField[]
order(UnloadedField[] persistentFields)
For fields which are persistent (according toisPersistentField(org.hibernate.bytecode.enhance.spi.UnloadedField)
), determine the corresponding ordering maintained within the Hibernate metamodel.void
registerDiscoveredType(UnloadedClass classDescriptor, Type.PersistenceType type)
-
-
-
Method Detail
-
getLoadingClassLoader
ClassLoader getLoadingClassLoader()
Obtain access to the ClassLoader that can be used to load Class references. In JPA SPI terms, this should be a "temporary class loader" as defined byPersistenceUnitInfo.getNewTempClassLoader()
- Returns:
- The class loader that the enhancer can use.
-
isEntityClass
boolean isEntityClass(UnloadedClass classDescriptor)
Does the given class descriptor represent an entity class?- Parameters:
classDescriptor
- The descriptor of the class to check.- Returns:
true
if the class is an entity;false
otherwise.
-
isCompositeClass
boolean isCompositeClass(UnloadedClass classDescriptor)
Does the given class name represent an embeddable/component class?- Parameters:
classDescriptor
- The descriptor of the class to check.- Returns:
true
if the class is an embeddable/component;false
otherwise.
-
isMappedSuperclassClass
boolean isMappedSuperclassClass(UnloadedClass classDescriptor)
Does the given class name represent a MappedSuperclass class?- Parameters:
classDescriptor
- The descriptor of the class to check.- Returns:
true
if the class is a mapped super class;false
otherwise.
-
doBiDirectionalAssociationManagement
boolean doBiDirectionalAssociationManagement(UnloadedField field)
Should we manage association of bi-directional persistent attributes for this field?- Parameters:
field
- The field to check.- Returns:
true
indicates that the field is enhanced so that for bi-directional persistent fields the association is managed, i.e. the associations are automatically set;false
indicates that the management is handled by the user.
-
doDirtyCheckingInline
@Deprecated(forRemoval=true) boolean doDirtyCheckingInline(UnloadedClass classDescriptor)
Deprecated, for removal: This API element is subject to removal in a future version.Will be removed without replacement. See HHH-15641Should we in-line dirty checking for persistent attributes for this class?- Parameters:
classDescriptor
- The descriptor of the class to check.- Returns:
true
indicates that dirty checking should be in-lined within the entity;false
indicates it should not. In-lined is more easily serializable and probably more performant.
-
doExtendedEnhancement
boolean doExtendedEnhancement(UnloadedClass classDescriptor)
Should we enhance field access to entities from this class?- Parameters:
classDescriptor
- The descriptor of the class to check.- Returns:
true
indicates that any direct access to fields of entities should be routed to the enhanced getter / setter method.
-
hasLazyLoadableAttributes
@Deprecated(forRemoval=true) boolean hasLazyLoadableAttributes(UnloadedClass classDescriptor)
Deprecated, for removal: This API element is subject to removal in a future version.Will be removed without replacement. See HHH-15641Does the given class define any lazy loadable attributes?- Parameters:
classDescriptor
- The class to check- Returns:
- true/false
-
isPersistentField
boolean isPersistentField(UnloadedField ctField)
Does the field represent persistent state? Persistent fields will be "enhanced".may be better to perform basic checks in the caller (non-static, etc) and call out with just the Class name and field name...
- Parameters:
ctField
- The field reference.- Returns:
true
if the field is ;false
otherwise.
-
order
UnloadedField[] order(UnloadedField[] persistentFields)
For fields which are persistent (according toisPersistentField(org.hibernate.bytecode.enhance.spi.UnloadedField)
), determine the corresponding ordering maintained within the Hibernate metamodel.- Parameters:
persistentFields
- The persistent field references.- Returns:
- The ordered references.
-
isLazyLoadable
boolean isLazyLoadable(UnloadedField field)
Determine if a field is lazy loadable.- Parameters:
field
- The field to check- Returns:
true
if the field is lazy loadable;false
otherwise.
-
isMappedCollection
boolean isMappedCollection(UnloadedField field)
- Parameters:
field
- the field to check- Returns:
true
if the field is mapped
-
isDiscoveredType
boolean isDiscoveredType(UnloadedClass classDescriptor)
-
registerDiscoveredType
void registerDiscoveredType(UnloadedClass classDescriptor, Type.PersistenceType type)
-
getUnsupportedEnhancementStrategy
@Incubating default UnsupportedEnhancementStrategy getUnsupportedEnhancementStrategy()
-
getBytecodeProvider
@Incubating default BytecodeProvider getBytecodeProvider()
Allows to force the use of a specific instance of BytecodeProvider to perform the enhancement.- Returns:
- When returning {code null} the default implementation will be used. Only return a different instance if you need to override the default implementation.
-
-