use of j.util.ConcurrentList in project JFramework by gugumall.
the class JObject method getStaticList.
/**
* @param key
* @return
*/
public static ConcurrentList getStaticList(String key) {
if (statics.containsKey(key)) {
return (ConcurrentList) statics.get(key);
} else {
ConcurrentList s = new ConcurrentList();
statics.put(key, s);
return s;
}
}
use of j.util.ConcurrentList in project JFramework by gugumall.
the class JCacheUnitMap method keys.
/*
* (non-Javadoc)
* @see j.cache.JCacheUnit#keys(j.cache.JCacheParams)
*/
public ConcurrentList keys(JCacheParams params) throws Exception {
checkStatus(false);
JCacheFilter keyFileter = params == null ? null : params.keyFilter;
JCacheFilter valueFilter = params == null ? null : params.valueFilter;
int recordsPerPage = params == null ? 0 : params.recordsPerPage;
int pageNum = params == null ? 0 : params.pageNum;
ConcurrentMap mappings = container.snapshot();
List keys = mappings.listKeys();
if (keyFileter != null || valueFilter != null) {
for (int i = 0; i < keys.size(); i++) {
Object key = keys.get(i);
Object value = mappings.get(key);
boolean remove = false;
if (keyFileter != null && !keyFileter.matches(key)) {
remove = true;
} else if (valueFilter != null && !valueFilter.matches(value)) {
remove = true;
}
if (remove) {
keys.remove(i);
}
}
}
mappings.clear();
mappings = null;
ConcurrentList result = new ConcurrentList();
result.setTotal(keys.size());
if (recordsPerPage > 0 && pageNum > 0) {
// 分页
int start = recordsPerPage * (pageNum - 1);
int to = recordsPerPage * pageNum;
if (start >= 0) {
if (keys.size() > start) {
keys = JUtilList.subConcurrentList(keys, start, to > keys.size() ? keys.size() : to);
} else {
keys.clear();
}
}
}
result.addAll(keys);
return result;
}
use of j.util.ConcurrentList in project JFramework by gugumall.
the class JDCache method keys.
/*
* (non-Javadoc)
* @see j.cache.JCache#keys(java.lang.String, j.cache.JCacheParams)
*/
public ConcurrentList keys(String cacheId, JCacheParams jdcParams) throws Exception {
Servant info = findService(cacheId);
if (info.service != null) {
return info.service.keys(cacheId, jdcParams);
} else {
Map params = new HashMap();
params.put("cacheId", cacheId);
params.put("params", JObject.serializable2String((Serializable) jdcParams));
String response = Client.httpCallPost(info.jhttp, info.jclient, info.serviceCode, info.httpChannel, "keys", params);
params.clear();
params = null;
return (ConcurrentList) JObject.string2Serializable(response);
}
}
use of j.util.ConcurrentList in project JFramework by gugumall.
the class JCacheUnitMap method values.
/*
* (non-Javadoc)
* @see j.cache.JCacheUnit#values(j.cache.JCacheParams)
*/
public ConcurrentList values(JCacheParams params) throws Exception {
checkStatus(false);
JCacheFilter keyFileter = params == null ? null : params.keyFilter;
JCacheFilter valueFilter = params == null ? null : params.valueFilter;
JUtilSorter sorter = params == null ? null : params.sorter;
String sortType = params == null ? null : params.sortType;
int recordsPerPage = params == null ? 0 : params.recordsPerPage;
int pageNum = params == null ? 0 : params.pageNum;
ConcurrentMap mappings = container.snapshot();
List values = null;
if (keyFileter != null || valueFilter != null) {
values = new ConcurrentList();
List keys = mappings.listKeys();
for (int i = 0; i < keys.size(); i++) {
Object key = keys.get(i);
Object value = mappings.get(key);
boolean remove = false;
if (keyFileter != null && !keyFileter.matches(key)) {
remove = true;
} else if (valueFilter != null && !valueFilter.matches(value)) {
remove = true;
}
if (!remove) {
values.add(value);
}
}
keys.clear();
keys = null;
} else {
values = mappings.listValues();
}
mappings.clear();
mappings = null;
if (sorter != null) {
// 排序
values = sorter.mergeSort(values, sortType);
}
ConcurrentList result = new ConcurrentList();
result.setTotal(values.size());
if (recordsPerPage > 0 && pageNum > 0) {
// 分页
int start = recordsPerPage * (pageNum - 1);
int to = recordsPerPage * pageNum;
if (start >= 0) {
if (values.size() > start) {
values = JUtilList.subConcurrentList(values, start, to > values.size() ? values.size() : to);
} else {
values.clear();
}
}
}
result.addAll(values);
return result;
}
use of j.util.ConcurrentList in project JFramework by gugumall.
the class ServiceManager method getServices.
/**
* @param code
* @param initializing
* @return
*/
public static ServiceConfig[] getServices(String code, boolean initializing) {
if (!initializing)
waitWhileLoading();
ConcurrentList ls = (ConcurrentList) servicesOfClusters.get(code);
if (ls == null)
return null;
else {
ServiceConfig[] array = new ServiceConfig[ls.size()];
ls.toArray(array);
return array;
}
}
Aggregations