1 32 33 package com.knowgate.dataxslt; 34 35 import java.util.HashMap ; 36 37 47 import java.lang.ref.SoftReference ; 48 49 public class MicrositeFactory { 50 public static boolean bCache = true; 51 public static HashMap oMicrosites = new HashMap (); 52 53 public MicrositeFactory() { 54 } 55 56 59 public static boolean cache () { 60 return bCache; 61 } 62 63 68 public static void cache (boolean bCacheOnOf) { 69 bCache = bCacheOnOf; 70 if (false==bCacheOnOf) 71 oMicrosites.clear(); 72 } 73 74 85 public static synchronized Microsite getInstance(String sURI, boolean bValidateXML) throws ClassNotFoundException , Exception , IllegalAccessException { 86 Microsite oRetObj; 87 Object oRefObj; 88 89 if (bCache) { 90 oRefObj = oMicrosites.get(sURI); 91 92 if (null == oRefObj) { 93 oRetObj = new Microsite(sURI, bValidateXML); 94 oMicrosites.put(sURI, new SoftReference (oRetObj)); 95 } 96 else { 97 oRetObj = (Microsite) ( (SoftReference ) oRefObj).get(); 98 if (null == oRetObj) 99 oRetObj = new Microsite(sURI, bValidateXML); 100 } 101 return oRetObj; 102 } 103 else 104 oRetObj = new Microsite(sURI, bValidateXML); 105 106 return oRetObj; 107 } 109 111 120 121 public static Microsite getInstance(String sURI) throws ClassNotFoundException , Exception , IllegalAccessException { 122 return getInstance(sURI, false); 123 } }
| Popular Tags
|