All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.anysoft.rrm.RRModelManager Maven / Gradle / Ivy

There is a newer version: 1.6.17
Show newest version
package com.anysoft.rrm;

import java.util.Collection;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

import com.anysoft.util.Properties;

/**
 * 管理器
 * @author duanyy
 * @version 1.6.4.14 [20151126 duanyy] 
* - 增加list方法.
* * @version 1.9.6.7 [20170802 duanyy]
* - 修正多实例下的并发问题
* */ public class RRModelManager { private Map> rrms = new ConcurrentHashMap>(); public RRModel getModel(String id){ return (RRModel) rrms.get(id); } @SuppressWarnings("unchecked") public synchronized RRModel addModel(String id,Class clazz,Properties p){ RRModel found = (RRModel) rrms.get(id); if (found == null){ found = new RRModel(id); found.configure(p); rrms.put(id, found); } return found; } @SuppressWarnings("unchecked") public synchronized RRModel addModel(String id,data instance,Properties p){ RRModel found = (RRModel) rrms.get(id); if (found == null){ found = new RRModel(id); found.configure(p); found.update(System.currentTimeMillis(), instance); rrms.put(id, found); } return found; } 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; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy