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); } }
/** * Replace non-persistent ids with store-local ids. */ @Override public Splittable getSerializedProxyId(SimpleProxyId<?> stableId) { return super.getSerializedProxyId(serializedId(stableId)); }
private static AbstractRequestContext nonDiffingRequestContext(AutoBean<?> bean) { AbstractRequestContext context = requestContext(bean); if (context != null && context.isDiffing()) { context = null; } return context; } }
private <P extends BaseProxy> SimpleProxyId<P> createId(Class<P> clazz, String serverId) { SimpleProxyId<P> toReturn; if (isValueType(clazz)) { toReturn = new SimpleProxyId<P>(clazz, serverId); } else { @SuppressWarnings("unchecked") SimpleProxyId<P> temp = (SimpleProxyId<P>) new SimpleEntityProxyId<EntityProxy>( asEntityProxy(clazz), serverId); toReturn = (SimpleProxyId<P>) temp; } return toReturn; }
/** * Create a new object, with an ephemeral id. */ public <T extends BaseProxy> T create(Class<T> clazz) { checkLocked(); SimpleProxyId<T> id = state.requestFactory.allocateId(clazz); AutoBean<T> created = createProxy(clazz, id, false); return takeOwnership(created); }
/** * This method comes from the {@link InstanceRequest} * interface. Instance methods place the instance in the first parameter slot. */ public Request<T> using(P instanceObject) { getRequestData().getOrderedParameters()[0] = instanceObject; /* * Instance methods enqueue themselves when their using() method is called. * This ensures that the instance parameter will have been set when * AbstractRequestContext.retainArg() is called. */ requestContext.addInvocation(this); return this; }
/** * Allocates a synthetic proxy id. This object is only valid for the lifetime * of a request. */ public <P extends BaseProxy> SimpleProxyId<P> allocateSyntheticId( Class<P> clazz, int syntheticId) { assert syntheticId > 0; SimpleProxyId<P> toReturn = createId(clazz, "%" + syntheticId); toReturn.setSyntheticId(syntheticId); return toReturn; }
public Class<? extends EntityProxy> getProxyClass(String historyToken) { String typeToken = IdUtil.getTypeToken(historyToken); if (typeToken != null) { return getTypeFromToken(typeToken); } return getTypeFromToken(historyToken); }
@Override protected boolean shouldFlush() { if (request == null) { return false; } if (request instanceof AbstractRequestContext) { return !((AbstractRequestContext) request).isLocked(); } return true; } }
@Override DialectImpl create(AbstractRequestContext context) { return context.new StandardPayloadDialect(); } },
@Override DialectImpl create(AbstractRequestContext context) { return context.new JsonRpcPayloadDialect(); } };
/** * EntityCodex support. */ public boolean isValueType(Class<?> clazz) { return state.requestFactory.isValueType(clazz); }
/** * Called by generated subclasses to enqueue a method invocation. */ protected void addInvocation(AbstractRequest<?, ?> request) { state.dialect.addInvocation(request); };
/** * EntityCodex support. */ public boolean isValueType(Class<?> clazz) { return idFactory.isValueType(clazz); }
@Override protected RequestData makeRequestData() { data.setPropertyRefs(propertyRefs); return data; } };
/** * EntityCodex support. */ public boolean isEntityType(Class<?> clazz) { return idFactory.isEntityType(clazz); }
/** * Returns the requests that were dequeued as part of reusing the context. */ private void reuse() { freezeEntities(false); state.locked = false; }
public RequestData getRequestData() { if (requestData == null) { requestData = makeRequestData(); } return requestData; }
private <P extends BaseProxy> SimpleProxyId<P> createId(Class<P> clazz, int clientId) { SimpleProxyId<P> toReturn; if (isValueType(clazz)) { toReturn = new SimpleProxyId<P>(clazz, clientId); } else { @SuppressWarnings("unchecked") SimpleProxyId<P> temp = (SimpleProxyId<P>) new SimpleEntityProxyId<EntityProxy>( asEntityProxy(clazz), clientId); toReturn = (SimpleProxyId<P>) temp; } return toReturn; }