added logging if we can't properly cast things when closing things down

git-svn-id: https://svn.apache.org/repos/asf/incubator/activemq/trunk@386099 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
James Strachan 2006-03-15 16:02:20 +00:00
parent 3c09f0cba5
commit 1629774d27
1 changed files with 19 additions and 4 deletions

View File

@ -29,6 +29,8 @@ import org.apache.activemq.store.MessageStore;
import org.apache.activemq.store.PersistenceAdapter; import org.apache.activemq.store.PersistenceAdapter;
import org.apache.activemq.store.TopicMessageStore; import org.apache.activemq.store.TopicMessageStore;
import org.apache.activemq.store.TransactionStore; import org.apache.activemq.store.TransactionStore;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import edu.emory.mathcs.backport.java.util.concurrent.ConcurrentHashMap; import edu.emory.mathcs.backport.java.util.concurrent.ConcurrentHashMap;
@ -38,6 +40,7 @@ import edu.emory.mathcs.backport.java.util.concurrent.ConcurrentHashMap;
* @version $Revision: 1.4 $ * @version $Revision: 1.4 $
*/ */
public class MemoryPersistenceAdapter implements PersistenceAdapter { public class MemoryPersistenceAdapter implements PersistenceAdapter {
private static final Log log = LogFactory.getLog(MemoryPersistenceAdapter.class);
MemoryTransactionStore transactionStore; MemoryTransactionStore transactionStore;
ConcurrentHashMap topics = new ConcurrentHashMap(); ConcurrentHashMap topics = new ConcurrentHashMap();
@ -111,13 +114,17 @@ public class MemoryPersistenceAdapter implements PersistenceAdapter {
public void deleteAllMessages() throws IOException { public void deleteAllMessages() throws IOException {
for (Iterator iter = topics.values().iterator(); iter.hasNext();) { for (Iterator iter = topics.values().iterator(); iter.hasNext();) {
MemoryMessageStore store = (MemoryMessageStore) iter.next(); MemoryMessageStore store = asMemoryMessageStore(iter.next());
if (store != null) {
store.delete(); store.delete();
} }
}
for (Iterator iter = queues.values().iterator(); iter.hasNext();) { for (Iterator iter = queues.values().iterator(); iter.hasNext();) {
MemoryMessageStore store = (MemoryMessageStore) iter.next(); MemoryMessageStore store = asMemoryMessageStore(iter.next());
if (store != null) {
store.delete(); store.delete();
} }
}
transactionStore.delete(); transactionStore.delete();
} }
@ -129,4 +136,12 @@ public class MemoryPersistenceAdapter implements PersistenceAdapter {
this.useExternalMessageReferences = useExternalMessageReferences; this.useExternalMessageReferences = useExternalMessageReferences;
} }
protected MemoryMessageStore asMemoryMessageStore(Object value) {
if (value instanceof MemoryMessageStore) {
return (MemoryMessageStore) value;
}
log.warn("Expected an instance of MemoryMessageStore but was: " + value);
return null;
}
} }