/** * INTERNAL: * Given a proxy object, trigger the indirection and return the actual object represented by the proxy. */ public static Object getValueFromProxy(Object value) { if (Proxy.isProxyClass(value.getClass())) { return ((ProxyIndirectionHandler)Proxy.getInvocationHandler(value)).getValueHolder().getValue(); } return value; }
/** * INTERNAL: * Given a proxy object, trigger the indirection and return the actual object represented by the proxy. */ public static Object getValueFromProxy(Object value) { if (Proxy.isProxyClass(value.getClass())) { return ((ProxyIndirectionHandler)Proxy.getInvocationHandler(value)).getValueHolder().getValue(); } return value; }
/** * INTERNAL: * Given a proxy object, trigger the indirection and return the actual object represented by the proxy. */ public static Object getValueFromProxy(Object value) { if (Proxy.isProxyClass(value.getClass())) { return ((ProxyIndirectionHandler)Proxy.getInvocationHandler(value)).getValueHolder().getValue(); } return value; }
/** * INTERNAL: * Return whether the specified object is instantiated. */ public boolean objectIsInstantiated(Object object) { if (object instanceof Proxy) { ProxyIndirectionHandler handler = (ProxyIndirectionHandler)Proxy.getInvocationHandler(object); ValueHolderInterface valueHolder = handler.getValueHolder(); return valueHolder.isInstantiated(); } else { return true; } }
/** * INTERNAL: * Return whether the specified object is instantiated. */ public boolean objectIsInstantiated(Object object) { if (object instanceof Proxy) { ProxyIndirectionHandler handler = (ProxyIndirectionHandler)Proxy.getInvocationHandler(object); ValueHolderInterface valueHolder = handler.getValueHolder(); return valueHolder.isInstantiated(); } else { return true; } }
/** * INTERNAL: * Return whether the specified object is instantiated. */ public boolean objectIsInstantiated(Object object) { if (object instanceof Proxy) { ProxyIndirectionHandler handler = (ProxyIndirectionHandler)Proxy.getInvocationHandler(object); ValueHolderInterface valueHolder = handler.getValueHolder(); return valueHolder.isInstantiated(); } else { return true; } }
/** * INTERNAL: * Return the "real" attribute value, as opposed to any wrapper. This will trigger the wrapper to * instantiate the value. */ public Object getRealAttributeValueFromObject(Object obj, Object object) { if (object instanceof Proxy) { ProxyIndirectionHandler handler = (ProxyIndirectionHandler)Proxy.getInvocationHandler(object); ValueHolderInterface valueHolder = handler.getValueHolder(); return valueHolder.getValue(); } else { return object; } }
/** * INTERNAL: * Return whether the specified object can be instantiated without database access. */ public boolean objectIsEasilyInstantiated(Object object) { if (object instanceof Proxy) { ProxyIndirectionHandler handler = (ProxyIndirectionHandler)Proxy.getInvocationHandler(object); ValueHolderInterface valueHolder = handler.getValueHolder(); if (valueHolder instanceof DatabaseValueHolder) { return ((DatabaseValueHolder)valueHolder).isEasilyInstantiated(); } } return true; }
/** * INTERNAL: * Return the "real" attribute value, as opposed to any wrapper. This will trigger the wrapper to * instantiate the value. */ public Object getRealAttributeValueFromObject(Object obj, Object object) { if (object instanceof Proxy) { ProxyIndirectionHandler handler = (ProxyIndirectionHandler)Proxy.getInvocationHandler(object); ValueHolderInterface valueHolder = handler.getValueHolder(); return valueHolder.getValue(); } else { return object; } }
/** * INTERNAL: * Return the "real" attribute value, as opposed to any wrapper. This will trigger the wrapper to * instantiate the value. */ public Object getRealAttributeValueFromObject(Object obj, Object object) { if (object instanceof Proxy) { ProxyIndirectionHandler handler = (ProxyIndirectionHandler)Proxy.getInvocationHandler(object); ValueHolderInterface valueHolder = handler.getValueHolder(); return valueHolder.getValue(); } else { return object; } }
/** * INTERNAL: * Return whether the specified object can be instantiated without database access. */ public boolean objectIsEasilyInstantiated(Object object) { if (object instanceof Proxy) { ProxyIndirectionHandler handler = (ProxyIndirectionHandler)Proxy.getInvocationHandler(object); ValueHolderInterface valueHolder = handler.getValueHolder(); if (valueHolder instanceof DatabaseValueHolder) { return ((DatabaseValueHolder)valueHolder).isEasilyInstantiated(); } } return true; }
/** * INTERNAL: * Return the reference row for the reference object. This allows the new row to be built without * instantiating the reference object. Return null if the object has already been instantiated. */ public AbstractRecord extractReferenceRow(Object referenceObject) { if ((referenceObject == null) || !Proxy.isProxyClass(referenceObject.getClass())) { return null; } ProxyIndirectionHandler handler = (ProxyIndirectionHandler)Proxy.getInvocationHandler(referenceObject); ValueHolderInterface valueHolder = handler.getValueHolder(); if (valueHolder.isInstantiated()) { return null; } else { return ((DatabaseValueHolder)valueHolder).getRow(); } }
/** * INTERNAL: * Return the reference row for the reference object. This allows the new row to be built without * instantiating the reference object. Return null if the object has already been instantiated. */ public AbstractRecord extractReferenceRow(Object referenceObject) { if ((referenceObject == null) || !Proxy.isProxyClass(referenceObject.getClass())) { return null; } ProxyIndirectionHandler handler = (ProxyIndirectionHandler)Proxy.getInvocationHandler(referenceObject); ValueHolderInterface valueHolder = handler.getValueHolder(); if (valueHolder.isInstantiated()) { return null; } else { return ((DatabaseValueHolder)valueHolder).getRow(); } }
/** * INTERNAL: * Return the reference row for the reference object. This allows the new row to be built without * instantiating the reference object. Return null if the object has already been instantiated. */ public AbstractRecord extractReferenceRow(Object referenceObject) { if ((referenceObject == null) || !Proxy.isProxyClass(referenceObject.getClass())) { return null; } ProxyIndirectionHandler handler = (ProxyIndirectionHandler)Proxy.getInvocationHandler(referenceObject); ValueHolderInterface valueHolder = handler.getValueHolder(); if (valueHolder.isInstantiated()) { return null; } else { return ((DatabaseValueHolder)valueHolder).getRow(); } }
/** * INTERNAL: * Iterate over the specified attribute value. */ public void iterateOnAttributeValue(DescriptorIterator iterator, Object attributeValue) { if (attributeValue instanceof Proxy) { ProxyIndirectionHandler handler = (ProxyIndirectionHandler)Proxy.getInvocationHandler(attributeValue); ValueHolderInterface valueHolder = handler.getValueHolder(); iterator.iterateValueHolderForMapping(valueHolder, this.getMapping()); } else { if (attributeValue != null) { this.getMapping().iterateOnRealAttributeValue(iterator, attributeValue); } } }
/** * INTERNAL: * Iterate over the specified attribute value. */ public void iterateOnAttributeValue(DescriptorIterator iterator, Object attributeValue) { if (attributeValue instanceof Proxy) { ProxyIndirectionHandler handler = (ProxyIndirectionHandler)Proxy.getInvocationHandler(attributeValue); ValueHolderInterface valueHolder = handler.getValueHolder(); iterator.iterateValueHolderForMapping(valueHolder, this.getMapping()); } else { if (attributeValue != null) { this.getMapping().iterateOnRealAttributeValue(iterator, attributeValue); } } }
/** * INTERNAL: * Iterate over the specified attribute value. */ public void iterateOnAttributeValue(DescriptorIterator iterator, Object attributeValue) { if (attributeValue instanceof Proxy) { ProxyIndirectionHandler handler = (ProxyIndirectionHandler)Proxy.getInvocationHandler(attributeValue); ValueHolderInterface valueHolder = handler.getValueHolder(); iterator.iterateValueHolderForMapping(valueHolder, this.getMapping()); } else { if (attributeValue != null) { this.getMapping().iterateOnRealAttributeValue(iterator, attributeValue); } } }
/** * 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); }