public HttpContext getHttpContext(ThreadScope scope) { return scope.get(HttpContext.SCOPE_KEY); }
public RouterContext getActionContext(ThreadScope threadScope) { return threadScope.get(RouterContext.SCOPE_KEY); }
public DataPort getDataPort(ThreadScope scope) { DataPort port = scope.get(DataPort.SCOPE_KEY); if (port == null) { throw new TeleException(NO_DATA_PORT_MSG); } return port; } }
@Override public final <P extends Profile> P getProfile() { // Check thread cache at first ProfileHolder holder = threadScope.get(ProfileHolder.SCOPE_KEY); if (holder != null) { return (P) holder.getProfile(); } DataPort port = dataPortProv.get(); Profile profile = profileReadControl(port); // Cache the profile threadScope.put(ProfileHolder.SCOPE_KEY, new ProfileHolder(profile)); return (P) profile; }
@Override public Bundle getBundle(final String basePath) { // Check thread scope for bundle final StringKey<Bundle> scopeKey = new StringKey<>(SCOPE_KEY_PREFIX + basePath); Bundle bundle = threadScope.get(scopeKey); if (bundle != null) { return bundle; } bundle = getBundle(basePath, true); // Reference the bundle from thread scope to fast access in the same thread threadScope.put(scopeKey, bundle); return bundle; }
@Override public final <P extends Principal> P getPrincipal() { // Check thread cache at first PrincipalHolder holder = threadScope.get(PrincipalHolder.SCOPE_KEY); if (holder != null) { return (P) holder.getPrincipal(); } // No principal in cache. Retrieve principal from client DataPort<Object, Object> port = dataPortProv.get(); Principal principal = principalReadControl(port); // Store principal to cache and return threadScope.put(PrincipalHolder.SCOPE_KEY, new PrincipalHolder(principal)); return (P) principal; }