1 package org.jboss.remoting.callback; 2 3 import java.io.IOException ; 4 import java.io.Serializable ; 5 import java.util.Map ; 6 import org.jboss.logging.Logger; 7 import org.jboss.remoting.SerializableStore; 8 9 16 public class NullCallbackStore implements SerializableStore, Serializable 17 { 18 static final long serialVersionUID = -8182007953992756845L; 19 20 private boolean isCallbackLost = false; 21 22 private static final Logger log = Logger.getLogger(NullCallbackStore.class); 23 24 29 public int size() 30 { 31 return isCallbackLost ? 1 : 0; 32 } 33 34 43 public Object getNext() throws IOException 44 { 45 if(isCallbackLost) 46 { 47 isCallbackLost = false; 48 return new FailedCallback("This is an invalid callback. The server ran out of memory, so callbacks were lost."); 49 } 50 else 51 { 52 return null; 53 } 54 } 55 56 64 public void add(Serializable object) throws IOException 65 { 66 isCallbackLost = true; 67 log.error("Lost callback because not enough free memory available. Callback lost was " + object); 68 throw new IOException ("Callback has been lost because not enough free memory to hold object."); 69 } 70 71 76 public void setConfig(Map config) 77 { 78 } 79 80 85 public void start() throws Exception 86 { 87 } 88 89 92 public void stop() 93 { 94 } 95 96 101 public void create() throws Exception 102 { 103 } 104 105 108 public void destroy() 109 { 110 } 111 112 117 public void setPurgeOnShutdown(boolean purgeOnShutdown) 118 { 119 } 120 121 126 public boolean getPurgeOnShutdown() 127 { 128 return false; 129 } 130 131 public void purgeFiles() 132 { 133 } 134 135 public class FailedCallback extends Callback 136 { 137 138 public FailedCallback(Object callbackPayload) 139 { 140 super(callbackPayload); 141 } 142 143 public Object getCallbackObject() 144 { 145 throw new RuntimeException ("This is an invalid callback. The server ran out of memory, so callbacks were lost."); 146 } 147 } 148 } 149 | Popular Tags |