mirror of https://github.com/apache/activemq.git
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:
parent
3c09f0cba5
commit
1629774d27
|
@ -29,6 +29,8 @@ import org.apache.activemq.store.MessageStore;
|
|||
import org.apache.activemq.store.PersistenceAdapter;
|
||||
import org.apache.activemq.store.TopicMessageStore;
|
||||
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;
|
||||
|
||||
|
@ -38,6 +40,7 @@ import edu.emory.mathcs.backport.java.util.concurrent.ConcurrentHashMap;
|
|||
* @version $Revision: 1.4 $
|
||||
*/
|
||||
public class MemoryPersistenceAdapter implements PersistenceAdapter {
|
||||
private static final Log log = LogFactory.getLog(MemoryPersistenceAdapter.class);
|
||||
|
||||
MemoryTransactionStore transactionStore;
|
||||
ConcurrentHashMap topics = new ConcurrentHashMap();
|
||||
|
@ -111,13 +114,17 @@ public class MemoryPersistenceAdapter implements PersistenceAdapter {
|
|||
|
||||
public void deleteAllMessages() throws IOException {
|
||||
for (Iterator iter = topics.values().iterator(); iter.hasNext();) {
|
||||
MemoryMessageStore store = (MemoryMessageStore) iter.next();
|
||||
MemoryMessageStore store = asMemoryMessageStore(iter.next());
|
||||
if (store != null) {
|
||||
store.delete();
|
||||
}
|
||||
}
|
||||
for (Iterator iter = queues.values().iterator(); iter.hasNext();) {
|
||||
MemoryMessageStore store = (MemoryMessageStore) iter.next();
|
||||
MemoryMessageStore store = asMemoryMessageStore(iter.next());
|
||||
if (store != null) {
|
||||
store.delete();
|
||||
}
|
||||
}
|
||||
transactionStore.delete();
|
||||
}
|
||||
|
||||
|
@ -129,4 +136,12 @@ public class MemoryPersistenceAdapter implements PersistenceAdapter {
|
|||
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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue