Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class SopFactory{
- private static Map<String, List<ConfigObject>> confs = new HashMap<String, List<ConfigObject>>();
- public Sop createSop(name){
- List<ConfigObject> conf = null;
- if((conf = confs.get(name) == null){
- conf = loadConf(name);
- confs.put(name, conf)
- }
- return new Sop(conf);
- }
- public static void init(){
- // load configuration into conf
- }
- public static void destory(){
- conf.clear();
- conf = null;
- }
- private List<ConfigObject> loadConf(String confName){
- // ...
- }
- }
- public class Sop{
- // reference to cached configuration in SopFactory
- // it's for read only
- // for thread safety, never expose this to client
- private List<ConfigObject> conf;
- protected Sop(List<ConfigObject> conf){
- this.conf = conf;
- }
- public void send(Object data){
- for(ConfigObjecto : conf){
- // access configuration information to assemble packet
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement