diff options
author | Keith Wall <kwall@apache.org> | 2014-06-13 16:52:33 +0000 |
---|---|---|
committer | Keith Wall <kwall@apache.org> | 2014-06-13 16:52:33 +0000 |
commit | 80c035cd28b2e0f643e00877a69ab73b4c81d356 (patch) | |
tree | 3005ab4e1f598b724c43222f853125ef602393fc /java | |
parent | e99117956fa997fee274cdad39f5702a183a0935 (diff) | |
download | qpid-python-80c035cd28b2e0f643e00877a69ab73b4c81d356.tar.gz |
QPID-5802: [Java Broker] Refactor VH implementations to avoid duplicated message store/message store subject code.
This addresses review comments from Alex Rudyy.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@1602475 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java')
9 files changed, 35 insertions, 160 deletions
diff --git a/java/bdbstore/src/main/java/org/apache/qpid/server/virtualhost/berkeleydb/BDBHAVirtualHostImpl.java b/java/bdbstore/src/main/java/org/apache/qpid/server/virtualhost/berkeleydb/BDBHAVirtualHostImpl.java index f66d157246..6ba0a4dd39 100644 --- a/java/bdbstore/src/main/java/org/apache/qpid/server/virtualhost/berkeleydb/BDBHAVirtualHostImpl.java +++ b/java/bdbstore/src/main/java/org/apache/qpid/server/virtualhost/berkeleydb/BDBHAVirtualHostImpl.java @@ -23,13 +23,11 @@ package org.apache.qpid.server.virtualhost.berkeleydb; import java.util.Map; import java.util.Set; -import org.apache.qpid.server.logging.subjects.MessageStoreLogSubject; import org.apache.qpid.server.model.ConfiguredObject; import org.apache.qpid.server.model.ManagedAttributeField; import org.apache.qpid.server.model.ManagedObject; import org.apache.qpid.server.model.ManagedObjectFactoryConstructor; import org.apache.qpid.server.model.VirtualHostNode; -import org.apache.qpid.server.store.DurableConfigurationStore; import org.apache.qpid.server.store.MessageStore; import org.apache.qpid.server.store.berkeleydb.BDBConfigurationStore; import org.apache.qpid.server.store.berkeleydb.replication.ReplicatedEnvironmentFacade; @@ -43,7 +41,6 @@ public class BDBHAVirtualHostImpl extends AbstractVirtualHost<BDBHAVirtualHostIm public static final String TYPE = "BDB_HA"; private final BDBConfigurationStore _configurationStore; - private MessageStoreLogSubject _messageStoreLogSubject; @ManagedAttributeField(afterSet="setLocalTransactionSynchronizationPolicyOnEnvironment") private String _localTransactionSynchronizationPolicy; @@ -57,33 +54,15 @@ public class BDBHAVirtualHostImpl extends AbstractVirtualHost<BDBHAVirtualHostIm super(attributes, virtualHostNode); _configurationStore = (BDBConfigurationStore) virtualHostNode.getConfigurationStore(); - _messageStoreLogSubject = new MessageStoreLogSubject(getName(), _configurationStore.getMessageStore().getClass().getSimpleName()); } @Override - protected void initialiseStorage() - { - } - - @Override - public DurableConfigurationStore getDurableConfigurationStore() - { - return _configurationStore; - } - - @Override - public MessageStore getMessageStore() + protected MessageStore createMessageStore() { return _configurationStore.getMessageStore(); } @Override - protected MessageStoreLogSubject getMessageStoreLogSubject() - { - return _messageStoreLogSubject; - } - - @Override public String getLocalTransactionSynchronizationPolicy() { return _localTransactionSynchronizationPolicy; @@ -152,7 +131,7 @@ public class BDBHAVirtualHostImpl extends AbstractVirtualHost<BDBHAVirtualHostIm } catch(Exception e) { - throw new IllegalArgumentException("Invalid transaction syncronization policy '" + policy + "'. " + e.getMessage()); + throw new IllegalArgumentException("Invalid transaction synchronization policy '" + policy + "'. " + e.getMessage()); } } diff --git a/java/bdbstore/src/main/java/org/apache/qpid/server/virtualhost/berkeleydb/BDBVirtualHost.java b/java/bdbstore/src/main/java/org/apache/qpid/server/virtualhost/berkeleydb/BDBVirtualHost.java index 51fdcd1f2b..2f1c9f9387 100644 --- a/java/bdbstore/src/main/java/org/apache/qpid/server/virtualhost/berkeleydb/BDBVirtualHost.java +++ b/java/bdbstore/src/main/java/org/apache/qpid/server/virtualhost/berkeleydb/BDBVirtualHost.java @@ -22,7 +22,6 @@ package org.apache.qpid.server.virtualhost.berkeleydb; 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; @@ -34,8 +33,6 @@ import org.apache.qpid.server.virtualhost.AbstractVirtualHost; public class BDBVirtualHost extends AbstractVirtualHost<BDBVirtualHost> { public static final String VIRTUAL_HOST_TYPE = "BDB"; - private MessageStore _messageStore; - private MessageStoreLogSubject _messageStoreLogSubject; @ManagedObjectFactoryConstructor public BDBVirtualHost(final Map<String, Object> attributes, @@ -46,23 +43,8 @@ public class BDBVirtualHost extends AbstractVirtualHost<BDBVirtualHost> @Override - protected void initialiseStorage() + protected MessageStore createMessageStore() { - _messageStore = new BDBConfigurationStore().getMessageStore(); - - _messageStoreLogSubject = new MessageStoreLogSubject(getName(), _messageStore.getClass().getSimpleName()); - - } - - @Override - protected MessageStoreLogSubject getMessageStoreLogSubject() - { - return _messageStoreLogSubject; - } - - @Override - public MessageStore getMessageStore() - { - return _messageStore; + return new BDBConfigurationStore().getMessageStore(); } } 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; - } } diff --git a/java/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/virtualhost/derby/DerbyVirtualHost.java b/java/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/virtualhost/derby/DerbyVirtualHost.java index 5a5511becf..31c3f7c944 100644 --- a/java/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/virtualhost/derby/DerbyVirtualHost.java +++ b/java/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/virtualhost/derby/DerbyVirtualHost.java @@ -22,7 +22,6 @@ package org.apache.qpid.server.virtualhost.derby; 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; @@ -34,8 +33,6 @@ import org.apache.qpid.server.virtualhost.AbstractVirtualHost; public class DerbyVirtualHost extends AbstractVirtualHost<DerbyVirtualHost> { public static final String VIRTUAL_HOST_TYPE = "DERBY"; - private MessageStore _messageStore; - private MessageStoreLogSubject _messageStoreLogSubject; @ManagedObjectFactoryConstructor public DerbyVirtualHost(final Map<String, Object> attributes, @@ -46,23 +43,9 @@ public class DerbyVirtualHost extends AbstractVirtualHost<DerbyVirtualHost> @Override - protected void initialiseStorage() + protected MessageStore createMessageStore() { - _messageStore = new DerbyMessageStore().getMessageStore(); - - _messageStoreLogSubject = new MessageStoreLogSubject(getName(), _messageStore.getClass().getSimpleName()); - + return new DerbyMessageStore().getMessageStore(); } - @Override - protected MessageStoreLogSubject getMessageStoreLogSubject() - { - return _messageStoreLogSubject; - } - - @Override - public MessageStore getMessageStore() - { - return _messageStore; - } } diff --git a/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/virtualhost/jdbc/JDBCVirtualHost.java b/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/virtualhost/jdbc/JDBCVirtualHost.java index 8acf474321..1dd39a8696 100644 --- a/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/virtualhost/jdbc/JDBCVirtualHost.java +++ b/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/virtualhost/jdbc/JDBCVirtualHost.java @@ -22,7 +22,6 @@ package org.apache.qpid.server.virtualhost.jdbc; 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; @@ -34,8 +33,6 @@ import org.apache.qpid.server.virtualhost.AbstractVirtualHost; public class JDBCVirtualHost extends AbstractVirtualHost<JDBCVirtualHost> { public static final String VIRTUAL_HOST_TYPE = "JDBC"; - private MessageStore _messageStore; - private MessageStoreLogSubject _messageStoreLogSubject; @ManagedObjectFactoryConstructor public JDBCVirtualHost(final Map<String, Object> attributes, @@ -46,23 +43,8 @@ public class JDBCVirtualHost extends AbstractVirtualHost<JDBCVirtualHost> @Override - protected void initialiseStorage() + protected MessageStore createMessageStore() { - _messageStore = new JDBCMessageStore().getMessageStore(); - - _messageStoreLogSubject = new MessageStoreLogSubject(getName(), _messageStore.getClass().getSimpleName()); - - } - - @Override - protected MessageStoreLogSubject getMessageStoreLogSubject() - { - return _messageStoreLogSubject; - } - - @Override - public MessageStore getMessageStore() - { - return _messageStore; + return new JDBCMessageStore().getMessageStore(); } } diff --git a/java/broker-plugins/memory-store/src/main/java/org/apache/qpid/server/virtualhost/memory/MemoryVirtualHost.java b/java/broker-plugins/memory-store/src/main/java/org/apache/qpid/server/virtualhost/memory/MemoryVirtualHost.java index ebd32d79a7..5c86f734d0 100644 --- a/java/broker-plugins/memory-store/src/main/java/org/apache/qpid/server/virtualhost/memory/MemoryVirtualHost.java +++ b/java/broker-plugins/memory-store/src/main/java/org/apache/qpid/server/virtualhost/memory/MemoryVirtualHost.java @@ -22,7 +22,6 @@ package org.apache.qpid.server.virtualhost.memory; 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; @@ -34,8 +33,6 @@ import org.apache.qpid.server.virtualhost.AbstractVirtualHost; public class MemoryVirtualHost extends AbstractVirtualHost<MemoryVirtualHost> { public static final String VIRTUAL_HOST_TYPE = "Memory"; - private MessageStore _messageStore; - private MessageStoreLogSubject _messageStoreLogSubject; @ManagedObjectFactoryConstructor public MemoryVirtualHost(final Map<String, Object> attributes, @@ -46,23 +43,8 @@ public class MemoryVirtualHost extends AbstractVirtualHost<MemoryVirtualHost> @Override - protected void initialiseStorage() + protected MessageStore createMessageStore() { - _messageStore = new MemoryMessageStore(); - - _messageStoreLogSubject = new MessageStoreLogSubject(getName(), _messageStore.getClass().getSimpleName()); - - } - - @Override - protected MessageStoreLogSubject getMessageStoreLogSubject() - { - return _messageStoreLogSubject; - } - - @Override - public MessageStore getMessageStore() - { - return _messageStore; + return new MemoryMessageStore(); } } |