| Rafael Winterhalter The only changes I'd really expect to be needed are:
- Make Enhancer an interface, rather than just the single impl we have today
- Expose the Enhancer from BytecodeProvider
- Adjust EnhancementContext to not use Javassist types are its interchange.
The last one is the only real biggie. I knew it was less that ideal when we originally wrote this work, as you can even see in the todo comment:
- @todo Not sure its a great idea to expose Javassist classes this way. maybe wrap them in our own contracts?
which is in fact exactly what we will have to do. We will have to develop an SPI contract for communication between Hibernate (as the Enhancer consumer and EnhancementContext implementor) and the Enhancer implementor(s). We can certainly help with all these tasks listed here. I'm not sure how much help we can give though implementing a Byte Buddy implementation of Enhancer. I personally have no knowledge of Byte Buddy. As far as a "formal specification" its really all defined by the EnhancementContext methods. Specifically the following capabilities are expected:
- enhance entity, embeddable and mappedsuperclass classes to implement the appropriate version of org.hibernate.engine.spi.Managed
- enhance for lazy loading support
- org.hibernate.bytecode.enhance.spi.EnhancementContext#hasLazyLoadableAttributes
- org.hibernate.bytecode.enhance.spi.EnhancementContext#isPersistentField
- org.hibernate.bytecode.enhance.spi.EnhancementContext#isLazyLoadable
- org.hibernate.bytecode.enhance.spi.EnhancementContext#isMappedCollection
- enhance for bi-directional association management
- org.hibernate.bytecode.enhance.spi.EnhancementContext#doBiDirectionalAssociationManagement
- enhance for in-line dirty checking/tracking
- org.hibernate.bytecode.enhance.spi.EnhancementContext#doDirtyCheckingInline
- attempt to perform "extended" enhancement (convert field access outside the class itself)
- org.hibernate.bytecode.enhance.spi.EnhancementContext#doExtendedEnhancement
Honestly, some of this we may want to just move into the Enhancer implementor. That would alleviate much of the need for dedicated SPI contract describing the domain model to be enhanced. |