use of org.eclipse.persistence.internal.sessions.remote.RemoteSessionController in project eclipselink by eclipse-ee4j.
the class BasicIndirectionPolicy method getOriginalValueHolder.
/**
* INTERNAL: Return the original valueHolder object. Access to the
* underlying valueholder may be required when serializing the valueholder
* or converting the valueHolder to another type.
*/
@Override
public Object getOriginalValueHolder(Object unitOfWorkIndirectionObject, AbstractSession session) {
if ((unitOfWorkIndirectionObject instanceof UnitOfWorkValueHolder) && (((UnitOfWorkValueHolder<?>) unitOfWorkIndirectionObject).getRemoteUnitOfWork() != null)) {
ValueHolderInterface<?> valueHolder = ((UnitOfWorkValueHolder<?>) unitOfWorkIndirectionObject).getWrappedValueHolder();
if (valueHolder == null) {
// For remote session the original value holder is transient,
// so the value must be found in the registry or created.
RemoteUnitOfWork remoteUnitOfWork = (RemoteUnitOfWork) ((UnitOfWorkValueHolder<?>) unitOfWorkIndirectionObject).getRemoteUnitOfWork();
RemoteSessionController controller = remoteUnitOfWork.getParentSessionController();
ObjID id = ((UnitOfWorkValueHolder<?>) unitOfWorkIndirectionObject).getWrappedValueHolderRemoteID();
if (id != null) {
// on the client, the id should be enough to create a new remote value holder.
if (controller != null) {
valueHolder = controller.getRemoteValueHolders().get(id);
} else if (session.isRemoteSession()) {
valueHolder = new RemoteValueHolder<>(id);
((RemoteValueHolder<?>) valueHolder).setSession(session);
}
}
if (valueHolder == null) {
// Must build a new value holder.
Object object = ((UnitOfWorkValueHolder<?>) unitOfWorkIndirectionObject).getSourceObject();
AbstractRecord row = this.mapping.getDescriptor().getObjectBuilder().buildRow(object, session, WriteType.UNDEFINED);
ReadObjectQuery query = new ReadObjectQuery();
query.setSession(session);
valueHolder = (ValueHolderInterface<?>) this.mapping.valueFromRow(row, null, query, true);
}
return valueHolder;
}
}
if (unitOfWorkIndirectionObject instanceof WrappingValueHolder) {
ValueHolderInterface<?> valueHolder = ((WrappingValueHolder<?>) unitOfWorkIndirectionObject).getWrappedValueHolder();
if (!session.isProtectedSession()) {
while (valueHolder instanceof WrappingValueHolder && ((WrappingValueHolder<?>) valueHolder).getWrappedValueHolder() != null) {
valueHolder = ((WrappingValueHolder<?>) valueHolder).getWrappedValueHolder();
}
}
if (valueHolder instanceof DatabaseValueHolder) {
((DatabaseValueHolder<?>) valueHolder).releaseWrappedValueHolder(session);
}
return valueHolder;
} else {
return unitOfWorkIndirectionObject;
}
}
use of org.eclipse.persistence.internal.sessions.remote.RemoteSessionController in project eclipselink by eclipse-ee4j.
the class ContainerIndirectionPolicy method getOriginalIndirectionObject.
/**
* INTERNAL:
* Return the original indirection object for a unit of work indirection object.
*/
@Override
public Object getOriginalIndirectionObject(Object unitOfWorkIndirectionObject, AbstractSession session) {
IndirectContainer container = (IndirectContainer) unitOfWorkIndirectionObject;
if (container.getValueHolder() instanceof UnitOfWorkValueHolder) {
ValueHolderInterface<?> valueHolder = ((UnitOfWorkValueHolder<?>) container.getValueHolder()).getWrappedValueHolder();
if ((valueHolder == null) && session.isRemoteUnitOfWork()) {
RemoteSessionController controller = ((RemoteUnitOfWork) session).getParentSessionController();
valueHolder = controller.getRemoteValueHolders().get(((UnitOfWorkValueHolder<?>) container.getValueHolder()).getWrappedValueHolderRemoteID());
}
return buildContainer(valueHolder);
} else {
return container;
}
}
use of org.eclipse.persistence.internal.sessions.remote.RemoteSessionController in project eclipselink by eclipse-ee4j.
the class ProxyIndirectionPolicy method getOriginalIndirectionObject.
/**
* INTERNAL:
* Return the original indirection object for a unit of work indirection object.
*/
@Override
public Object getOriginalIndirectionObject(Object unitOfWorkIndirectionObject, AbstractSession session) {
if (unitOfWorkIndirectionObject instanceof UnitOfWorkValueHolder) {
ValueHolderInterface<?> valueHolder = ((UnitOfWorkValueHolder<?>) unitOfWorkIndirectionObject).getWrappedValueHolder();
if ((valueHolder == null) && session.isRemoteUnitOfWork()) {
RemoteSessionController controller = ((RemoteUnitOfWork) session).getParentSessionController();
valueHolder = controller.getRemoteValueHolders().get(((UnitOfWorkValueHolder<?>) unitOfWorkIndirectionObject).getWrappedValueHolderRemoteID());
}
return valueHolder;
} else {
return unitOfWorkIndirectionObject;
}
}
Aggregations