1 16 package org.apache.cocoon.caching.impl; 17 18 import java.io.IOException ; 19 20 import org.apache.avalon.framework.service.ServiceException; 21 import org.apache.avalon.framework.service.ServiceManager; 22 import org.apache.avalon.framework.service.Serviceable; 23 import org.apache.excalibur.store.Store; 24 25 33 public class StoreEventRegistryImpl extends AbstractDoubleMapEventRegistry 34 implements Serviceable { 35 36 private static final String EVENTREGISTRYKEY = "EVENTREGWRAPPER"; 37 private ServiceManager m_manager; 38 private Store m_store; 39 40 protected void persist(EventRegistryDataWrapper wrapper) { 41 EventRegistryDataWrapper ecdw = wrapRegistry(); 42 try { 43 m_store.store(EVENTREGISTRYKEY, ecdw); 44 } catch (IOException e) { 45 getLogger().warn("Unable to persist Event Registry"); 46 } 47 this.m_manager.release(this.m_store); 48 m_manager = null; 49 m_store = null; 50 } 51 52 55 public void service(ServiceManager manager) throws ServiceException { 56 this.m_manager = manager; 57 this.m_store = (Store) manager.lookup(Store.ROLE); 58 } 59 60 63 protected boolean recover() { 64 Object o = m_store.get(EVENTREGISTRYKEY); 65 m_store.remove(EVENTREGISTRYKEY); 66 if (o != null && o instanceof EventRegistryDataWrapper) { 67 if (getLogger().isInfoEnabled()) { 68 getLogger().info("Retrieving EventRegistry from Store."); 69 } 70 unwrapRegistry((EventRegistryDataWrapper) o); 71 return true; 72 } else { 73 getLogger().warn("Unable to recover Event Registry."); 74 super.createBlankCache(); 75 return false; 76 } 77 } 78 79 } 80 | Popular Tags |