/** * Set the supplied request to have the default cache policy and the {@link #getNowInUtc() current time in UTC}. * * @param request the cacheable request */ protected void setCacheableInfo( CacheableRequest request ) { // Set it only if the request has no cache policy already ... if (request.getCachePolicy() == null && defaultCachePolicy != null) { request.setCachePolicy(defaultCachePolicy); } request.setTimeLoaded(nowInUtc); }
protected static DateTime computeExpirationTime( CacheableRequest request ) { CachePolicy policy = request.getCachePolicy(); return policy == null ? null : request.getTimeLoaded().plus(policy.getTimeToLive(), TimeUnit.MILLISECONDS); }
/** * Set the supplied request to have the supplied cache policy and the {@link #getNowInUtc() current time in UTC}. * * @param request the cacheable request * @param cachePolicy the cache policy for the request; may be null if there is to be no cache policy */ protected void setCacheableInfo( CacheableRequest request, CachePolicy cachePolicy ) { if (cachePolicy == null) cachePolicy = defaultCachePolicy; if (cachePolicy != null) { if (request.getCachePolicy() != null) { // Set the supplied only if less than the current ... if (request.getCachePolicy().getTimeToLive() > cachePolicy.getTimeToLive()) { request.setCachePolicy(cachePolicy); } } else { // There is no current policy, so set the supplied policy ... request.setCachePolicy(cachePolicy); } } request.setTimeLoaded(nowInUtc); }
actualLocationsOfProxyNodes.put(locationOfProxy.getPath(), locationOfProxy); setCacheableInfo(request, fromSource.getCachePolicy()); projectedRequest = projectedRequest.next(); ++numMerged; projectToFederated(actualLocation, projection, request, parent, children, properties); setCacheableInfo(request, fromSource.getCachePolicy()); projectedRequest = projectedRequest.next();
/** * {@inheritDoc} * * @see org.modeshape.graph.request.processor.RequestProcessor#process(org.modeshape.graph.request.ReadBranchRequest) */ @Override public void process( ReadBranchRequest request ) { CacheableRequest source = (CacheableRequest)federatedRequest.getFirstProjectedRequest().getRequest(); if (checkErrorOrCancel(request, source)) return; if (RequestType.READ_BRANCH == source.getType()) { ReadBranchRequest readSource = (ReadBranchRequest)source; request.setActualLocationOfNode(readSource.getActualLocationOfNode()); for (Location node : readSource) { List<Location> children = readSource.getChildren(node); if (children != null) request.setChildren(node, children); Map<Name, Property> props = readSource.getPropertiesFor(node); if (props != null) request.setProperties(node, props.values()); } } else if (RequestType.READ_NODE == source.getType()) { ReadNodeRequest readSource = (ReadNodeRequest)source; request.setActualLocationOfNode(readSource.getActualLocationOfNode()); Location parent = readSource.getActualLocationOfNode(); request.setChildren(parent, readSource.getChildren()); request.setProperties(parent, readSource.getPropertiesByName().values()); } request.setCachePolicy(getDefaultCachePolicy()); setCacheableInfo(request, source.getCachePolicy()); }
while (projectedRequest != null) { Request requestToSource = projectedRequest.getRequest(); setCacheableInfo(cacheableOriginal, ((CacheableRequest)requestToSource).getCachePolicy()); projectedRequest = projectedRequest.next();