1 7 package org.jboss.remoting; 8 9 import org.jboss.logging.Logger; 10 11 import java.io.IOException ; 12 import java.io.Serializable ; 13 import java.util.Map ; 14 15 22 public class NullCallbackStore implements SerializableStore, Serializable 23 { 24 static final long serialVersionUID = -8182007953992756845L; 25 private boolean isCallbackLost = false; 26 27 private static final Logger log = Logger.getLogger(NullCallbackStore.class); 28 29 34 public int size() 35 { 36 return isCallbackLost ? 1 : 0; 37 } 38 39 48 public Object getNext() throws IOException 49 { 50 if(isCallbackLost) 51 { 52 isCallbackLost = false; 53 return new FailedCallback("This is an invalid callback. The server ran out of memory, so callbacks were lost."); 54 } 55 else 56 { 57 return null; 58 } 59 } 60 61 69 public void add(Serializable object) throws IOException 70 { 71 isCallbackLost = true; 72 log.error("Lost callback because not enough free memory available. Callback lost was " + object); 73 throw new IOException ("Callback has been lost because not enough free memory to hold object."); 74 } 75 76 81 public void setConfig(Map config) 82 { 83 } 84 85 90 public void start() throws Exception 91 { 92 } 93 94 97 public void stop() 98 { 99 } 100 101 106 public void create() throws Exception 107 { 108 } 109 110 113 public void destroy() 114 { 115 } 116 117 122 public void setPurgeOnShutdown(boolean purgeOnShutdown) 123 { 124 } 125 126 131 public boolean getPurgeOnShutdown() 132 { 133 return false; 134 } 135 136 public void purgeFiles() 137 { 138 } 139 140 public class FailedCallback extends Callback 141 { 142 143 public FailedCallback(Object callbackPayload) 144 { 145 super(callbackPayload); 146 } 147 148 public Object getCallbackObject() 149 { 150 throw new RuntimeException ("This is an invalid callback. The server ran out of memory, so callbacks were lost."); 151 } 152 } 153 } 154 | Popular Tags |