/** * 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 the value to be stored in the object's attribute. * This will be a proxy object. */ public Object valueFromRow(Object object) { ValueHolderInterface valueHolder = new ValueHolder(object); return ProxyIndirectionHandler.newProxyInstance(object.getClass(), targetInterfaces, valueHolder); }
/** * 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: * * Utility method to create a new proxy object. */ public static Object newProxyInstance(Class anInterface, Class[] interfaces, ValueHolderInterface valueHolder) { ClassLoader classLoader = null; if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()){ try{ classLoader = AccessController.doPrivileged(new PrivilegedGetClassLoaderForClass(anInterface)); }catch (PrivilegedActionException ex){ throw (RuntimeException) ex.getCause(); } }else{ classLoader = PrivilegedAccessHelper.getClassLoaderForClass(anInterface); } return Proxy.newProxyInstance(classLoader, interfaces, new ProxyIndirectionHandler(valueHolder)); }
/** * 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: * * Utility method to create a new proxy object. */ public static Object newProxyInstance(Class anInterface, Class[] interfaces, ValueHolderInterface valueHolder) { ClassLoader classLoader = null; if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()){ try{ classLoader = AccessController.doPrivileged(new PrivilegedGetClassLoaderForClass(anInterface)); }catch (PrivilegedActionException ex){ throw (RuntimeException) ex.getCause(); } }else{ classLoader = PrivilegedAccessHelper.getClassLoaderForClass(anInterface); } return Proxy.newProxyInstance(classLoader, interfaces, new ProxyIndirectionHandler(valueHolder)); }
/** * 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 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 value to be stored in the object's attribute. * This will be a proxy object. */ public Object valueFromRow(Object object) { ValueHolderInterface valueHolder = new ValueHolder(object); return ProxyIndirectionHandler.newProxyInstance(object.getClass(), targetInterfaces, valueHolder); }
/** * INTERNAL: * * Utility method to create a new proxy object. */ public static Object newProxyInstance(Class anInterface, Class[] interfaces, ValueHolderInterface valueHolder) { ClassLoader classLoader = null; if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()){ try{ classLoader = (ClassLoader)AccessController.doPrivileged(new PrivilegedGetClassLoaderForClass(anInterface)); }catch (PrivilegedActionException ex){ throw (RuntimeException) ex.getCause(); } }else{ classLoader = PrivilegedAccessHelper.getClassLoaderForClass(anInterface); } return Proxy.newProxyInstance(classLoader, interfaces, new ProxyIndirectionHandler(valueHolder)); }
ValueHolderInterface oldValueHolder = handler.getValueHolder(); return ProxyIndirectionHandler.newProxyInstance(attributeValue.getClass(), targetInterfaces, newValueHolder);
/** * 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 the value to be stored in the object's attribute. * This will be a proxy object. */ public Object valueFromRow(Object object) { ValueHolderInterface valueHolder = new ValueHolder(object); return ProxyIndirectionHandler.newProxyInstance(object.getClass(), targetInterfaces, valueHolder); }
ValueHolderInterface oldValueHolder = handler.getValueHolder(); return ProxyIndirectionHandler.newProxyInstance(attributeValue.getClass(), targetInterfaces, newValueHolder);
/** * 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 value to be stored in the object's attribute. * This value is determined by invoking the appropriate method on the object and passing it the * row and session. */ public Object valueFromMethod(Object object, AbstractRecord row, AbstractSession session) { ValueHolderInterface valueHolder = new TransformerBasedValueHolder(this.getTransformationMapping().getAttributeTransformer(), object, row, session); return ProxyIndirectionHandler.newProxyInstance(object.getClass(), targetInterfaces, valueHolder); }
ValueHolderInterface oldValueHolder = handler.getValueHolder(); return ProxyIndirectionHandler.newProxyInstance(attributeValue.getClass(), targetInterfaces, newValueHolder);
/** * 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 value to be stored in the object's attribute. * This value is determined by invoking the appropriate method on the object and passing it the * row and session. */ public Object valueFromMethod(Object object, AbstractRecord row, AbstractSession session) { ValueHolderInterface valueHolder = new TransformerBasedValueHolder(this.getTransformationMapping().getAttributeTransformer(), object, row, session); return ProxyIndirectionHandler.newProxyInstance(object.getClass(), targetInterfaces, valueHolder); }
/** * 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; }