|
> Please note that if this proposal is accepted by the community, it will require reenhancement
> of existing domain classes. The change will impact the internal StateManager and > PersistenceCapable API (essentally removal of certain methods than any other behavioural > change). Why will this require re-enhancement? The previously-enhanced classes will just have some extra methods that are no longer part of the interface. Classes enhanced with the new version will not work with older OpenJPA versions, though. > Why will this require re-enhancement?
We'll no longer be setting pcFlags values -- the callbacks won't even exist to do so. Instances of classes that aren't re-enhanced will therefore never get their pcFlags set to LOAD_REQUIRED as needed to ensure their StateManagers are able to intercept all field access. +1 on the patch from me. Fixes a problem and gets rid of unneeded code baggage at the same time. The re-enhancement isn't much of an issue to me -- we've required re-enhancement for various upgrades in the past and it's never been an issue with users, surprisingly enough.
> Why will this require re-enhancement?
====================================================== Previous enhancement: private static final void pcSetdepartment(Employee employee, Department department1) { if(employee.pcFlags == 0) { employee.department = department1; return; } if(employee.pcStateManager == null) { employee.department = department1; return; } else { employee.pcStateManager.settingObjectField(employee, pcInheritedFieldCount + 0, employee.department, department1, 0); return; } } ================================================ Enhanced version once pcFlags is removed: private static final void pcSetdepartment(Employee employee, Department department1) { if(employee.pcStateManager == null) { employee.department = department1; return; } else { employee.pcStateManager.settingObjectField(employee, pcInheritedFieldCount + 0, employee.department, department1, 0); return; } } ================================================== If the previous enhanced version is used, the behaviour of serialized domain class will remain unchanged even with new OpenJPA runtime (i.e. PC/SM interfaces without calling back on pcReplaceFlags()). But all this optimization to short-circuit StateManager mediation is only happening with JDO facade that too when the accessed field in not in default fetch group. Maybe we should do something explicit to make sure that classes enhanced with the old enhancer can't load anymore. It sounds like currently, classes will just silently start to behave differently.
One way is to add some extra checks on isPersistenceCapable() for the deprecated pcFlags() method and warn if the enhanced version is "old". Or is that too arbitrary?
Another would be to add a new getEnhancementContractVersion() method to the PersistenceCapable interface. This would cause immediate breakage of the old classes, since they don't have that method, and allow us to detect other subtle behavior changes in the future by checking that the version is compatible.
Added a public int getEnhancementContractVersion() to all enhanced classes.
Please review these baby steps into bytecode manipulation. The diff also contains removal of pcFlags related changes. It does not include the change in PersistenceCapable interface. 1. Should the method be static? 2. The ENHANCER_VERSION is public static final in PCEnhncer. So the user can: PersistenceCapable pc = ... if (pc.getEnhancementContractVersion() < PCEnhancer.ENHANCER_VERSION) // warn or throw exception 3. What is a good central location to add the above check? > 1. Should the method be static?
No; it should be part of the interface. The code looks good to me. Please make sure to run it through the Kodo test suites before committing, though -- sadly, we don't have as much enhancement coverage in the OpenJPA test suites as we should. I'd avoid the method name getEnhancementContractVersion because this might be used by the class developer. I'd suggest PRE+GetEnhancementContractVersion instead to avoid name conflicts.
Fixed with SVN revision 511998: http://svn.apache.org/viewvc?view=rev&rev=511998
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
i. remove pcFlags related interface method from PersistenceCapable and StateManager
ii. remove pcFlags related code generation from PCEnhancer