diff options
Diffstat (limited to 'java')
26 files changed, 36 insertions, 719 deletions
diff --git a/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBMessageStoreFactory.java b/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBMessageStoreFactory.java deleted file mode 100644 index 067372a228..0000000000 --- a/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBMessageStoreFactory.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.server.store.berkeleydb; - -import java.util.Map; - -import org.apache.qpid.server.model.VirtualHost; -import org.apache.qpid.server.plugin.DurableConfigurationStoreFactory; -import org.apache.qpid.server.plugin.MessageStoreFactory; -import org.apache.qpid.server.plugin.PluggableService; -import org.apache.qpid.server.store.DurableConfigurationStore; -import org.apache.qpid.server.store.MessageStore; - -@PluggableService -public class BDBMessageStoreFactory implements MessageStoreFactory, DurableConfigurationStoreFactory -{ - - @Override - public String getType() - { - return StandardEnvironmentFacade.TYPE; - } - - @Override - public DurableConfigurationStore createDurableConfigurationStore() - { - return new BDBConfigurationStore(); - } - - @Override - public MessageStore createMessageStore() - { - return (new BDBConfigurationStore()).getMessageStore(); - } - - @Override - public void validateAttributes(Map<String, Object> attributes) - { - @SuppressWarnings("unchecked") - Map<String, Object> messageStoreSettings = (Map<String, Object>) attributes.get(VirtualHost.MESSAGE_STORE_SETTINGS); - if(messageStoreSettings != null && getType().equals(messageStoreSettings.get(MessageStore.STORE_TYPE))) - { - Object storePath = messageStoreSettings.get(MessageStore.STORE_PATH); - if(!(storePath instanceof String)) - { - throw new IllegalArgumentException("Setting '"+ MessageStore.STORE_PATH - +"' is required and must be of type String."); - - } - } - } - - @Override - public void validateConfigurationStoreSettings(Map<String, Object> configurationStoreSettings) - { - if(configurationStoreSettings != null && getType().equals(configurationStoreSettings.get(DurableConfigurationStore.STORE_TYPE))) - { - Object storePath = configurationStoreSettings.get(DurableConfigurationStore.STORE_PATH); - if(!(storePath instanceof String)) - { - throw new IllegalArgumentException("Durable configuration store setting '" + DurableConfigurationStore.STORE_PATH - + "' is required and must be of type String."); - - } - } - } -} diff --git a/java/bdbstore/src/main/java/org/apache/qpid/server/virtualhostnode/berkeleydb/BDBVirtualHostNodeImpl.java b/java/bdbstore/src/main/java/org/apache/qpid/server/virtualhostnode/berkeleydb/BDBVirtualHostNodeImpl.java index 138c0717a2..591623510f 100644 --- a/java/bdbstore/src/main/java/org/apache/qpid/server/virtualhostnode/berkeleydb/BDBVirtualHostNodeImpl.java +++ b/java/bdbstore/src/main/java/org/apache/qpid/server/virtualhostnode/berkeleydb/BDBVirtualHostNodeImpl.java @@ -26,8 +26,8 @@ import org.apache.qpid.server.model.Broker; 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.plugin.DurableConfigurationStoreFactory; -import org.apache.qpid.server.store.berkeleydb.BDBMessageStoreFactory; +import org.apache.qpid.server.store.DurableConfigurationStore; +import org.apache.qpid.server.store.berkeleydb.BDBConfigurationStore; import org.apache.qpid.server.virtualhostnode.AbstractStandardVirtualHostNode; @ManagedObject( category = false, type = "BDB" ) @@ -46,9 +46,9 @@ public class BDBVirtualHostNodeImpl extends AbstractStandardVirtualHostNode<BDBV } @Override - protected DurableConfigurationStoreFactory getDurableConfigurationStoreFactory() + protected DurableConfigurationStore createConfigurationStore() { - return new BDBMessageStoreFactory(); + return new BDBConfigurationStore(); } @Override @@ -56,7 +56,6 @@ public class BDBVirtualHostNodeImpl extends AbstractStandardVirtualHostNode<BDBV { return _environmentConfiguration; } - @Override public String getStorePath() { diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/model/Broker.java b/java/broker-core/src/main/java/org/apache/qpid/server/model/Broker.java index 4443a3199d..53c1e7f7f4 100644 --- a/java/broker-core/src/main/java/org/apache/qpid/server/model/Broker.java +++ b/java/broker-core/src/main/java/org/apache/qpid/server/model/Broker.java @@ -41,7 +41,7 @@ public interface Broker<X extends Broker<X>> extends ConfiguredObject<X>, EventL String PROCESS_PID = "processPid"; String PRODUCT_VERSION = "productVersion"; String SUPPORTED_VIRTUALHOST_TYPES = "supportedVirtualHostTypes"; - String SUPPORTED_VIRTUALHOST_STORE_TYPES = "supportedVirtualHostStoreTypes"; + String SUPPORTED_VIRTUALHOSTNODE_TYPES = "supportedVirtualHostNodeTypes"; String SUPPORTED_AUTHENTICATION_PROVIDERS = "supportedAuthenticationProviders"; String SUPPORTED_PREFERENCES_PROVIDER_TYPES = "supportedPreferencesProviderTypes"; String DEFAULT_VIRTUAL_HOST = "defaultVirtualHost"; @@ -93,9 +93,6 @@ public interface Broker<X extends Broker<X>> extends ConfiguredObject<X>, EventL Collection<String> getSupportedVirtualHostNodeTypes(); @DerivedAttribute - Collection<String> getSupportedVirtualHostStoreTypes(); - - @DerivedAttribute Collection<String> getSupportedAuthenticationProviders(); @DerivedAttribute diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/BrokerAdapter.java b/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/BrokerAdapter.java index e6d7f44e0c..77eda0dc67 100644 --- a/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/BrokerAdapter.java +++ b/java/broker-core/src/main/java/org/apache/qpid/server/model/adapter/BrokerAdapter.java @@ -47,7 +47,6 @@ import org.apache.qpid.server.logging.messages.BrokerMessages; import org.apache.qpid.server.logging.messages.VirtualHostMessages; import org.apache.qpid.server.model.*; import org.apache.qpid.server.model.port.AbstractPortWithAuthProvider; -import org.apache.qpid.server.plugin.MessageStoreFactory; import org.apache.qpid.server.security.SecurityManager; import org.apache.qpid.server.security.SubjectCreator; import org.apache.qpid.server.security.access.Operation; @@ -71,13 +70,10 @@ public class BrokerAdapter extends AbstractConfiguredObject<BrokerAdapter> imple private EventLogger _eventLogger; - //private final VirtualHostRegistry _virtualHostRegistry; private final LogRecorder _logRecorder; private final SecurityManager _securityManager; - private final Collection<String> _supportedVirtualHostStoreTypes; - private AuthenticationProvider<?> _managementModeAuthenticationProvider; private BrokerOptions _brokerOptions; @@ -109,7 +105,6 @@ public class BrokerAdapter extends AbstractConfiguredObject<BrokerAdapter> imple _eventLogger = parent.getEventLogger(); _brokerOptions = parent.getBrokerOptions(); _securityManager = new SecurityManager(this, _brokerOptions.isManagementMode()); - _supportedVirtualHostStoreTypes = MessageStoreFactory.FACTORY_LOADER.getSupportedTypes(); if (_brokerOptions.isManagementMode()) { Map<String,Object> authManagerAttrs = new HashMap<String, Object>(); @@ -311,12 +306,6 @@ public class BrokerAdapter extends AbstractConfiguredObject<BrokerAdapter> imple } @Override - public Collection<String> getSupportedVirtualHostStoreTypes() - { - return _supportedVirtualHostStoreTypes; - } - - @Override public Collection<String> getSupportedVirtualHostTypes() { return getObjectFactory().getSupportedTypes(VirtualHost.class); diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/plugin/DurableConfigurationStoreFactory.java b/java/broker-core/src/main/java/org/apache/qpid/server/plugin/DurableConfigurationStoreFactory.java deleted file mode 100644 index ba398f129d..0000000000 --- a/java/broker-core/src/main/java/org/apache/qpid/server/plugin/DurableConfigurationStoreFactory.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.server.plugin; - -import java.util.Map; - -import org.apache.qpid.server.store.DurableConfigurationStore; - -public interface DurableConfigurationStoreFactory extends Pluggable -{ - PluggableFactoryLoader<DurableConfigurationStoreFactory> FACTORY_LOADER = new PluggableFactoryLoader<DurableConfigurationStoreFactory>(DurableConfigurationStoreFactory.class); - - String getType(); - - DurableConfigurationStore createDurableConfigurationStore(); - - void validateConfigurationStoreSettings(Map<String, Object> attributes); -} diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/plugin/MessageStoreFactory.java b/java/broker-core/src/main/java/org/apache/qpid/server/plugin/MessageStoreFactory.java deleted file mode 100644 index bae6738f23..0000000000 --- a/java/broker-core/src/main/java/org/apache/qpid/server/plugin/MessageStoreFactory.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.server.plugin; - -import java.util.Map; - -import org.apache.qpid.server.store.MessageStore; - -public interface MessageStoreFactory extends Pluggable -{ - PluggableFactoryLoader<MessageStoreFactory> FACTORY_LOADER = new PluggableFactoryLoader<MessageStoreFactory>(MessageStoreFactory.class); - - String getType(); - - MessageStore createMessageStore(); - - void validateAttributes(Map<String, Object> attributes); -} diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/store/JsonFileConfigStoreFactory.java b/java/broker-core/src/main/java/org/apache/qpid/server/store/JsonFileConfigStoreFactory.java deleted file mode 100644 index ea1f41d7ab..0000000000 --- a/java/broker-core/src/main/java/org/apache/qpid/server/store/JsonFileConfigStoreFactory.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.server.store; - -import java.util.Map; - -import org.apache.qpid.server.plugin.DurableConfigurationStoreFactory; -import org.apache.qpid.server.plugin.PluggableService; - -@PluggableService -public class JsonFileConfigStoreFactory implements DurableConfigurationStoreFactory -{ - @Override - public String getType() - { - return JsonFileConfigStore.TYPE; - } - - @Override - public DurableConfigurationStore createDurableConfigurationStore() - { - return new JsonFileConfigStore(); - } - - @Override - public void validateConfigurationStoreSettings(Map<String, Object> attributes) - { - Object storePath = attributes.get(DurableConfigurationStore.STORE_PATH); - if(!(storePath instanceof String)) - { - throw new IllegalArgumentException("Setting '"+ DurableConfigurationStore.STORE_PATH - +"' is required and must be of type String."); - - } - } - -} diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/virtualhostnode/AbstractStandardVirtualHostNode.java b/java/broker-core/src/main/java/org/apache/qpid/server/virtualhostnode/AbstractStandardVirtualHostNode.java index 7f460aae4f..e37eeb17bf 100644 --- a/java/broker-core/src/main/java/org/apache/qpid/server/virtualhostnode/AbstractStandardVirtualHostNode.java +++ b/java/broker-core/src/main/java/org/apache/qpid/server/virtualhostnode/AbstractStandardVirtualHostNode.java @@ -38,9 +38,7 @@ import org.apache.qpid.server.model.ConfiguredObject; import org.apache.qpid.server.model.RemoteReplicationNode; import org.apache.qpid.server.model.VirtualHost; import org.apache.qpid.server.model.VirtualHostNode; -import org.apache.qpid.server.plugin.DurableConfigurationStoreFactory; import org.apache.qpid.server.security.SecurityManager; -import org.apache.qpid.server.store.DurableConfigurationStore; import org.apache.qpid.server.store.MessageStore; import org.apache.qpid.server.store.MessageStoreProvider; import org.apache.qpid.server.store.VirtualHostStoreUpgraderAndRecoverer; @@ -57,16 +55,6 @@ public abstract class AbstractStandardVirtualHostNode<X extends AbstractStandard super(parent, attributes); } - @Override - public void onValidate() - { - super.onValidate(); - DurableConfigurationStoreFactory durableConfigurationStoreFactory = getDurableConfigurationStoreFactory(); - Map<String, Object> storeSettings = new HashMap<String, Object>(getActualAttributes()); - storeSettings.put(DurableConfigurationStore.STORE_TYPE, durableConfigurationStoreFactory.getType()); - durableConfigurationStoreFactory.validateConfigurationStoreSettings(storeSettings); - } - @SuppressWarnings({ "rawtypes", "unchecked" }) @Override protected <C extends ConfiguredObject> C addChild(Class<C> childClass, Map<String, Object> attributes, @@ -80,16 +68,6 @@ public abstract class AbstractStandardVirtualHostNode<X extends AbstractStandard } @Override - protected DurableConfigurationStore createConfigurationStore() - { - DurableConfigurationStoreFactory durableConfigurationStoreFactory = getDurableConfigurationStoreFactory(); - DurableConfigurationStore store = durableConfigurationStoreFactory.createDurableConfigurationStore(); - return store; - } - - protected abstract DurableConfigurationStoreFactory getDurableConfigurationStoreFactory(); - - @Override protected void activate() { if (LOGGER.isDebugEnabled()) diff --git a/java/broker-core/src/main/java/org/apache/qpid/server/virtualhostnode/JsonVirtualHostNodeImpl.java b/java/broker-core/src/main/java/org/apache/qpid/server/virtualhostnode/JsonVirtualHostNodeImpl.java index f41b794953..67f690a2b9 100644 --- a/java/broker-core/src/main/java/org/apache/qpid/server/virtualhostnode/JsonVirtualHostNodeImpl.java +++ b/java/broker-core/src/main/java/org/apache/qpid/server/virtualhostnode/JsonVirtualHostNodeImpl.java @@ -26,8 +26,8 @@ import org.apache.qpid.server.model.Broker; 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.plugin.DurableConfigurationStoreFactory; -import org.apache.qpid.server.store.JsonFileConfigStoreFactory; +import org.apache.qpid.server.store.DurableConfigurationStore; +import org.apache.qpid.server.store.JsonFileConfigStore; @ManagedObject(category=false, type="JSON") public class JsonVirtualHostNodeImpl extends AbstractStandardVirtualHostNode<JsonVirtualHostNodeImpl> implements FileBasedVirtualHostNode<JsonVirtualHostNodeImpl> @@ -42,9 +42,9 @@ public class JsonVirtualHostNodeImpl extends AbstractStandardVirtualHostNode<Jso } @Override - protected DurableConfigurationStoreFactory getDurableConfigurationStoreFactory() + protected DurableConfigurationStore createConfigurationStore() { - return new JsonFileConfigStoreFactory(); + return new JsonFileConfigStore(); } @Override @@ -58,5 +58,4 @@ public class JsonVirtualHostNodeImpl extends AbstractStandardVirtualHostNode<Jso { return getClass().getSimpleName() + " [id=" + getId() + ", name=" + getName() + ", storePath=" + getStorePath() + "]"; } - } diff --git a/java/broker-core/src/test/java/org/apache/qpid/server/store/TestMemoryMessageStoreFactory.java b/java/broker-core/src/test/java/org/apache/qpid/server/store/TestMemoryMessageStoreFactory.java deleted file mode 100644 index df17884495..0000000000 --- a/java/broker-core/src/test/java/org/apache/qpid/server/store/TestMemoryMessageStoreFactory.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ - -package org.apache.qpid.server.store; - -import java.util.Map; - -import org.apache.qpid.server.plugin.DurableConfigurationStoreFactory; -import org.apache.qpid.server.plugin.MessageStoreFactory; - -public class TestMemoryMessageStoreFactory implements MessageStoreFactory, DurableConfigurationStoreFactory -{ - - @Override - public String getType() - { - return TestMemoryMessageStore.TYPE; - } - - @Override - public MessageStore createMessageStore() - { - return new TestMemoryMessageStore(); - } - - @Override - public void validateAttributes(Map<String, Object> attributes) - { - } - - @Override - public DurableConfigurationStore createDurableConfigurationStore() - { - return new AbstractMemoryStore() - { - }; - } - - @Override - public void validateConfigurationStoreSettings(Map<String, Object> attributes) - { - } -} diff --git a/java/broker-core/src/test/java/org/apache/qpid/server/virtualhostnode/AbstractStandardVirtualHostNodeTest.java b/java/broker-core/src/test/java/org/apache/qpid/server/virtualhostnode/AbstractStandardVirtualHostNodeTest.java index 220e9e94de..e0a56bc39c 100644 --- a/java/broker-core/src/test/java/org/apache/qpid/server/virtualhostnode/AbstractStandardVirtualHostNodeTest.java +++ b/java/broker-core/src/test/java/org/apache/qpid/server/virtualhostnode/AbstractStandardVirtualHostNodeTest.java @@ -37,13 +37,10 @@ import org.apache.qpid.server.model.State; import org.apache.qpid.server.model.SystemContext; import org.apache.qpid.server.model.VirtualHost; import org.apache.qpid.server.model.VirtualHostNode; -import org.apache.qpid.server.plugin.DurableConfigurationStoreFactory; import org.apache.qpid.server.store.ConfiguredObjectRecord; import org.apache.qpid.server.store.DurableConfigurationStore; -import org.apache.qpid.server.store.MessageStore; import org.apache.qpid.server.store.NullMessageStore; import org.apache.qpid.server.store.StoreException; -import org.apache.qpid.server.store.TestMemoryMessageStore; import org.apache.qpid.server.store.handler.ConfiguredObjectRecordHandler; import org.apache.qpid.server.util.BrokerTestHelper; import org.apache.qpid.server.virtualhost.TestMemoryVirtualHost; @@ -54,7 +51,6 @@ public class AbstractStandardVirtualHostNodeTest extends QpidTestCase private static final String TEST_VIRTUAL_HOST_NODE_NAME = "testNode"; private static final String TEST_VIRTUAL_HOST_NAME = "testVirtualHost"; - private DurableConfigurationStoreFactory _configStoreFactory = mock(DurableConfigurationStoreFactory.class); private UUID _nodeId = UUID.randomUUID(); private Broker<?> _broker; private DurableConfigurationStore _configStore; @@ -102,7 +98,6 @@ public class AbstractStandardVirtualHostNodeTest extends QpidTestCase handler.end(); } }; - when(_configStoreFactory.createDurableConfigurationStore()).thenReturn(_configStore); Map<String, Object> nodeAttributes = new HashMap<String, Object>(); nodeAttributes.put(VirtualHostNode.NAME, TEST_VIRTUAL_HOST_NODE_NAME); @@ -131,7 +126,6 @@ public class AbstractStandardVirtualHostNodeTest extends QpidTestCase handler.end(); } }; - when(_configStoreFactory.createDurableConfigurationStore()).thenReturn(_configStore); Map<String, Object> nodeAttributes = new HashMap<String, Object>(); nodeAttributes.put(VirtualHostNode.NAME, TEST_VIRTUAL_HOST_NODE_NAME); @@ -156,9 +150,6 @@ public class AbstractStandardVirtualHostNodeTest extends QpidTestCase virtualHostAttributes.put(VirtualHost.NAME, TEST_VIRTUAL_HOST_NAME); virtualHostAttributes.put(VirtualHost.TYPE, TestMemoryVirtualHost.VIRTUAL_HOST_TYPE); virtualHostAttributes.put(VirtualHost.MODEL_VERSION, BrokerModel.MODEL_VERSION); - Map<String,Object> messageStoreSettings = new HashMap<String, Object>(); - virtualHostAttributes.put(VirtualHost.MESSAGE_STORE_SETTINGS, messageStoreSettings); - messageStoreSettings.put(MessageStore.STORE_TYPE, TestMemoryMessageStore.TYPE); ConfiguredObjectRecord record = mock(ConfiguredObjectRecord.class); when(record.getId()).thenReturn(virtualHostId); diff --git a/java/broker-core/src/test/java/org/apache/qpid/server/virtualhostnode/TestVirtualHostNode.java b/java/broker-core/src/test/java/org/apache/qpid/server/virtualhostnode/TestVirtualHostNode.java index eda07bd846..16a9aa5550 100644 --- a/java/broker-core/src/test/java/org/apache/qpid/server/virtualhostnode/TestVirtualHostNode.java +++ b/java/broker-core/src/test/java/org/apache/qpid/server/virtualhostnode/TestVirtualHostNode.java @@ -25,11 +25,10 @@ import java.util.Map; import org.apache.qpid.server.model.Broker; import org.apache.qpid.server.model.ManagedObject; -import org.apache.qpid.server.plugin.DurableConfigurationStoreFactory; import org.apache.qpid.server.store.DurableConfigurationStore; import org.apache.qpid.server.store.MessageStore; import org.apache.qpid.server.store.TestMemoryMessageStore; -import org.apache.qpid.server.store.TestMemoryMessageStoreFactory; + @ManagedObject(type="TestMemory", category=false) public class TestVirtualHostNode extends AbstractStandardVirtualHostNode<TestVirtualHostNode> { @@ -49,33 +48,9 @@ public class TestVirtualHostNode extends AbstractStandardVirtualHostNode<TestVir } @Override - protected DurableConfigurationStoreFactory getDurableConfigurationStoreFactory() + protected DurableConfigurationStore createConfigurationStore() { - if (_store != null) - { - return new DurableConfigurationStoreFactory() - { - - @Override - public void validateConfigurationStoreSettings(Map<String, Object> attributes) - { - } - - @Override - public String getType() - { - return null; - } - - @Override - public DurableConfigurationStore createDurableConfigurationStore() - { - return _store; - } - }; - } - - return new TestMemoryMessageStoreFactory(); + return _store; } @Override diff --git a/java/broker-core/src/test/resources/META-INF/services/org.apache.qpid.server.plugin.DurableConfigurationStoreFactory b/java/broker-core/src/test/resources/META-INF/services/org.apache.qpid.server.plugin.DurableConfigurationStoreFactory deleted file mode 100644 index 9512fb8117..0000000000 --- a/java/broker-core/src/test/resources/META-INF/services/org.apache.qpid.server.plugin.DurableConfigurationStoreFactory +++ /dev/null @@ -1,19 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# -org.apache.qpid.server.store.TestMemoryMessageStoreFactory diff --git a/java/broker-core/src/test/resources/META-INF/services/org.apache.qpid.server.plugin.MessageStoreFactory b/java/broker-core/src/test/resources/META-INF/services/org.apache.qpid.server.plugin.MessageStoreFactory deleted file mode 100644 index 9512fb8117..0000000000 --- a/java/broker-core/src/test/resources/META-INF/services/org.apache.qpid.server.plugin.MessageStoreFactory +++ /dev/null @@ -1,19 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# -org.apache.qpid.server.store.TestMemoryMessageStoreFactory diff --git a/java/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/store/derby/DerbyMessageStoreFactory.java b/java/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/store/derby/DerbyMessageStoreFactory.java deleted file mode 100644 index 9bc3780a71..0000000000 --- a/java/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/store/derby/DerbyMessageStoreFactory.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.server.store.derby; - -import java.util.Map; - -import org.apache.qpid.server.model.VirtualHost; -import org.apache.qpid.server.plugin.DurableConfigurationStoreFactory; -import org.apache.qpid.server.plugin.MessageStoreFactory; -import org.apache.qpid.server.plugin.PluggableService; -import org.apache.qpid.server.store.DurableConfigurationStore; -import org.apache.qpid.server.store.MessageStore; - -@PluggableService -public class DerbyMessageStoreFactory implements MessageStoreFactory, DurableConfigurationStoreFactory -{ - - @Override - public String getType() - { - return DerbyMessageStore.TYPE; - } - - @Override - public DurableConfigurationStore createDurableConfigurationStore() - { - return new DerbyMessageStore(); - } - - @Override - public MessageStore createMessageStore() - { - return (new DerbyMessageStore()).getMessageStore(); - } - - @Override - public void validateAttributes(Map<String, Object> attributes) - { - @SuppressWarnings("unchecked") - Map<String, Object> messageStoreSettings = (Map<String, Object>) attributes.get(VirtualHost.MESSAGE_STORE_SETTINGS); - - if(getType().equals(messageStoreSettings.get(MessageStore.STORE_TYPE))) - { - Object storePath = messageStoreSettings.get(MessageStore.STORE_PATH); - if(!(storePath instanceof String)) - { - throw new IllegalArgumentException("Setting '"+ MessageStore.STORE_PATH - +"' is required and must be of type String."); - - } - } - - } - - @Override - public void validateConfigurationStoreSettings(Map<String, Object> configurationStoreSettings) - { - if(configurationStoreSettings != null && getType().equals(configurationStoreSettings.get(DurableConfigurationStore.STORE_TYPE))) - { - Object storePath = configurationStoreSettings.get(DurableConfigurationStore.STORE_PATH); - if(!(storePath instanceof String)) - { - throw new IllegalArgumentException("Setting '"+ DurableConfigurationStore.STORE_PATH - +"' is required and must be of type String."); - - } - } - } - -} diff --git a/java/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/virtualhostnode/derby/DerbyVirtualHostNode.java b/java/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/virtualhostnode/derby/DerbyVirtualHostNode.java index f65cc78f6a..9dc68d0343 100644 --- a/java/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/virtualhostnode/derby/DerbyVirtualHostNode.java +++ b/java/broker-plugins/derby-store/src/main/java/org/apache/qpid/server/virtualhostnode/derby/DerbyVirtualHostNode.java @@ -27,8 +27,8 @@ import org.apache.qpid.server.model.Broker; 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.plugin.DurableConfigurationStoreFactory; -import org.apache.qpid.server.store.derby.DerbyMessageStoreFactory; +import org.apache.qpid.server.store.DurableConfigurationStore; +import org.apache.qpid.server.store.derby.DerbyMessageStore; import org.apache.qpid.server.virtualhostnode.AbstractStandardVirtualHostNode; import org.apache.qpid.server.virtualhostnode.FileBasedVirtualHostNode; @@ -45,9 +45,9 @@ public class DerbyVirtualHostNode extends AbstractStandardVirtualHostNode<DerbyV } @Override - protected DurableConfigurationStoreFactory getDurableConfigurationStoreFactory() + protected DurableConfigurationStore createConfigurationStore() { - return new DerbyMessageStoreFactory(); + return new DerbyMessageStore(); } @Override diff --git a/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/JDBCMessageStoreFactory.java b/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/JDBCMessageStoreFactory.java deleted file mode 100644 index ab7ac6c671..0000000000 --- a/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/JDBCMessageStoreFactory.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.server.store.jdbc; - -import java.util.Map; - -import org.apache.qpid.server.model.VirtualHost; -import org.apache.qpid.server.plugin.DurableConfigurationStoreFactory; -import org.apache.qpid.server.plugin.MessageStoreFactory; -import org.apache.qpid.server.plugin.PluggableService; -import org.apache.qpid.server.store.DurableConfigurationStore; -import org.apache.qpid.server.store.MessageStore; - -@PluggableService -public class JDBCMessageStoreFactory implements MessageStoreFactory, DurableConfigurationStoreFactory -{ - - @Override - public String getType() - { - return JDBCMessageStore.TYPE; - } - - @Override - public MessageStore createMessageStore() - { - return (new JDBCMessageStore()).getMessageStore(); - } - - @Override - public DurableConfigurationStore createDurableConfigurationStore() - { - return new JDBCMessageStore(); - } - - @Override - public void validateAttributes(Map<String, Object> attributes) - { - @SuppressWarnings("unchecked") - Map<String, Object> messageStoreSettings = (Map<String, Object>) attributes.get(VirtualHost.MESSAGE_STORE_SETTINGS); - if(getType().equals(messageStoreSettings.get(MessageStore.STORE_TYPE))) - { - Object connectionURL = messageStoreSettings.get(JDBCMessageStore.CONNECTION_URL); - if(!(connectionURL instanceof String)) - { - throw new IllegalArgumentException("Setting '"+ JDBCMessageStore.CONNECTION_URL - +"' is required and must be of type String."); - - } - } - } - - @Override - public void validateConfigurationStoreSettings(Map<String, Object> configurationStoreSettings) - { - if(configurationStoreSettings != null && getType().equals(configurationStoreSettings.get(DurableConfigurationStore.STORE_TYPE))) - { - Object connectionURL = configurationStoreSettings.get(JDBCMessageStore.CONNECTION_URL); - if(!(connectionURL instanceof String)) - { - throw new IllegalArgumentException("Setting '"+ JDBCMessageStore.CONNECTION_URL - +"' is required and must be of type String."); - } - } - } - -} diff --git a/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/virtualhostnode/jdbc/JDBCVirtualHostNodeImpl.java b/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/virtualhostnode/jdbc/JDBCVirtualHostNodeImpl.java index cb3077bc65..29986335d0 100644 --- a/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/virtualhostnode/jdbc/JDBCVirtualHostNodeImpl.java +++ b/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/virtualhostnode/jdbc/JDBCVirtualHostNodeImpl.java @@ -26,8 +26,8 @@ import org.apache.qpid.server.model.Broker; 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.plugin.DurableConfigurationStoreFactory; -import org.apache.qpid.server.store.jdbc.JDBCMessageStoreFactory; +import org.apache.qpid.server.store.DurableConfigurationStore; +import org.apache.qpid.server.store.jdbc.JDBCMessageStore; import org.apache.qpid.server.virtualhostnode.AbstractStandardVirtualHostNode; @ManagedObject( category = false, type = "JDBC" ) @@ -58,9 +58,9 @@ public class JDBCVirtualHostNodeImpl extends AbstractStandardVirtualHostNode<JDB } @Override - protected DurableConfigurationStoreFactory getDurableConfigurationStoreFactory() + protected DurableConfigurationStore createConfigurationStore() { - return new JDBCMessageStoreFactory(); + return new JDBCMessageStore(); } @Override @@ -98,5 +98,4 @@ public class JDBCVirtualHostNodeImpl extends AbstractStandardVirtualHostNode<JDB { return _blobType; } - } diff --git a/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/HelperServlet.java b/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/HelperServlet.java index db635e31ce..367ed5a2a9 100644 --- a/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/HelperServlet.java +++ b/java/broker-plugins/management-http/src/main/java/org/apache/qpid/server/management/plugin/servlet/rest/HelperServlet.java @@ -56,7 +56,7 @@ public class HelperServlet extends AbstractServlet Action[] supportedActions = { new ListAuthenticationProviderAttributes(), - new ListBrokerAttribute(Broker.SUPPORTED_VIRTUALHOST_STORE_TYPES, "ListMessageStoreTypes"), + new ListBrokerAttribute(Broker.SUPPORTED_VIRTUALHOSTNODE_TYPES, "ListVirtualHostNodeTypes"), new ListBrokerAttribute(Broker.SUPPORTED_VIRTUALHOST_TYPES, "ListVirtualHostTypes"), new ListBrokerAttribute(Broker.SUPPORTED_PREFERENCES_PROVIDER_TYPES, "ListPreferencesProvidersTypes"), new ListBrokerAttribute(Broker.PRODUCT_VERSION, "version"), diff --git a/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/virtualhost/standard/addVirtualHost.js b/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/virtualhost/standard/addVirtualHost.js index 9ceab3c411..af77026c87 100644 --- a/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/virtualhost/standard/addVirtualHost.js +++ b/java/broker-plugins/management-http/src/main/java/resources/js/qpid/management/virtualhost/standard/addVirtualHost.js @@ -66,7 +66,7 @@ define(["dojo/_base/xhr", } xhr.get({ sync: true, - url: "service/helper?action=ListMessageStoreTypes", + url: "service/helper?action=ListVirtualHostTypes", handleAs: "json" }).then( function(data) { diff --git a/java/broker-plugins/memory-store/src/main/java/org/apache/qpid/server/store/MemoryMessageStoreFactory.java b/java/broker-plugins/memory-store/src/main/java/org/apache/qpid/server/store/MemoryMessageStoreFactory.java deleted file mode 100644 index 8148ff9371..0000000000 --- a/java/broker-plugins/memory-store/src/main/java/org/apache/qpid/server/store/MemoryMessageStoreFactory.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * - */ -package org.apache.qpid.server.store; - -import java.util.Map; - -import org.apache.qpid.server.plugin.DurableConfigurationStoreFactory; -import org.apache.qpid.server.plugin.MessageStoreFactory; -import org.apache.qpid.server.plugin.PluggableService; - -@PluggableService -public class MemoryMessageStoreFactory implements MessageStoreFactory, DurableConfigurationStoreFactory -{ - - @Override - public String getType() - { - return MemoryConfigurationStore.TYPE; - } - - @Override - public MessageStore createMessageStore() - { - return new MemoryMessageStore(); - } - - @Override - public void validateAttributes(Map<String, Object> attributes) - { - } - - @Override - public DurableConfigurationStore createDurableConfigurationStore() - { - return new MemoryConfigurationStore(); - } - - @Override - public void validateConfigurationStoreSettings(Map<String, Object> attributes) - { - } -} diff --git a/java/broker-plugins/memory-store/src/main/java/org/apache/qpid/server/virtualhostnode/memory/MemoryVirtualHostNode.java b/java/broker-plugins/memory-store/src/main/java/org/apache/qpid/server/virtualhostnode/memory/MemoryVirtualHostNode.java index ce587388ce..1fd4717ae1 100644 --- a/java/broker-plugins/memory-store/src/main/java/org/apache/qpid/server/virtualhostnode/memory/MemoryVirtualHostNode.java +++ b/java/broker-plugins/memory-store/src/main/java/org/apache/qpid/server/virtualhostnode/memory/MemoryVirtualHostNode.java @@ -25,8 +25,8 @@ import java.util.Map; import org.apache.qpid.server.model.Broker; import org.apache.qpid.server.model.ManagedObject; import org.apache.qpid.server.model.ManagedObjectFactoryConstructor; -import org.apache.qpid.server.plugin.DurableConfigurationStoreFactory; -import org.apache.qpid.server.store.MemoryMessageStoreFactory; +import org.apache.qpid.server.store.DurableConfigurationStore; +import org.apache.qpid.server.store.MemoryConfigurationStore; import org.apache.qpid.server.virtualhostnode.AbstractStandardVirtualHostNode; @ManagedObject(type="Memory",category=false) @@ -40,9 +40,8 @@ public class MemoryVirtualHostNode extends AbstractStandardVirtualHostNode<Memor } @Override - public DurableConfigurationStoreFactory getDurableConfigurationStoreFactory() + protected DurableConfigurationStore createConfigurationStore() { - return new MemoryMessageStoreFactory(); + return new MemoryConfigurationStore(); } - } diff --git a/java/systests/src/main/java/org/apache/qpid/server/store/SplitStoreTest.java b/java/systests/src/main/java/org/apache/qpid/server/store/SplitStoreTest.java index c580ff6717..53c0563aee 100644 --- a/java/systests/src/main/java/org/apache/qpid/server/store/SplitStoreTest.java +++ b/java/systests/src/main/java/org/apache/qpid/server/store/SplitStoreTest.java @@ -100,7 +100,12 @@ public class SplitStoreTest extends QpidBrokerTestCase Map<String, Object> messageStoreSettings = new HashMap<String, Object>(); messageStoreSettings.put(MessageStore.STORE_TYPE, getTestProfileMessageStoreType()); messageStoreSettings.put(MessageStore.STORE_PATH, _messageStorePath); - TestUtils.createStoreWithVirtualHostEntry(messageStoreSettings, config, nodeType); + + // TODO initialise the virtualhost with the required attributes using the virtualhost blueprint + // mechanism. + + //TestUtils.createStoreWithVirtualHostEntry(messageStoreSettings, config, nodeType); + super.startBroker(); } diff --git a/java/systests/src/main/java/org/apache/qpid/systest/rest/BrokerRestHttpsTest.java b/java/systests/src/main/java/org/apache/qpid/systest/rest/BrokerRestHttpsTest.java index 7ddf119ebc..f59d9f797f 100644 --- a/java/systests/src/main/java/org/apache/qpid/systest/rest/BrokerRestHttpsTest.java +++ b/java/systests/src/main/java/org/apache/qpid/systest/rest/BrokerRestHttpsTest.java @@ -64,7 +64,7 @@ public class BrokerRestHttpsTest extends QpidRestTestCase Map<String, Object> brokerDetails = getRestTestHelper().getJsonAsSingletonList("broker"); Asserts.assertAttributesPresent(brokerDetails, ConfiguredObjectTypeRegistry.getAttributeNames(Broker.class), - Broker.PROCESS_PID, Broker.SUPPORTED_VIRTUALHOST_STORE_TYPES, + Broker.PROCESS_PID, ConfiguredObject.TYPE, ConfiguredObject.CREATED_BY, ConfiguredObject.CREATED_TIME, diff --git a/java/systests/src/main/java/org/apache/qpid/systest/rest/BrokerRestTest.java b/java/systests/src/main/java/org/apache/qpid/systest/rest/BrokerRestTest.java index e312293c33..6faca2e32d 100644 --- a/java/systests/src/main/java/org/apache/qpid/systest/rest/BrokerRestTest.java +++ b/java/systests/src/main/java/org/apache/qpid/systest/rest/BrokerRestTest.java @@ -40,7 +40,6 @@ import org.apache.qpid.server.model.LifetimePolicy; import org.apache.qpid.server.model.Port; import org.apache.qpid.server.model.State; import org.apache.qpid.server.model.VirtualHostNode; -import org.apache.qpid.server.plugin.MessageStoreFactory; import org.apache.qpid.test.client.UnroutableMessageTestExceptionListener; import org.apache.qpid.test.utils.TestBrokerConfiguration; import org.apache.qpid.util.SystemUtils; @@ -234,10 +233,9 @@ public class BrokerRestTest extends QpidRestTestCase assertNotNull("Unexpected value of attribute ports", brokerDetails.get(BROKER_PORTS_ATTRIBUTE)); assertNotNull("Unexpected value of attribute authenticationproviders", brokerDetails.get(BROKER_AUTHENTICATIONPROVIDERS_ATTRIBUTE)); - @SuppressWarnings("unchecked") - Collection<String> supportedVirtualHostStoreTypes = (Collection<String>)brokerDetails.get(Broker.SUPPORTED_VIRTUALHOST_STORE_TYPES); - Collection<String> expectedSupportedVirtualHostStoreTypes = MessageStoreFactory.FACTORY_LOADER.getSupportedTypes(); - assertEquals("Unexpected supported virtual host store types", new HashSet<String>(expectedSupportedVirtualHostStoreTypes), new HashSet<String>(supportedVirtualHostStoreTypes)); + assertNotNull("Unexpected value of attribute supportedVirtualHostTypes", brokerDetails.get(Broker.SUPPORTED_VIRTUALHOST_TYPES)); + assertNotNull("Unexpected value of attribute supportedVirtualHostNodeTypes", brokerDetails.get(Broker.SUPPORTED_VIRTUALHOSTNODE_TYPES)); + } } diff --git a/java/systests/src/main/java/org/apache/qpid/test/utils/TestUtils.java b/java/systests/src/main/java/org/apache/qpid/test/utils/TestUtils.java index 3f993b38ce..5069e20335 100644 --- a/java/systests/src/main/java/org/apache/qpid/test/utils/TestUtils.java +++ b/java/systests/src/main/java/org/apache/qpid/test/utils/TestUtils.java @@ -20,29 +20,10 @@ */ package org.apache.qpid.test.utils; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; -import java.io.File; import java.lang.management.ManagementFactory; import java.lang.management.ThreadInfo; import java.lang.management.ThreadMXBean; -import java.util.HashMap; -import java.util.Map; -import java.util.UUID; - -import org.apache.qpid.server.model.BrokerModel; -import org.apache.qpid.server.model.VirtualHost; -import org.apache.qpid.server.model.VirtualHostNode; -import org.apache.qpid.server.plugin.DurableConfigurationStoreFactory; -import org.apache.qpid.server.store.ConfiguredObjectRecordImpl; -import org.apache.qpid.server.store.DurableConfigurationStore; -import org.apache.qpid.server.store.JsonFileConfigStore; -import org.apache.qpid.server.store.MemoryConfigurationStore; -import org.apache.qpid.server.store.MemoryMessageStore; -import org.apache.qpid.server.virtualhost.ProvidedStoreVirtualHost; -import org.apache.qpid.util.FileUtils; -import org.apache.qpid.util.Strings; public class TestUtils { @@ -71,53 +52,4 @@ public class TestUtils } return dump.toString(); } - - public static String createStoreWithVirtualHostEntry(Map<String, Object> messageStoreSettings, TestBrokerConfiguration config, String configStoreType) - { - UUID virtualHostId = UUID.randomUUID(); - Map<String, Object> virtualHostAttributes = new HashMap<String, Object>(); - virtualHostAttributes.put(VirtualHost.NAME, TestBrokerConfiguration.ENTRY_NAME_VIRTUAL_HOST); - virtualHostAttributes.put(VirtualHost.ID, virtualHostId); - virtualHostAttributes.put(VirtualHost.TYPE, MemoryMessageStore.TYPE.equals(configStoreType) ? configStoreType : ProvidedStoreVirtualHost.VIRTUAL_HOST_TYPE); - virtualHostAttributes.put(VirtualHost.MESSAGE_STORE_SETTINGS, messageStoreSettings); - virtualHostAttributes.put(VirtualHost.MODEL_VERSION, BrokerModel.MODEL_VERSION); - - // If using MMS, switch to split store with JSON config store. - if (MemoryConfigurationStore.TYPE.equals(configStoreType)) - { - configStoreType = JsonFileConfigStore.TYPE; - } - DurableConfigurationStoreFactory storeFactory = DurableConfigurationStoreFactory.FACTORY_LOADER.get(configStoreType); - DurableConfigurationStore store = storeFactory.createDurableConfigurationStore(); - - config.setObjectAttribute(VirtualHostNode.class, TestBrokerConfiguration.ENTRY_NAME_VIRTUAL_HOST, VirtualHostNode.TYPE, configStoreType); - - Map<String,Object> nodeAttributes = config.getObjectAttributes(VirtualHostNode.class, TestBrokerConfiguration.ENTRY_NAME_VIRTUAL_HOST); - String storePath = (String)nodeAttributes.get(DurableConfigurationStore.STORE_PATH); - String path = Strings.expand(storePath, false, Strings.JAVA_SYS_PROPS_RESOLVER, Strings.ENV_VARS_RESOLVER); - - File pathFile = new File(path); - if (pathFile.exists()) - { - FileUtils.delete(pathFile, true); - } - - Map<String, Object> attributes = new HashMap<String, Object>(nodeAttributes); - attributes.put(DurableConfigurationStore.STORE_PATH, path); - - VirtualHostNode<?> virtualHostNode = mock(VirtualHostNode.class); - when(virtualHostNode.getModel()).thenReturn(BrokerModel.getInstance()); - when(virtualHostNode.getName()).thenReturn(TestBrokerConfiguration.ENTRY_NAME_VIRTUAL_HOST); - - try - { - store.openConfigurationStore(virtualHostNode, attributes); - store.create(new ConfiguredObjectRecordImpl(virtualHostId, VirtualHost.class.getSimpleName(), virtualHostAttributes)); - } - finally - { - store.closeConfigurationStore(); - } - return path; - } } |