diff options
Diffstat (limited to 'java/broker-core/src')
4 files changed, 25 insertions, 58 deletions
diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/AbstractVirtualHost.java b/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/AbstractVirtualHost.java index db749caf88..9ef1fd889a 100644 --- a/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/AbstractVirtualHost.java +++ b/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/AbstractVirtualHost.java @@ -127,6 +127,8 @@ public abstract class AbstractVirtualHost<X extends AbstractVirtualHost<X>> exte private final AtomicBoolean _deleted = new AtomicBoolean(); private final VirtualHostNode<?> _virtualHostNode; + private MessageStoreLogSubject _messageStoreLogSubject; + @ManagedAttributeField private Map<String, Object> _messageStoreSettings; @@ -153,6 +155,8 @@ public abstract class AbstractVirtualHost<X extends AbstractVirtualHost<X>> exte private MessageDestination _defaultDestination; + private MessageStore _messageStore; + public AbstractVirtualHost(final Map<String, Object> attributes, VirtualHostNode<?> virtualHostNode) { super(parentsMap(virtualHostNode), attributes); @@ -206,24 +210,24 @@ public abstract class AbstractVirtualHost<X extends AbstractVirtualHost<X>> exte } @Override + public MessageStore getMessageStore() + { + return _messageStore; + } + + @Override protected void onOpen() { super.onOpen(); registerSystemNodes(); - Subject.doAs(SecurityManager.getSubjectWithAddedSystemRights(), new PrivilegedAction<Object>() - { - @Override - public Object run() - { - initialiseStorage(); - return null; - } - }); + _messageStore = createMessageStore(); - getMessageStore().addEventListener(this, Event.PERSISTENT_MESSAGE_SIZE_OVERFULL); - getMessageStore().addEventListener(this, Event.PERSISTENT_MESSAGE_SIZE_UNDERFULL); + _messageStoreLogSubject = new MessageStoreLogSubject(getName(), _messageStore.getClass().getSimpleName()); + + _messageStore.addEventListener(this, Event.PERSISTENT_MESSAGE_SIZE_OVERFULL); + _messageStore.addEventListener(this, Event.PERSISTENT_MESSAGE_SIZE_UNDERFULL); synchronized(_aliases) @@ -259,7 +263,7 @@ public abstract class AbstractVirtualHost<X extends AbstractVirtualHost<X>> exte } } - abstract protected void initialiseStorage(); + protected abstract MessageStore createMessageStore(); protected boolean isStoreEmpty() { @@ -295,7 +299,10 @@ public abstract class AbstractVirtualHost<X extends AbstractVirtualHost<X>> exte }); } - abstract protected MessageStoreLogSubject getMessageStoreLogSubject(); + protected MessageStoreLogSubject getMessageStoreLogSubject() + { + return _messageStoreLogSubject; + } public IConnectionRegistry getConnectionRegistry() { diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/ProvidedStoreVirtualHost.java b/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/ProvidedStoreVirtualHost.java index ac8d6c34fd..347ef820d3 100644 --- a/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/ProvidedStoreVirtualHost.java +++ b/java/broker-core/src/main/java/org/apache/qpid/server/virtualhost/ProvidedStoreVirtualHost.java @@ -23,7 +23,6 @@ package org.apache.qpid.server.virtualhost; import java.util.Map; import org.apache.qpid.server.configuration.IllegalConfigurationException; -import org.apache.qpid.server.logging.subjects.MessageStoreLogSubject; import org.apache.qpid.server.model.ManagedObject; import org.apache.qpid.server.model.ManagedObjectFactoryConstructor; import org.apache.qpid.server.model.VirtualHostNode; @@ -35,8 +34,6 @@ import org.apache.qpid.server.store.MessageStoreProvider; public class ProvidedStoreVirtualHost extends AbstractVirtualHost<ProvidedStoreVirtualHost> { public static final String VIRTUAL_HOST_TYPE = "ProvidedStore"; - private MessageStore _messageStore; - private MessageStoreLogSubject _messageStoreLogSubject; @ManagedObjectFactoryConstructor public ProvidedStoreVirtualHost(final Map<String, Object> attributes, @@ -62,26 +59,12 @@ public class ProvidedStoreVirtualHost extends AbstractVirtualHost<ProvidedStoreV } @Override - protected void initialiseStorage() + protected MessageStore createMessageStore() { VirtualHostNode<?> virtualHostNode = getParent(VirtualHostNode.class); - MessageStoreProvider messageStoreProvider = (MessageStoreProvider) virtualHostNode.getConfigurationStore(); - _messageStore = messageStoreProvider.getMessageStore(); - - _messageStoreLogSubject = new MessageStoreLogSubject(getName(), _messageStore.getClass().getSimpleName()); - + return messageStoreProvider.getMessageStore(); } +} - @Override - protected MessageStoreLogSubject getMessageStoreLogSubject() - { - return _messageStoreLogSubject; - } - @Override - public MessageStore getMessageStore() - { - return _messageStore; - } -} diff --git a/java/broker-core/src/test/java/org/apache/qpid/server/virtualhost/MockVirtualHost.java b/java/broker-core/src/test/java/org/apache/qpid/server/virtualhost/MockVirtualHost.java index 64c2cdbd95..be4d7ae49d 100644 --- a/java/broker-core/src/test/java/org/apache/qpid/server/virtualhost/MockVirtualHost.java +++ b/java/broker-core/src/test/java/org/apache/qpid/server/virtualhost/MockVirtualHost.java @@ -44,7 +44,6 @@ import org.apache.qpid.server.model.VirtualHostAlias; import org.apache.qpid.server.protocol.LinkRegistry; import org.apache.qpid.server.queue.AMQQueue; import org.apache.qpid.server.security.SecurityManager; -import org.apache.qpid.server.security.auth.manager.AuthenticationManager; import org.apache.qpid.server.stats.StatisticsCounter; import org.apache.qpid.server.store.ConfiguredObjectRecord; import org.apache.qpid.server.store.DurableConfigurationStore; @@ -65,11 +64,6 @@ public class MockVirtualHost implements VirtualHostImpl<MockVirtualHost, AMQQueu } - public AuthenticationManager getAuthenticationManager() - { - return null; - } - public DtxRegistry getDtxRegistry() { return null; diff --git a/java/broker-core/src/test/java/org/apache/qpid/server/virtualhost/TestMemoryVirtualHost.java b/java/broker-core/src/test/java/org/apache/qpid/server/virtualhost/TestMemoryVirtualHost.java index 472e7a0820..99ed026620 100644 --- a/java/broker-core/src/test/java/org/apache/qpid/server/virtualhost/TestMemoryVirtualHost.java +++ b/java/broker-core/src/test/java/org/apache/qpid/server/virtualhost/TestMemoryVirtualHost.java @@ -22,7 +22,6 @@ package org.apache.qpid.server.virtualhost; import java.util.Map; -import org.apache.qpid.server.logging.subjects.MessageStoreLogSubject; import org.apache.qpid.server.model.ManagedObject; import org.apache.qpid.server.model.ManagedObjectFactoryConstructor; import org.apache.qpid.server.model.VirtualHostNode; @@ -33,8 +32,6 @@ import org.apache.qpid.server.store.TestMemoryMessageStore; public class TestMemoryVirtualHost extends AbstractVirtualHost<TestMemoryVirtualHost> { public static final String VIRTUAL_HOST_TYPE = "TestMemory"; - private MessageStore _messageStore; - private MessageStoreLogSubject _messageStoreLogSubject; @ManagedObjectFactoryConstructor public TestMemoryVirtualHost(final Map<String, Object> attributes, @@ -45,23 +42,9 @@ public class TestMemoryVirtualHost extends AbstractVirtualHost<TestMemoryVirtual @Override - protected void initialiseStorage() + protected MessageStore createMessageStore() { - _messageStore = new TestMemoryMessageStore(); - - _messageStoreLogSubject = new MessageStoreLogSubject(getName(), _messageStore.getClass().getSimpleName()); - + return new TestMemoryMessageStore(); } - @Override - protected MessageStoreLogSubject getMessageStoreLogSubject() - { - return _messageStoreLogSubject; - } - - @Override - public MessageStore getMessageStore() - { - return _messageStore; - } } |