@Override public String getAttribute(String name) { if (updated != null) return updated.getAttribute(name); return cached.getAttributes().get(name); }
@Override public String getBaseUrl() { if (updated != null) return updated.getBaseUrl(); return cached.getBaseUrl(); }
@Override public String getClientAuthenticatorType() { if (updated != null) return updated.getClientAuthenticatorType(); return cached.getClientAuthenticatorType(); }
@Override public ClientModel getClientById(String id, RealmModel realm) { if (!cache.isEnabled()) return getDelegate().getClientById(id, realm); CachedClient cached = cache.getApplication(id); if (cached != null && !cached.getRealm().equals(realm.getId())) { cached = null; } if (cached == null) { ClientModel model = getDelegate().getClientById(id, realm); if (model == null) return null; if (appInvalidations.contains(id)) return model; cached = new CachedClient(cache, getDelegate(), realm, model); cache.addCachedClient(cached); } else if (appInvalidations.contains(id)) { return getDelegate().getClientById(id, realm); } else if (managedApplications.containsKey(id)) { return managedApplications.get(id); } ClientAdapter adapter = new ClientAdapter(realm, cached, this, cache); managedApplications.put(id, adapter); return adapter; } @Override
private void remove(Object object) { if (object instanceof CachedRealm) { CachedRealm realm = (CachedRealm) object; realmLookup.remove(realm.getName()); for (String r : realm.getRealmRoles().values()) { realmCache.evictCachedRoleById(r); } for (String c : realm.getClients().values()) { realmCache.evictCachedApplicationById(c); } log.tracev("Realm removed realm={0}", realm.getName()); } else if (object instanceof CachedClient) { CachedClient client = (CachedClient) object; for (String r : client.getRoles().values()) { realmCache.evictCachedRoleById(r); } log.tracev("Client removed client={0}", client.getId()); } } }
CachedClient cachedClient = new CachedClient(cache, delegate, model, client); cache.addCachedClient(cachedClient);
@Override public ClientTemplateModel getClientTemplate() { if (updated != null) return updated.getClientTemplate(); if (cached.getClientTemplate() == null) return null; return cacheSession.getClientTemplateById(cached.getClientTemplate(), cachedRealm); }
@Override public String getClientId() { if (updated != null) return updated.getClientId(); return cached.getClientId(); }
@Override public String getDescription() { if (updated != null) return updated.getDescription(); return cached.getDescription(); }
@Override public String getManagementUrl() { if (updated != null) return updated.getManagementUrl(); return cached.getManagementUrl(); }
@Override public List<String> getDefaultRoles() { if (updated != null) return updated.getDefaultRoles(); return cached.getDefaultRoles(); }
@Override public String getId() { if (updated != null) return updated.getId(); return cached.getId(); }
@Override public Map<String, String> getAttributes() { if (updated != null) return updated.getAttributes(); Map<String, String> copy = new HashMap<String, String>(); copy.putAll(cached.getAttributes()); return copy; }