com.anysoft.rrm.RRModelManager Maven / Gradle / Ivy
package com.anysoft.rrm;
import java.util.Collection;
import java.util.Hashtable;
import com.anysoft.util.Properties;
/**
* 管理器
* @author duanyy
* @version 1.6.4.14 [20151126 duanyy]
* - 增加list方法.
*/
public class RRModelManager {
private Hashtable> rrms = new Hashtable>();
public RRModel extends RRData> getModel(String id){
return (RRModel extends RRData>) rrms.get(id);
}
public RRModel addModel(String id,Class clazz,Properties p){
RRModel newModel = new RRModel(id);
newModel.configure(p);
rrms.put(id, newModel);
return newModel;
}
public RRModel addModel(String id,data instance,Properties p){
RRModel newModel = new RRModel(id);
newModel.configure(p);
newModel.update(System.currentTimeMillis(), instance);
rrms.put(id, newModel);
return newModel;
}
public RRModel addModel(String id,RRModel newModel){
rrms.put(id, newModel);
return newModel;
}
public void remove(String id){
rrms.remove(id);
}
public void clear(){
rrms.clear();
}
public Collection> list(){
return rrms.values();
}
protected static RRModelManager instance = new RRModelManager();
public static synchronized RRModelManager get(){
return instance;
}
}