/** * INTERNAL: * Return a backup clone of a clone container that has not been * read from the database yet. * This is used by the indirection policy to hook together a UOW * clone with its backup clone - only when the clone (the working * copy returned to the user) instantiates its contents from the * database will these contents be copied to the backup clone. */ protected Object buildBackupClone(IndirectContainer container) { ValueHolderInterface containerValueHolder = container.getValueHolder(); // CR#2852176 Use a BackupValueHolder to handle replacing of the original. BackupValueHolder backupValueHolder = new BackupValueHolder(containerValueHolder); if (containerValueHolder instanceof UnitOfWorkValueHolder) { ((UnitOfWorkValueHolder) containerValueHolder).setBackupValueHolder(backupValueHolder); } return this.buildIndirectContainer(backupValueHolder); }
/** * If the original value holder was not instantiated, * then first instantiate it to obtain the backup value. */ public Object getValue() { // Ensures instantiation of the original, and setting of this back value holder's value. getUnitOfWorkValueHolder().getValue(); return value; }
/** * INTERNAL: * Return a backup clone of a clone container that has not been * read from the database yet. * This is used by the indirection policy to hook together a UOW * clone with its backup clone - only when the clone (the working * copy returned to the user) instantiates its contents from the * database will these contents be copied to the backup clone. */ protected Object buildBackupClone(IndirectContainer container) { UnitOfWorkValueHolder containerValueHolder = (UnitOfWorkValueHolder)container.getValueHolder(); // CR#2852176 Use a BackupValueHolder to handle replacing of the original. BackupValueHolder backupValueHolder = new BackupValueHolder(containerValueHolder); containerValueHolder.setBackupValueHolder(backupValueHolder); return this.buildIndirectContainer(backupValueHolder); }
/** * INTERNAL: * Return a backup clone of a clone container that has not been * read from the database yet. * This is used by the indirection policy to hook together a UOW * clone with its backup clone - only when the clone (the working * copy returned to the user) instantiates its contents from the * database will these contents be copied to the backup clone. */ protected Object buildBackupClone(IndirectContainer container) { ValueHolderInterface containerValueHolder = container.getValueHolder(); // CR#2852176 Use a BackupValueHolder to handle replacing of the original. BackupValueHolder backupValueHolder = new BackupValueHolder(containerValueHolder); if (containerValueHolder instanceof UnitOfWorkValueHolder) { ((UnitOfWorkValueHolder) containerValueHolder).setBackupValueHolder(backupValueHolder); } return this.buildIndirectContainer(backupValueHolder); }
/** * INTERNAL: * Return a backup clone of the attribute. */ public Object backupCloneAttribute(Object attributeValue, Object clone, Object backup, UnitOfWorkImpl unitOfWork) { if (!(attributeValue instanceof Proxy)) { return this.getMapping().buildBackupCloneForPartObject(attributeValue, clone, backup, unitOfWork); } ProxyIndirectionHandler handler = (ProxyIndirectionHandler)Proxy.getInvocationHandler(attributeValue); ValueHolderInterface unitOfWorkValueHolder = handler.getValueHolder(); ValueHolderInterface backupValueHolder = null; if ((!(unitOfWorkValueHolder instanceof UnitOfWorkValueHolder)) || unitOfWorkValueHolder.isInstantiated()) { backupValueHolder = (ValueHolderInterface) super.backupCloneAttribute(unitOfWorkValueHolder, clone, backup, unitOfWork); } else { // CR#2852176 Use a BackupValueHolder to handle replacing of the original. backupValueHolder = new BackupValueHolder(unitOfWorkValueHolder); ((UnitOfWorkValueHolder)unitOfWorkValueHolder).setBackupValueHolder((BackupValueHolder) backupValueHolder); } return ProxyIndirectionHandler.newProxyInstance(attributeValue.getClass(), targetInterfaces, backupValueHolder); }
/** * INTERNAL: * Return a backup clone of the attribute. */ public Object backupCloneAttribute(Object attributeValue, Object clone, Object backup, UnitOfWorkImpl unitOfWork) { if (!(attributeValue instanceof Proxy)) { return this.getMapping().buildBackupCloneForPartObject(attributeValue, clone, backup, unitOfWork); } ProxyIndirectionHandler handler = (ProxyIndirectionHandler)Proxy.getInvocationHandler(attributeValue); ValueHolderInterface unitOfWorkValueHolder = handler.getValueHolder(); ValueHolderInterface backupValueHolder = null; if ((!(unitOfWorkValueHolder instanceof UnitOfWorkValueHolder)) || unitOfWorkValueHolder.isInstantiated()) { backupValueHolder = (ValueHolderInterface) super.backupCloneAttribute(unitOfWorkValueHolder, clone, backup, unitOfWork); } else { // CR#2852176 Use a BackupValueHolder to handle replacing of the original. backupValueHolder = new BackupValueHolder(unitOfWorkValueHolder); ((UnitOfWorkValueHolder)unitOfWorkValueHolder).setBackupValueHolder((BackupValueHolder) backupValueHolder); } return ProxyIndirectionHandler.newProxyInstance(attributeValue.getClass(), targetInterfaces, backupValueHolder); }
/** * INTERNAL: * Return a backup clone of the attribute. */ public Object backupCloneAttribute(Object attributeValue, Object clone, Object backup, UnitOfWorkImpl unitOfWork) { if (!(attributeValue instanceof Proxy)) { return this.getMapping().buildBackupCloneForPartObject(attributeValue, clone, backup, unitOfWork); } ProxyIndirectionHandler handler = (ProxyIndirectionHandler)Proxy.getInvocationHandler(attributeValue); ValueHolderInterface unitOfWorkValueHolder = handler.getValueHolder(); ValueHolderInterface backupValueHolder = null; if ((!(unitOfWorkValueHolder instanceof UnitOfWorkValueHolder)) || unitOfWorkValueHolder.isInstantiated()) { backupValueHolder = (ValueHolderInterface) super.backupCloneAttribute(unitOfWorkValueHolder, clone, backup, unitOfWork); } else { // CR#2852176 Use a BackupValueHolder to handle replacing of the original. backupValueHolder = new BackupValueHolder(unitOfWorkValueHolder); ((UnitOfWorkValueHolder)unitOfWorkValueHolder).setBackupValueHolder((BackupValueHolder) backupValueHolder); } return ProxyIndirectionHandler.newProxyInstance(attributeValue.getClass(), targetInterfaces, backupValueHolder); }
/** * INTERNAL: * Return a backup clone of the attribute. */ public Object backupCloneAttribute(Object attributeValue, Object clone, Object backup, UnitOfWorkImpl unitOfWork) { //no need to check if the attribute is a valueholder because closeAttribute // should always be called first ValueHolderInterface valueHolder = (ValueHolderInterface)attributeValue;// cast the value ValueHolderInterface result = null; // delay instantiation until absolutely necessary if ((!(valueHolder instanceof UnitOfWorkValueHolder)) || valueHolder.isInstantiated()) { result = new ValueHolder(); result.setValue(super.backupCloneAttribute(valueHolder.getValue(), clone, backup, unitOfWork)); } else { // Backup value holder will be instantiated when uow vh is, to get original value, // backup must also know about the uow vh, in case it needs to get its value. result = new BackupValueHolder(valueHolder); ((UnitOfWorkValueHolder)valueHolder).setBackupValueHolder(result); } return result; }
/** * INTERNAL: * Return a backup clone of the attribute. */ public Object backupCloneAttribute(Object attributeValue, Object clone, Object backup, UnitOfWorkImpl unitOfWork) { //no need to check if the attribute is a valueholder because closeAttribute // should always be called first ValueHolderInterface valueHolder = (ValueHolderInterface)attributeValue;// cast the value ValueHolderInterface result = null; // delay instantiation until absolutely necessary if ((!(valueHolder instanceof UnitOfWorkValueHolder)) || valueHolder.isInstantiated()) { result = new ValueHolder(); result.setValue(super.backupCloneAttribute(valueHolder.getValue(), clone, backup, unitOfWork)); } else { // Backup value holder will be instantiated when uow vh is, to get original value, // backup must also know about the uow vh, in case it needs to get its value. result = new BackupValueHolder(valueHolder); ((UnitOfWorkValueHolder)valueHolder).setBackupValueHolder(result); } return result; }