use of lucee.runtime.type.scope.client.IKStorageScopeClient in project Lucee by lucee.
the class IKStorageScopeSupport method getInstance.
public static Scope getInstance(int scope, IKHandler handler, String appName, String name, PageContext pc, Scope existing, Log log) throws PageException {
IKStorageValue sv = null;
if (Scope.SCOPE_SESSION == scope)
sv = handler.loadData(pc, appName, name, "session", Scope.SCOPE_SESSION, log);
else if (Scope.SCOPE_CLIENT == scope)
sv = handler.loadData(pc, appName, name, "client", Scope.SCOPE_CLIENT, log);
if (sv != null) {
long time = sv.lastModified();
if (existing instanceof IKStorageScopeSupport) {
IKStorageScopeSupport tmp = ((IKStorageScopeSupport) existing);
if (tmp.lastModified() >= time && name.equalsIgnoreCase(tmp.getStorage())) {
return existing;
}
}
if (Scope.SCOPE_SESSION == scope)
return new IKStorageScopeSession(pc, handler, appName, name, sv.getValue(), time);
else if (Scope.SCOPE_CLIENT == scope)
return new IKStorageScopeClient(pc, handler, appName, name, sv.getValue(), time);
} else if (existing instanceof IKStorageScopeSupport) {
IKStorageScopeSupport tmp = ((IKStorageScopeSupport) existing);
if (name.equalsIgnoreCase(tmp.getStorage())) {
return existing;
}
}
IKStorageScopeSupport rtn = null;
ConcurrentHashMapPro<Key, IKStorageScopeItem> map = new ConcurrentHashMapPro<Collection.Key, IKStorageScopeItem>();
if (Scope.SCOPE_SESSION == scope)
rtn = new IKStorageScopeSession(pc, handler, appName, name, map, 0);
else if (Scope.SCOPE_CLIENT == scope)
rtn = new IKStorageScopeClient(pc, handler, appName, name, map, 0);
rtn.store(pc);
return rtn;
}
Aggregations