Advertisement
Guest User

Untitled

a guest
Aug 28th, 2014
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. public class SopFactory{
  2. private static Map<String, List<ConfigObject>> confs = new HashMap<String, List<ConfigObject>>();
  3.  
  4. public Sop createSop(name){
  5. List<ConfigObject> conf = null;
  6. if((conf = confs.get(name) == null){
  7. conf = loadConf(name);
  8. confs.put(name, conf)
  9. }
  10. return new Sop(conf);
  11. }
  12.  
  13. public static void init(){
  14. // load configuration into conf
  15. }
  16.  
  17. public static void destory(){
  18. conf.clear();
  19. conf = null;
  20. }
  21.  
  22. private List<ConfigObject> loadConf(String confName){
  23. // ...
  24. }
  25. }
  26.  
  27. public class Sop{
  28. // reference to cached configuration in SopFactory
  29. // it's for read only
  30. // for thread safety, never expose this to client
  31. private List<ConfigObject> conf;
  32.  
  33. protected Sop(List<ConfigObject> conf){
  34. this.conf = conf;
  35. }
  36.  
  37. public void send(Object data){
  38. for(ConfigObjecto : conf){
  39. // access configuration information to assemble packet
  40. }
  41. }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement