/** * Creates or retrieves a new canonical AutoBean to represent the given id in the returned * payload. */ <Q extends BaseProxy> AutoBean<Q> getProxyForReturnPayloadGraph(SimpleProxyId<Q> id) { @SuppressWarnings("unchecked") AutoBean<Q> bean = (AutoBean<Q>) state.returnedProxies.get(id); if (bean == null) { Class<Q> proxyClass = id.getProxyClass(); bean = createProxy(proxyClass, id, true); state.returnedProxies.put(id, bean); } return 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); }
/** * Creates an AutoBean for the given id, tracking a domain object. */ private <Q extends BaseProxy> AutoBean<Q> createProxyBean(SimpleProxyId<Q> id, Object domainObject) { AutoBean<Q> toReturn = AutoBeanFactorySource.createBean(id.getProxyClass(), SimpleRequestProcessor.CONFIGURATION); toReturn.setTag(Constants.STABLE_ID, id); toReturn.setTag(Constants.DOMAIN_OBJECT, domainObject); beans.put(id, toReturn); return toReturn; }
/** * Convert any non-persistent ids into store-local synthetic ids. */ private <T extends BaseProxy> SimpleProxyId<T> serializedId(SimpleProxyId<T> stableId) { assert !stableId.isSynthetic(); if (stableId.isEphemeral()) { @SuppressWarnings("unchecked") SimpleProxyId<T> syntheticId = (SimpleProxyId<T>) syntheticIds.get(stableId); if (syntheticId == null) { int nextId = store.nextId(); assert nextId >= 0 : "ProxyStore.nextId() returned a negative number " + nextId; syntheticId = getRequestFactory().allocateSyntheticId(stableId.getProxyClass(), nextId + 1); syntheticIds.put(stableId, syntheticId); } return syntheticId; } return stableId; }
Class<?> domainClass = service.resolveDomainClass(id.getProxyClass()); if (beans.containsKey(id)) { domainClasses.add(service.resolveDomainClass(id.getProxyClass())); domainIds.add(domainParam); idsToLoad.add(id);
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; } }
assert toReturn.getProxyClass().equals(getTypeFromToken(typeToken));
operation.setTypeToken(state.requestFactory.getTypeToken(stableId.getProxyClass())); if (stableId.isEphemeral()) { parent = createProxy(stableId.getProxyClass(), stableId, true); } else if (stableId.isSynthetic()) { parent = createProxy(stableId.getProxyClass(), stableId, true); if (isEntityType(stableId.getProxyClass())) { } else if (isValueType(stableId.getProxyClass())) {
public String getHistoryToken(SimpleProxyId<?> proxy) { SimpleProxyId<?> id = (SimpleProxyId<?>) proxy; String token = getTypeToken(proxy.getProxyClass()); if (id.isEphemeral()) { return IdUtil.ephemeralId(id.getClientId(), token); } else if (id.isSynthetic()) { return IdUtil.syntheticId(id.getSyntheticId(), token); } else { return IdUtil.persistedId(id.getServerId(), token); } }
rootId.setTypeToken(service.resolveTypeToken(id.getProxyClass())); if (id.isEphemeral()) { rootId.setStrength(Strength.EPHEMERAL); leafId = FACTORY.id().as(); leafId.setClientId(stableId.getClientId()); leafId.setTypeToken(service.resolveTypeToken(stableId.getProxyClass())); if (stableId.isEphemeral()) { leafId.setStrength(Strength.EPHEMERAL);
WriteOperation writeOperation; if (id.isEphemeral() && returnState.isEntityType(id.getProxyClass())) { returnState.getResolver().resolveClientValue(domainObject, id.getProxyClass(), Collections.<String> emptySet()); op.setTypeToken(service.resolveTypeToken(id.getProxyClass())); if (version != null) { op.setVersion(toBase64(version.getPayload()));
if (operations != null && state.requestFactory.isEntityType(id.getProxyClass())) { for (WriteOperation writeOperation : operations) { if (writeOperation.equals(WriteOperation.UPDATE) id.getProxyClass());
/** * EntityCodex support. */ public Splittable getSerializedProxyId(SimpleProxyId<?> stableId) { AutoBean<IdMessage> bean = MessageFactoryHolder.FACTORY.id(); IdMessage ref = bean.as(); ref.setServerId(stableId.getServerId()); ref.setTypeToken(getRequestFactory().getTypeToken(stableId.getProxyClass())); if (stableId.isSynthetic()) { ref.setStrength(Strength.SYNTHETIC); ref.setSyntheticId(stableId.getSyntheticId()); } else if (stableId.isEphemeral()) { ref.setStrength(Strength.EPHEMERAL); ref.setClientId(stableId.getClientId()); } return AutoBeanCodex.encode(bean); }
/** * EntityCodex support. This method is identical to * {@link IdFactory#getHistoryToken(SimpleProxyId)} except that it * base64-encodes the server ids and adds client ids for stable ids * that were ephemeral. * <p> * XXX: Merge this with AbstsractRequestContext's implementation */ public Splittable getSerializedProxyId(SimpleProxyId<?> stableId) { AutoBean<IdMessage> bean = MessageFactoryHolder.FACTORY.id(); IdMessage ref = bean.as(); ref.setTypeToken(service.resolveTypeToken(stableId.getProxyClass())); if (stableId.isSynthetic()) { ref.setStrength(Strength.SYNTHETIC); ref.setSyntheticId(stableId.getSyntheticId()); } else if (stableId.isEphemeral()) { ref.setStrength(Strength.EPHEMERAL); ref.setClientId(stableId.getClientId()); } else { if (stableId.wasEphemeral()) { ref.setClientId(stableId.getClientId()); } ref.setServerId(SimpleRequestProcessor.toBase64(stableId.getServerId())); } return AutoBeanCodex.encode(bean); }
/** * Creates an AutoBean for the given id, tracking a domain object. */ private <Q extends BaseProxy> AutoBean<Q> createProxyBean(SimpleProxyId<Q> id, Object domainObject) { AutoBean<Q> toReturn = AutoBeanFactorySource.createBean(id.getProxyClass(), SimpleRequestProcessor.CONFIGURATION); toReturn.setTag(Constants.STABLE_ID, id); toReturn.setTag(Constants.DOMAIN_OBJECT, domainObject); beans.put(id, toReturn); return toReturn; }
/** * Creates an AutoBean for the given id, tracking a domain object. */ private <Q extends BaseProxy> AutoBean<Q> createProxyBean(SimpleProxyId<Q> id, Object domainObject) { AutoBean<Q> toReturn = AutoBeanFactorySource.createBean(id.getProxyClass(), SimpleRequestProcessor.CONFIGURATION); toReturn.setTag(Constants.STABLE_ID, id); toReturn.setTag(Constants.DOMAIN_OBJECT, domainObject); beans.put(id, toReturn); return toReturn; }
/** * Creates an AutoBean for the given id, tracking a domain object. */ private <Q extends BaseProxy> AutoBean<Q> createProxyBean(SimpleProxyId<Q> id, Object domainObject) { AutoBean<Q> toReturn = AutoBeanFactorySource.createBean(id.getProxyClass(), SimpleRequestProcessor.CONFIGURATION); toReturn.setTag(Constants.STABLE_ID, id); toReturn.setTag(Constants.DOMAIN_OBJECT, domainObject); beans.put(id, toReturn); return toReturn; }
public String getHistoryToken(SimpleProxyId<?> proxy) { SimpleProxyId<?> id = (SimpleProxyId<?>) proxy; String token = getTypeToken(proxy.getProxyClass()); if (id.isEphemeral()) { return IdUtil.ephemeralId(id.getClientId(), token); } else if (id.isSynthetic()) { return IdUtil.syntheticId(id.getSyntheticId(), token); } else { return IdUtil.persistedId(id.getServerId(), token); } }
public String getHistoryToken(SimpleProxyId<?> proxy) { SimpleProxyId<?> id = (SimpleProxyId<?>) proxy; String token = getTypeToken(proxy.getProxyClass()); if (id.isEphemeral()) { return IdUtil.ephemeralId(id.getClientId(), token); } else if (id.isSynthetic()) { return IdUtil.syntheticId(id.getSyntheticId(), token); } else { return IdUtil.persistedId(id.getServerId(), token); } }
public String getHistoryToken(SimpleProxyId<?> proxy) { SimpleProxyId<?> id = (SimpleProxyId<?>) proxy; String token = getTypeToken(proxy.getProxyClass()); if (id.isEphemeral()) { return IdUtil.ephemeralId(id.getClientId(), token); } else if (id.isSynthetic()) { return IdUtil.syntheticId(id.getSyntheticId(), token); } else { return IdUtil.persistedId(id.getServerId(), token); } }