1 7 package org.jboss.cache.loader; 8 9 import org.jboss.cache.CacheImpl; 10 import org.jboss.cache.Fqn; 11 import org.jboss.cache.NodeSPI; 12 import org.jboss.cache.config.CacheLoaderConfig.IndividualCacheLoaderConfig; 13 14 import java.io.ObjectInputStream ; 15 import java.io.ObjectOutputStream ; 16 import java.util.HashMap ; 17 import java.util.Map ; 18 import java.util.Set ; 19 20 36 public class LocalDelegatingCacheLoader extends DelegatingCacheLoader 37 { 38 39 IndividualCacheLoaderConfig config; 40 CacheImpl delegate = null; 41 42 public LocalDelegatingCacheLoader() 43 { 44 } 45 46 public LocalDelegatingCacheLoader(CacheImpl delegate) 47 { 48 this.delegate = delegate; 49 } 50 51 public void setConfig(IndividualCacheLoaderConfig config) 52 { 53 this.config = config; 54 } 55 56 public IndividualCacheLoaderConfig getConfig() 57 { 58 return config; 59 } 60 61 protected Set delegateGetChildrenNames(Fqn fqn) throws Exception 62 { 63 return delegate.getChildrenNames(fqn); 64 } 65 66 71 protected Map delegateGet(Fqn name) throws Exception 72 { 73 NodeSPI n = (NodeSPI) delegate.get(name); 74 if (n == null) return null; 75 Map m = n.getDataDirect(); 77 if (m == null) m = new HashMap (0); 78 return m; 79 } 80 81 protected void setDelegateCache(CacheImpl delegate) 82 { 83 this.delegate = delegate; 84 } 85 86 protected boolean delegateExists(Fqn name) throws Exception 87 { 88 return delegate.exists(name); 89 } 90 91 protected Object delegatePut(Fqn name, Object key, Object value) throws Exception 92 { 93 return delegate.put(name, key, value); 94 } 95 96 protected void delegatePut(Fqn name, Map attributes) throws Exception 97 { 98 delegate.put(name, attributes); 99 } 100 101 protected Object delegateRemove(Fqn name, Object key) throws Exception 102 { 103 return delegate.remove(name, key); 104 } 105 106 protected void delegateRemove(Fqn name) throws Exception 107 { 108 delegate.remove(name); 109 } 110 111 protected void delegateRemoveData(Fqn name) throws Exception 112 { 113 delegate.removeData(name); 114 } 115 116 protected void delegateLoadEntireState(ObjectOutputStream os) throws Exception 117 { 118 try 119 { 120 delegate.getStateTransferManager().getState(os, Fqn.ROOT, delegate.getConfiguration().getInitialStateRetrievalTimeout(), true, false); 130 } 131 catch (Exception e) 132 { 133 throw e; 134 } 135 catch (Throwable t) 136 { 137 throw new RuntimeException ("Caught exception getting state from delegate", t); 138 } 139 } 140 141 protected void delegateLoadState(Fqn subtree, ObjectOutputStream os) throws Exception 142 { 143 throw new UnsupportedOperationException ("setting and loading state for specific Fqns not supported"); 144 } 145 146 protected void delegateStoreEntireState(ObjectInputStream is) throws Exception 147 { 148 delegate.getStateTransferManager().setState(is, Fqn.ROOT, null); 149 150 } 151 152 protected void delegateStoreState(Fqn subtree, ObjectInputStream is) throws Exception 153 { 154 throw new UnsupportedOperationException ("setting and loading state for specific Fqns not supported"); 155 } 156 157 } 158 | Popular Tags |