/** * Flushes the bean cache. The cache remains available for the rest of the request. */ public static void invalidate() { if (isActive()) { endRequest(); beginRequest(); } }
private Stack(ThreadLocal<Stack> interceptionContexts) { this.interceptionContexts = interceptionContexts; this.elements = new ArrayDeque<CombinedInterceptorAndDecoratorStackMethodHandler>(); /* * Setting / removing of a thread-local is much more expensive compared to get. Therefore, * if RequestScopedCache is active we register the thread-local for removal at the end of the * request. This yields possitive results only if the number of intercepted invocations is large. * If it is not, the performance characteristics are similar to explicitly removing the thread-local * once the stack gets empty. */ this.removeWhenEmpty = !RequestScopedCache.addItemIfActive(this); this.valid = true; }
public static void addItem(final RequestScopedItem item) { final List<RequestScopedItem> cache = CACHE.get(); checkCacheForAdding(cache); cache.add(item); }
public static void beginRequest() { // if the previous request was not ended properly for some reason, make sure it is ended now endRequest(); CACHE.set(new LinkedList<RequestScopedItem>()); }
@Override public void activate() { super.activate(); RequestScopedCache.beginRequest(); }
@Override public void destroy(Contextual<?> contextual) { if (!isActive()) { throw new ContextNotActiveException(); } checkContextInitialized(); if (contextual == null) { throw ContextLogger.LOG.contextualIsNull(); } final BeanStore beanStore = getBeanStore(); if (beanStore == null) { throw ContextLogger.LOG.noBeanStoreAvailable(this); } BeanIdentifier id = getId(contextual); ContextualInstance<?> beanInstance = beanStore.remove(id); if (beanInstance != null) { RequestScopedCache.invalidate(); destroyContextualInstance(beanInstance); } }
public static void beginRequest() { // if the previous request was not ended properly for some reason, make sure it is ended now endRequest(); CACHE.set(new LinkedList<RequestScopedItem>()); }
@Override public void activate() { super.activate(); RequestScopedCache.beginRequest(); }
@Override public void destroy(Contextual<?> contextual) { if (!isActive()) { throw new ContextNotActiveException(); } checkContextInitialized(); if (contextual == null) { throw ContextLogger.LOG.contextualIsNull(); } final BeanStore beanStore = getBeanStore(); if (beanStore == null) { throw ContextLogger.LOG.noBeanStoreAvailable(this); } BeanIdentifier id = getId(contextual); ContextualInstance<?> beanInstance = beanStore.remove(id); if (beanInstance != null) { RequestScopedCache.invalidate(); destroyContextualInstance(beanInstance); } }
/** * Flushes the bean cache. The cache remains available for the rest of the request. */ public static void invalidate() { if (isActive()) { endRequest(); beginRequest(); } }
public static void beginRequest() { // if the previous request was not ended properly for some reason, make sure it is ended now endRequest(); CACHE.set(new LinkedList<RequestScopedItem>()); }
@Override public void activate() { super.activate(); RequestScopedCache.beginRequest(); }
private Stack(ThreadLocal<Stack<T>> interceptionContexts) { this.interceptionContexts = interceptionContexts; this.elements = new ArrayDeque<T>(); /* * Setting / removing of a thread-local is much more expensive compared to get. Therefore, * if RequestScopedCache is active we register the thread-local for removal at the end of the * request. This yields possitive results only if the number of intercepted invocations is large. * If it is not, the performance characteristics are similar to explicitly removing the thread-local * once the stack gets empty. */ this.removeWhenEmpty = !RequestScopedCache.addItemIfActive(this); this.valid = true; }
public static void addItem(final RequestScopedItem item) { final List<RequestScopedItem> cache = CACHE.get(); checkCacheForAdding(cache); cache.add(item); }
@Override public void destroy(Contextual<?> contextual) { if (!isActive()) { throw new ContextNotActiveException(); } checkContextInitialized(); if (contextual == null) { throw ContextLogger.LOG.contextualIsNull(); } final BeanStore beanStore = getBeanStore(); if (beanStore == null) { throw ContextLogger.LOG.noBeanStoreAvailable(this); } BeanIdentifier id = getId(contextual); ContextualInstance<?> beanInstance = beanStore.remove(id); if (beanInstance != null) { RequestScopedCache.invalidate(); destroyContextualInstance(beanInstance); } }
/** * Flushes the bean cache. The cache remains available for the rest of the request. */ public static void invalidate() { if (isActive()) { endRequest(); beginRequest(); } }
public static void beginRequest() { // if the previous request was not ended properly for some reason, make sure it is ended now endRequest(); CACHE.set(new LinkedList<RequestScopedItem>()); }
@Override public void activate() { super.activate(); RequestScopedCache.beginRequest(); }
private Stack(ThreadLocal<Stack> interceptionContexts) { this.interceptionContexts = interceptionContexts; this.elements = new ArrayDeque<CombinedInterceptorAndDecoratorStackMethodHandler>(); /* * Setting / removing of a thread-local is much more expensive compared to get. Therefore, * if RequestScopedCache is active we register the thread-local for removal at the end of the * request. This yields possitive results only if the number of intercepted invocations is large. * If it is not, the performance characteristics are similar to explicitly removing the thread-local * once the stack gets empty. */ this.removeWhenEmpty = !RequestScopedCache.addItemIfActive(this); this.valid = true; }
public static void addItem(final RequestScopedItem item) { final List<RequestScopedItem> cache = CACHE.get(); checkCacheForAdding(cache); cache.add(item); }