/** * INTERNAL: * Return whether the specified object is instantiated. */ public boolean objectIsInstantiated(Object object) { if (object instanceof IndirectContainer) { return ((IndirectContainer)object).isInstantiated(); } else { return true;// it must be a "real" collection } }
/** * INTERNAL: * Return whether the specified object can be instantiated without database access. */ public boolean objectIsEasilyInstantiated(Object object) { ValueHolderInterface valueHolder = ((IndirectContainer)object).getValueHolder(); if (valueHolder instanceof DatabaseValueHolder) { return ((DatabaseValueHolder)valueHolder).isEasilyInstantiated(); } else { return true; } }
/** * Iterate an indirect container. */ protected void internalIterateIndirectContainer(IndirectContainer container) { ValueHolderInterface containedValueHolder = container.getValueHolder(); if (containedValueHolder instanceof RemoteValueHolder) { containedValueHolder = ((RemoteValueHolder)containedValueHolder).getWrappedServerValueHolder(); } synchronized (containedValueHolder) { // extract VH within sync block to ensure correct one is used. ValueHolderInterface valueHolder = container.getValueHolder(); RemoteValueHolder remoteValueHolder = buildRemoteValueHolderFor(valueHolder); container.setValueHolder(remoteValueHolder); remoteValueHolder.setServerIndirectionObject(container); } }
/** * Return a new IndirectContainer with the specified value holder. */ protected Object buildIndirectContainer(ValueHolderInterface valueHolder) { IndirectContainer result = buildIndirectContainer(); result.setValueHolder(valueHolder); return result; }
/** * Return a new IndirectContainer with the specified value holder. */ protected Object buildIndirectContainer(ValueHolderInterface valueHolder) { IndirectContainer result = buildIndirectContainer(); result.setValueHolder(valueHolder); return result; }
/** * INTERNAL: * set the source object into QueryBasedValueHolder. */ public void setSourceObject(Object sourceObject, Object attributeValue) { if( attributeValue instanceof IndirectContainer) { ValueHolderInterface valueHolder = ((IndirectContainer)attributeValue).getValueHolder(); if (valueHolder instanceof QueryBasedValueHolder) { ((QueryBasedValueHolder)valueHolder).setSourceObject(sourceObject); } } }
/** * Iterate an indirect container. */ protected void internalIterateIndirectContainer(IndirectContainer container) { ValueHolderInterface containedValueHolder = container.getValueHolder(); if (containedValueHolder instanceof RemoteValueHolder) { containedValueHolder = ((RemoteValueHolder)containedValueHolder).getWrappedServerValueHolder(); } synchronized (containedValueHolder) { // extract VH within sync block to ensure correct one is used. ValueHolderInterface valueHolder = container.getValueHolder(); RemoteValueHolder remoteValueHolder = buildRemoteValueHolderFor(valueHolder); container.setValueHolder(remoteValueHolder); remoteValueHolder.setServerIndirectionObject(container); } }
/** * INTERNAL: * Return whether the specified object is instantiated. */ public boolean objectIsInstantiated(Object object) { if (object instanceof IndirectContainer) { return ((IndirectContainer)object).isInstantiated(); } else { return true;// it must be a "real" collection } }
/** * Return a new IndirectContainer with the specified value holder. */ protected Object buildIndirectContainer(ValueHolderInterface valueHolder) { IndirectContainer result = buildIndirectContainer(); result.setValueHolder(valueHolder); return result; }
/** * INTERNAL: * Return whether the specified object is instantiated. */ public boolean objectIsInstantiated(Object object) { return ((IndirectContainer)object).getValueHolder().isInstantiated(); }
/** * Iterate an indirect container. */ protected void internalIterateIndirectContainer(IndirectContainer container) { ValueHolderInterface containedValueHolder = container.getValueHolder(); if (containedValueHolder instanceof RemoteValueHolder) { containedValueHolder = ((RemoteValueHolder)containedValueHolder).getWrappedServerValueHolder(); } synchronized (containedValueHolder) { // extract VH within sync block to ensure correct one is used. ValueHolderInterface valueHolder = container.getValueHolder(); RemoteValueHolder remoteValueHolder = buildRemoteValueHolderFor(valueHolder); container.setValueHolder(remoteValueHolder); remoteValueHolder.setServerIndirectionObject(container); } }
/** * INTERNAL: * Return whether the specified object is instantiated. */ public boolean objectIsInstantiated(Object object) { if (object instanceof IndirectContainer) { return ((IndirectContainer)object).isInstantiated(); } else { return true;// it must be a "real" collection } }
/** * Build a conatiner with the initialized constructor. * @see initializeContainer */ protected IndirectContainer buildContainer(ValueHolderInterface valueHolder) { try { IndirectContainer container = null; if (getContainerConstructor().getParameterTypes().length == 0) { if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()){ container = (IndirectContainer)AccessController.doPrivileged(new PrivilegedInvokeConstructor(getContainerConstructor(), new Object[0])); }else{ container = (IndirectContainer)PrivilegedAccessHelper.invokeConstructor(getContainerConstructor(), new Object[0]); } container.setValueHolder(valueHolder); } else { if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()){ container = (IndirectContainer)AccessController.doPrivileged(new PrivilegedInvokeConstructor(getContainerConstructor(), new Object[] { valueHolder })); }else{ container = (IndirectContainer)PrivilegedAccessHelper.invokeConstructor(getContainerConstructor(), new Object[] { valueHolder }); } } return container; } catch (Exception exception) { throw DescriptorException.invalidIndirectionPolicyOperation(this, "buildContainer constructor (" + getContainerConstructor() + ") Failed: " + exception); } }
/** * INTERNAL: * Return the "real" attribute value, as opposed to any wrapper. * This will trigger the wrapper to instantiate the value. */ public Object getRealAttributeValueFromObject(Object object, Object attribute) { return ((IndirectContainer)attribute).getValueHolder().getValue(); }
if (attributeValue instanceof IndirectContainer) { indirectContainer = (IndirectContainer)attributeValue; valueHolder = indirectContainer.getValueHolder(); if (indirectContainer instanceof IndirectList) { indirectList = (IndirectList)indirectContainer; indirectContainer.setValueHolder(uowValueHolder); container = indirectContainer;
@Override public void write(Kryo kryo, Output output, Collection collection) { boolean isNotInstantiated = collection instanceof IndirectContainer && !((IndirectContainer) collection).isInstantiated(); output.writeBoolean(isNotInstantiated); if (!isNotInstantiated) { super.write(kryo, output, collection); } }
/** * Build a conatiner with the initialized constructor. * @see initializeContainer */ protected IndirectContainer buildContainer(ValueHolderInterface valueHolder) { try { IndirectContainer container = null; if (getContainerConstructor().getParameterTypes().length == 0) { if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()){ container = (IndirectContainer)AccessController.doPrivileged(new PrivilegedInvokeConstructor(getContainerConstructor(), new Object[0])); }else{ container = (IndirectContainer)PrivilegedAccessHelper.invokeConstructor(getContainerConstructor(), new Object[0]); } container.setValueHolder(valueHolder); } else { if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()){ container = (IndirectContainer)AccessController.doPrivileged(new PrivilegedInvokeConstructor(getContainerConstructor(), new Object[] { valueHolder })); }else{ container = (IndirectContainer)PrivilegedAccessHelper.invokeConstructor(getContainerConstructor(), new Object[] { valueHolder }); } } return container; } catch (Exception exception) { throw DescriptorException.invalidIndirectionPolicyOperation(this, "buildContainer constructor (" + getContainerConstructor() + ") Failed: " + exception); } }
/** * INTERNAL: * Iterate over the specified attribute value, */ public void iterateOnAttributeValue(DescriptorIterator iterator, Object attributeValue) { super.iterateOnAttributeValue(iterator, ((IndirectContainer)attributeValue).getValueHolder()); }
if (attributeValue instanceof IndirectContainer) { indirectContainer = (IndirectContainer)attributeValue; valueHolder = indirectContainer.getValueHolder(); if (indirectContainer instanceof IndirectList) { indirectList = (IndirectList)indirectContainer; indirectContainer.setValueHolder(uowValueHolder); container = indirectContainer;
/** * Iterate on the indirection object for its mapping. */ public void iterateIndirectContainerForMapping(IndirectContainer container, DatabaseMapping mapping) { setCurrentMapping(mapping); setCurrentDescriptor(null); if (shouldIterateOnIndirectionObjects()) {// false by default internalIterateIndirectContainer(container); } if (shouldIterateOverUninstantiatedIndirectionObjects() || (shouldIterateOverIndirectionObjects() && container.isInstantiated())) { // force instantiation only if specified mapping.iterateOnRealAttributeValue(this, container); } else if (shouldIterateOverIndirectionObjects()) { // PERF: Allow the indirect container to iterate any cached elements. if (container instanceof IndirectCollection) { mapping.iterateOnRealAttributeValue(this, ((IndirectCollection)container).getAddedElements()); } } }