resolve https://issues.apache.org/activemq/browse/AMQ-2064 - persistence Adapter and temp store are now associated with the simple xbean system usage in the default activemq.xml

git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@734194 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Gary Tully 2009-01-13 17:41:50 +00:00
parent 4dc1fccfdb
commit b5b6a0834d
4 changed files with 22 additions and 1 deletions

View File

@ -16,7 +16,10 @@
*/
package org.apache.activemq.xbean;
import java.io.IOException;
import org.apache.activemq.broker.BrokerService;
import org.apache.activemq.usage.SystemUsage;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;
@ -48,6 +51,7 @@ public class XBeanBrokerService extends BrokerService implements InitializingBea
}
public void afterPropertiesSet() throws Exception {
ensureSystemUsageHasStore();
if (start) {
start();
}
@ -62,6 +66,16 @@ public class XBeanBrokerService extends BrokerService implements InitializingBea
}
}
private void ensureSystemUsageHasStore() throws IOException {
SystemUsage usage = getSystemUsage();
if (usage.getStoreUsage().getStore() == null) {
usage.getStoreUsage().setStore(getPersistenceAdapter());
}
if (usage.getTempUsage().getStore() == null) {
usage.getTempUsage().setStore(getTempDataStore());
}
}
public void destroy() throws Exception {
stop();
}

View File

@ -104,6 +104,8 @@ public class ConfigTest extends TestCase {
// System.out.print("Checking persistence adapter factory
// settings... ");
broker.getPersistenceAdapter();
assertTrue(broker.getSystemUsage().getStoreUsage().getStore() instanceof JournalPersistenceAdapter);
LOG.info("Success");
} finally {
@ -240,6 +242,9 @@ public class ConfigTest extends TestCase {
assertEquals("SystemUsage Config Error (TempUsage.limit)", 1024 * 1024 * 100, systemUsage.getTempUsage().getLimit());
assertEquals("SystemUsage Config Error (StoreUsage.limit)", 1024 * 1024 * 1024, systemUsage.getStoreUsage().getLimit());
assertEquals("SystemUsage Config Error (StoreUsage.name)", "foo", systemUsage.getStoreUsage().getName());
assertNotNull(systemUsage.getStoreUsage().getStore());
assertTrue(systemUsage.getStoreUsage().getStore() instanceof MemoryPersistenceAdapter);
LOG.info("Success");

View File

@ -75,6 +75,9 @@ public class MemoryPropertyTest extends TestCase {
assertEquals(1024, broker.getSystemUsage().getMemoryUsage().getLimit());
assertEquals(34, broker.getSystemUsage().getMemoryUsage().getPercentUsageMinDelta());
assertNotNull(broker.getSystemUsage().getStoreUsage().getStore());
// non persistent broker so no temp storage
assertNull(broker.getSystemUsage().getTempUsage().getStore());
}
}

View File

@ -40,7 +40,6 @@ public class FailoverTimeoutTest extends TestCase {
try {
producer.send(message);
} catch (JMSException jmse) {
jmse.printStackTrace();
assertEquals("Failover timeout of " + timeout + " ms reached.", jmse.getMessage());
}