synchronized void setStatus(Status status) { if (perThreadStatus != null) perThreadStatus.set(status); else this.status = status; } }
synchronized void setStatus(Status status) { if (perThreadStatus != null) perThreadStatus.set(status); else this.status = status; } }
public void set(Locale locale) { assert locale != null; if (!localeNames.contains(locale.toString().toLowerCase())) { String message = String .format("Locale '%s' is not supported by this application. Supported locales are '%s'; this is configured via the %s symbol.", locale, supportedLocales, SymbolConstants.SUPPORTED_LOCALES); throw new IllegalArgumentException(message); } localeValue.set(locale); }
public void set(Object instance, InstanceContext context, Object newValue) { fieldValue.set(newValue); // This catches the case where the instance initializer method sets a value for the field. // That value is captured and used when no specific value has been stored. if (!resources.isLoaded()) fieldDefaultValue = newValue; } }
public void set(Object instance, InstanceContext context, Object newValue) { resources.persistFieldChange(name, newValue); fieldValue.set(newValue); } }
public MutableServiceActivity(ServiceDef serviceDef, PerthreadManager perthreadManager, Status status) { this.serviceDef = serviceDef; if (serviceDef.getServiceScope().equals(ScopeConstants.PERTHREAD)) { perThreadStatus = perthreadManager.createValue(); perThreadStatus.set(status); this.status = status; // this is now the default status } else { perThreadStatus = null; this.status = status; } }
public MutableServiceActivity(ServiceDef serviceDef, PerthreadManager perthreadManager, Status status) { this.serviceDef = serviceDef; if (serviceDef.getServiceScope().equals(ScopeConstants.PERTHREAD)) { perThreadStatus = perthreadManager.createValue(); perThreadStatus.set(status); this.status = status; // this is now the default status } else { perThreadStatus = null; this.status = status; } }
private List<Runnable> getCallbacks() { List<Runnable> result = callbacksValue.get(); if (result == null) { result = CollectionFactory.newList(); callbacksValue.set(result); } return result; }
private List<Runnable> getCallbacks() { List<Runnable> result = callbacksValue.get(); if (result == null) { result = CollectionFactory.newList(); callbacksValue.set(result); } return result; }
@Override public synchronized Status getStatus() { if (perThreadStatus != null) { if (!perThreadStatus.exists()) perThreadStatus.set(status); return perThreadStatus.get(); } else return status; }
@Override public synchronized Status getStatus() { if (perThreadStatus != null) { if (!perThreadStatus.exists()) perThreadStatus.set(status); return perThreadStatus.get(); } else return status; }
/** * Instructs the hub to notify all its listeners (for the current thread). * It also discards its list of listeners. */ @Override public void cleanup() { List<Runnable> callbacks = getCallbacks(); callbacksValue.set(null); for (Runnable callback : callbacks) { try { callback.run(); } catch (Exception ex) { logger.warn(String.format("Error invoking callback %s: %s", callback, ex), ex); } } // Listeners should not re-add themselves or store any per-thread state // here, it will be lost. // Discard the per-thread map of values, including the key that stores // the listeners. This means that if a listener attempts to register // new listeners, the new listeners will not be triggered and will be // released to the GC. holder.remove(); }
/** * Instructs the hub to notify all its listeners (for the current thread). * It also discards its list of listeners. */ @Override public void cleanup() { List<Runnable> callbacks = getCallbacks(); callbacksValue.set(null); for (Runnable callback : callbacks) { try { callback.run(); } catch (Exception ex) { logger.warn("Error invoking callback {}: {}", callback, ex, ex); } } // Listeners should not re-add themselves or store any per-thread state // here, it will be lost. // Discard the per-thread map of values, including the key that stores // the listeners. This means that if a listener attempts to register // new listeners, the new listeners will not be triggered and will be // released to the GC. holder.remove(); }
private void addAlertStorageCleanupCallback() { // Add a callback that exists just to clear the non-persistent alerts. // Only one of these is needed. if (needAlertStorageCleanup.get(true)) { ajaxResponseRenderer.addCallback(new JavaScriptCallback() { public void run(JavaScriptSupport javascriptSupport) { // In an Ajax request, the Alerts are added, just so that they can be removed if not persistent. // Again, this is for the rare case where there's a redirect to another page. getAlertStorage().dismissNonPersistent(); } }); needAlertStorageCleanup.set(false); } }
private void addAlertStorageCleanupCallback() { // Add a callback that exists just to clear the non-persistent alerts. // Only one of these is needed. if (needAlertStorageCleanup.get(true)) { ajaxResponseRenderer.addCallback(new JavaScriptCallback() { public void run(JavaScriptSupport javascriptSupport) { // In an Ajax request, the Alerts are added, just so that they can be removed if not persistent. // Again, this is for the rare case where there's a redirect to another page. getAlertStorage().dismissNonPersistent(); } }); needAlertStorageCleanup.set(false); } }
public Object get(Object instance, InstanceContext context) { if (!fieldValue.exists()) { Object persistedValue = resources.hasFieldChange(name) ? resources.getFieldChange(name) : defaultValue; fieldValue.set(persistedValue); } return fieldValue.get(); }
public void render(MarkupWriter writer, RenderQueue queue) { renderingValue.set(false); Element current = writer.getElement(); if (current != expectedElementAtCompletion) throw new TapestryException(StructureMessages.unbalancedElements(completeId), getLocation(), null); invoke(false, POST_RENDER_CLEANUP); queue.endComponent(); }
/** * Pushes the SetupRender phase state onto the queue. */ public final void render(MarkupWriter writer, RenderQueue queue) { // TODO: An error if the render flag is already set (recursive rendering not // allowed or advisable). // TODO: Check for recursive rendering. renderingValue.set(true); queue.startComponent(coreResources); queue.push(new PostRenderCleanupPhase(writer.getElement())); push(queue, setupRenderPhase); }
private MethodResultCache getOrCreateCache(MethodInvocation invocation) { Object instance = invocation.getInstance(); // The PerThreadValue is created in the instance constructor. PerThreadValue<MethodResultCache> value = (PerThreadValue<MethodResultCache>) fieldHandle .get(instance); // But it will be empty when first created, or at the start of a new request. if (value.exists()) { return value.get(); } // Use the factory to create a MethodResultCache for the combination of instance, method, and thread. return value.set(factory.create(instance)); } };
private Map<String, Object> getRenderVariables(boolean create) { try { acquireReadLock(); if (renderVariables == null) { if (!create) { return null; } createRenderVariablesPerThreadValue(); } Map<String, Object> result = renderVariables.get(); if (result == null && create) result = renderVariables.set(CollectionFactory.newCaseInsensitiveMap()); return result; } finally { releaseReadLock(); } }