1 10 11 package com.triactive.jdo.store; 12 13 import com.triactive.jdo.PersistenceManagerFactoryImpl; 14 import java.util.HashMap ; 15 import java.util.Map ; 16 import java.util.WeakHashMap ; 17 18 19 public class StoreManagerFactory 20 { 21 private static final Map cachesByPMF = new WeakHashMap (); 22 23 private StoreManagerFactory() 24 { 25 } 26 27 public static synchronized StoreManager getStoreManager(PersistenceManagerFactoryImpl pmf, 28 String userName, 29 String password) 30 { 31 Map managersByLogon = (Map )cachesByPMF.get(pmf); 32 33 if (managersByLogon == null) 34 { 35 managersByLogon = new HashMap (); 36 cachesByPMF.put(pmf, managersByLogon); 37 } 38 39 String key = "" + userName + ';' + password; 40 StoreManager storeMgr = (StoreManager)managersByLogon.get(key); 41 42 if (storeMgr == null) 43 { 44 storeMgr = new StoreManager(pmf, userName, password); 45 46 managersByLogon.put(key, storeMgr); 47 } 48 49 return storeMgr; 50 } 51 } 52 | Popular Tags |