private static AbstractRequestContext nonDiffingRequestContext(AutoBean<?> bean) { AbstractRequestContext context = requestContext(bean); if (context != null && context.isDiffing()) { context = null; } return context; } }
/** * Make the EnityProxy bean edited and owned by this RequestContext. */ private <T extends BaseProxy> T takeOwnership(AutoBean<T> bean) { state.editedProxies.put(stableId(bean), bean); bean.setTag(REQUEST_CONTEXT_STATE, this.state); return bean.as(); } }
private AutoBean<? extends BaseProxy> findEditedProxy(IdMessage idMessage) { // Support violations for value objects. SimpleProxyId<BaseProxy> rootId = getId(idMessage); // The stub is empty, since we don't process any OperationMessages AutoBean<BaseProxy> stub = getProxyForReturnPayloadGraph(rootId); // So pick up the instance that we just sent to the server return state.editedProxies.get(BaseProxyCategory.stableId(stub)); } }
AbstractRequestContext context = requestContext(bean);
/** * ValueProxies are equal if they are from the same RequestContext and all of * their properties are equal. */ public static boolean equals(AutoBean<? extends ValueProxy> bean, Object o) { if (!(o instanceof ValueProxy)) { return false; } AutoBean<ValueProxy> other = AutoBeanUtils.getAutoBean((ValueProxy) o); if (other == null) { // Unexpected, could be an user-provided implementation? return false; } if (!stableId(bean).getProxyClass().equals(stableId(other).getProxyClass())) { // Compare AppleProxies to AppleProxies return false; } // Compare the entire object graph return AutoBeanUtils.deepEquals(bean, other); }
private static AbstractRequestContext nonDiffingRequestContext(AutoBean<?> bean) { AbstractRequestContext context = requestContext(bean); if (context != null && context.isDiffing()) { context = null; } return context; } }
/** * Compute deltas for each entity seen by the context. * <p> * TODO(t.broyer): reduce payload size by only sending proxies that are * directly referenced by invocation arguments or by other proxies. For * backwards-compatibility with no-op requests and operation-only requests, * only do so when there's at least one invocation (or we can choose to * break backwards compatibility for those edge-cases). */ private List<OperationMessage> makePayloadOperations() { assert isLocked(); assert !state.diffing; state.diffing = true; try { List<OperationMessage> operations = new ArrayList<OperationMessage>(); for (AutoBean<? extends BaseProxy> currentView : state.editedProxies.values()) { OperationMessage operation = makeOperationMessage(BaseProxyCategory.stableId(currentView), currentView, true).as(); operations.add(operation); } return operations; } finally { state.diffing = false; } }
private static AbstractRequestContext nonDiffingRequestContext(AutoBean<?> bean) { AbstractRequestContext context = requestContext(bean); if (context != null && context.isDiffing()) { context = null; } return context; } }
value = BaseProxyCategory.stableId(autoBean);
private static AbstractRequestContext nonDiffingRequestContext(AutoBean<?> bean) { AbstractRequestContext context = requestContext(bean); if (context != null && context.isDiffing()) { context = null; } return context; } }
public boolean isChanged() { /* * NB: Don't use the presence of ephemeral objects for this test. * * Diff the objects until one is found to be different. It's not just a * simple flag-check because of the possibility of "unmaking" a change, per * the JavaDoc. * * TODO: try to get rid of the 'diffing' flag and optimize the diffing of * objects: http://code.google.com/p/google-web-toolkit/issues/detail?id=7379 */ assert !state.diffing; state.diffing = true; try { for (AutoBean<? extends BaseProxy> bean : state.editedProxies.values()) { AutoBean<?> previous = bean.getTag(Constants.PARENT_OBJECT); if (previous == null) { // Compare to empty object Class<?> proxyClass = stableId(bean).getProxyClass(); previous = getAutoBeanFactory().create(proxyClass); } if (!AutoBeanUtils.diff(previous, bean).isEmpty()) { return true; } } return false; } finally { state.diffing = false; } }
AbstractRequestContext context = requestContext(bean);
private void serializeOneProxy(SimpleProxyId<?> idForSerialization, AutoBean<? extends BaseProxy> bean) { AutoBean<OperationMessage> op = makeOperationMessage(serializedId(BaseProxyCategory.stableId(bean)), bean, false); store.put(getRequestFactory().getHistoryToken(idForSerialization), AutoBeanCodex.encode(op)); } }
AbstractRequestContext context = requestContext(bean);
/** * Take ownership of a proxy instance and make it editable. */ public <T extends BaseProxy> T editProxy(T object) { AutoBean<T> bean = checkStreamsNotCrossed(object); checkLocked(); @SuppressWarnings("unchecked") AutoBean<T> previouslySeen = (AutoBean<T>) state.editedProxies.get(BaseProxyCategory.stableId(bean)); if (previouslySeen != null && !previouslySeen.isFrozen()) { /* * If we've seen the object before, it might be because it was passed in as a method argument. * This does not guarantee its mutability, so check that here before returning the cached * object. */ return previouslySeen.as(); } // Create editable copies AutoBean<T> parent = bean; bean = cloneBeanAndCollections(bean); bean.setTag(Constants.PARENT_OBJECT, parent); return bean.as(); }
AbstractRequestContext context = requestContext(bean);
final SimpleProxyId<?> id = serializedId(BaseProxyCategory.stableId(root));
private AutoBean<? extends BaseProxy> findEditedProxy(IdMessage idMessage) { // Support violations for value objects. SimpleProxyId<BaseProxy> rootId = getId(idMessage); // The stub is empty, since we don't process any OperationMessages AutoBean<BaseProxy> stub = getProxyForReturnPayloadGraph(rootId); // So pick up the instance that we just sent to the server return state.editedProxies.get(BaseProxyCategory.stableId(stub)); } }
private AutoBean<? extends BaseProxy> findEditedProxy(IdMessage idMessage) { // Support violations for value objects. SimpleProxyId<BaseProxy> rootId = getId(idMessage); // The stub is empty, since we don't process any OperationMessages AutoBean<BaseProxy> stub = getProxyForReturnPayloadGraph(rootId); // So pick up the instance that we just sent to the server return state.editedProxies.get(BaseProxyCategory.stableId(stub)); } }
/** * Make the EnityProxy bean edited and owned by this RequestContext. */ private <T extends BaseProxy> T takeOwnership(AutoBean<T> bean) { state.editedProxies.put(stableId(bean), bean); bean.setTag(REQUEST_CONTEXT_STATE, this.state); return bean.as(); } }