1 19 20 package org.openharmonise.rm.publishing; 21 22 import org.openharmonise.commons.cache.*; 23 import org.openharmonise.commons.dsi.*; 24 import org.openharmonise.rm.sessions.*; 25 26 27 34 public final class WebPageEngineCache extends AbstractCache { 35 private static WebPageEngineCache m_instance = null; 36 private static final String m_sClassname = "WebPageEngine"; 37 38 protected AbstractDataStoreInterface m_dbintrf = null; 39 40 46 private WebPageEngineCache(AbstractDataStoreInterface dbinterf) throws CacheException { 47 super(m_sClassname); 48 49 m_dbintrf = dbinterf; 50 } 51 52 59 public synchronized static WebPageEngineCache getInstance(AbstractDataStoreInterface dbinterf) throws CacheException { 60 if (m_instance == null) { 61 m_instance = new WebPageEngineCache(dbinterf); 62 } 63 64 return m_instance; 65 } 66 67 74 public WebPageEngine getWebPageEngine(String object_id) throws CacheException { 75 final WebPageEngine cached_object = (WebPageEngine) this.getObject( 76 object_id); 77 78 if (cached_object == null) { 79 throw new RuntimeException ( 80 "Cached WebPageEngine was returned as null."); 81 } 82 83 return cached_object; 84 } 85 86 87 90 protected Object getCacheableObject(Object object_id) 91 throws Exception { 92 if (object_id == null) { 93 throw new IllegalArgumentException (m_sClassname + 94 " id must be passed " + 95 " to GetCacheableObject object_id:" + 96 object_id); 97 } 98 99 Object object = new WebPageEngine(this.m_dbintrf, (String ) object_id); 100 101 if (object == null) { 102 throw new RuntimeException ( 103 "Could not get WebPageEngine for WebPageEngine:" + 104 object_id); 105 } 106 107 return object; 108 } 109 110 113 public void addToCache(Object key, Object cacheable_object) { 114 String sKey = Session.removeSessionIdPrefix((String ) key); 115 super.addToCache(sKey, cacheable_object); 116 } 117 } | Popular Tags |