private Set<Document> supportedDocuments() { return queryResultsCache.execute(new Callable<Set<Document>>() { @Override public Set<Document> call() throws Exception { return supportedDocumentsNoCache(supportingDocumentCandidate); } }, Document_supports.class, "supportedDocuments", supportingDocumentCandidate); }
@Programmatic @SuppressWarnings("unchecked") public <T> T execute(final Callable<T> callable, final Key cacheKey) { if(control.isFixturesInstalling()) { try { return callable.call(); } catch (Exception e) { throw new RuntimeException(e); } } return executeWithCaching(callable, cacheKey); }
protected <T> T executeWithCaching(final Callable<T> callable, final Key cacheKey) { try { final Value<?> cacheValue = cache.get(cacheKey); logHitOrMiss(cacheKey, cacheValue); if(cacheValue != null) { return (T) cacheValue.getResult(); } // cache miss, so get the result... T result = callable.call(); // ... and cache // // (it is possible that the callable just invoked might also have updated the cache, eg if there was // some sort of recursion. However, Map#put(...) is idempotent, so valid to call more than once. // // note: there's no need for thread-safety synchronization... remember that QueryResultsCache is @RequestScoped put(cacheKey, result); return result; } catch (Exception e) { throw new RuntimeException(e); } }
@Programmatic @SuppressWarnings("unchecked") public <T> Value<T> get(final Key cacheKey) { Value<T> value = (Value<T>) cache.get(cacheKey); logHitOrMiss(cacheKey, value); return value; }
@Programmatic public <T> Value<T> get(final Class<?> callingClass, final String methodName, final Object... keys) { return get(new Key(callingClass, methodName, keys)); }
@Before public void setUp() throws Exception { queryResultsCache = new QueryResultsCache(); control = new QueryResultsCache.Control(); queryResultsCache.control = control; }
private Set<Document> supportedDocuments() { return queryResultsCache.execute(new Callable<Set<Document>>() { @Override public Set<Document> call() throws Exception { return supportedDocumentsNoCache(supportingDocumentCandidate); } }, Document_supports.class, "supportedDocuments", supportingDocumentCandidate); }
@Programmatic public <T> T execute(final Callable<T> callable, final Class<?> callingClass, final String methodName, final Object... keys) { if(control.isFixturesInstalling()) { try { return callable.call(); } catch (Exception e) { throw new RuntimeException(e); } } final Key cacheKey = new Key(callingClass, methodName, keys); return executeWithCaching(callable, cacheKey); }
/** * All templates which are applicable to the domain object's atPath, and which can be previewed. */ public List<DocumentTemplate> choices0$$() { return queryResultsCache.execute( () -> documentTemplateService.documentTemplatesForPreview(domainObject), getClass(), "$$", domainObject); }
/** * All templates which are applicable to the domain object's atPath, and which can be created and attached to at * least one domain object. */ public List<DocumentTemplate> choices0$$() { return queryResultsCache.execute( () -> documentTemplateService.documentTemplatesForCreateAndAttach(domainObject), getClass(), "$$", domainObject); }
/** * All templates which are applicable to the domain object's atPath, and which can be created and attached to at * least one domain object. */ public List<DocumentTemplate> choices0$$() { return queryResultsCache.execute( () -> documentTemplateService.documentTemplatesForCreateAndAttach(domainObject), getClass(), "$$", domainObject); }
/** * All templates which are applicable to the domain object's atPath, and which can be previewed. */ public List<DocumentTemplate> choices0$$() { return queryResultsCache.execute( () -> documentTemplateService.documentTemplatesForPreview(domainObject), getClass(), "$$", domainObject); }
/** * All templates which are applicable to the domain object's atPath, and which can be created and attached to at * least one domain object. */ public List<DocumentTemplate> choices0$$() { return queryResultsCache.execute( () -> documentTemplateService.documentTemplatesForCreateAndAttach(domainObject), getClass(), "$$", domainObject); }
@Programmatic public ApplicationSetting find(final String key) { return queryResultsCache.execute(new Callable<ApplicationSetting>() { @Override public ApplicationSetting call() throws Exception { return doFind(key); } }, ApplicationSettingRepository.class, "find", key); }
@Programmatic public UserSetting find( final String user, final String key) { return queryResultsCache.execute(new Callable<UserSetting>() { @Override public UserSetting call() throws Exception { return doFind(user, key); } }, UserSettingRepository.class, "find", user, key); }
/** * All templates which are applicable to the domain object's atPath, and which can be created and attached to at * least one domain object. */ public List<DocumentTemplate> choices0$$() { return queryResultsCache.execute( () -> documentTemplateService.documentTemplatesForCreateAndAttach(domainObject), getClass(), "$$", domainObject); }
public List<Document> choices0Exec() { return queryResultsCache.execute(() -> findAttachedToDocumentsNoCache(), Document_removeAttachment.class, "choices0Exec", document); }
public List<Document> choices0Exec() { return queryResultsCache.execute(() -> findAttachedToDocumentsNoCache(), Document_removeAttachment.class, "choices0Exec", document); }
@Action( domainEvent = ActionDomainEvent.class, semantics = SemanticsOf.SAFE ) @ActionLayout( contributed = Contributed.AS_ASSOCIATION ) @CollectionLayout(defaultView = "table") public List<Paperclip> $$() { return queryResultsCache.execute( (Callable<List<Paperclip>>) () -> { final List<Paperclip> paperclips = paperclipRepository.findByAttachedTo(attachedTo); return Lists.newArrayList(FluentIterable.from(paperclips).filter(filter()).toList()); }, getClass(), "$$", attachedTo); }
@Action( domainEvent = ActionDomainEvent.class, semantics = SemanticsOf.SAFE ) @ActionLayout( contributed = Contributed.AS_ASSOCIATION ) @CollectionLayout(defaultView = "table") public List<Paperclip> $$() { return queryResultsCache.execute( (Callable<List<Paperclip>>) () -> { final List<Paperclip> paperclips = paperclipRepository.findByAttachedTo(attachedTo); return Lists.newArrayList(FluentIterable.from(paperclips).filter(filter()).toList()); }, getClass(), "$$", attachedTo); }