diff options
| author | Robert Godfrey <rgodfrey@apache.org> | 2013-08-20 18:39:44 +0000 |
|---|---|---|
| committer | Robert Godfrey <rgodfrey@apache.org> | 2013-08-20 18:39:44 +0000 |
| commit | 6266c91a9ef891c84159c99cfc7708fc2cc7d49f (patch) | |
| tree | 38cc9d7ec71534364ac2bd983d535a4106a03e91 /qpid/java/broker-plugins/jdbc-store | |
| parent | fd04bb3ba94abd9979ae820e7717fdb77d230097 (diff) | |
| download | qpid-python-6266c91a9ef891c84159c99cfc7708fc2cc7d49f.tar.gz | |
QPID-5087 : [Java Broker] Allow use of separate message stores and configuration stores
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1515914 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/java/broker-plugins/jdbc-store')
3 files changed, 65 insertions, 11 deletions
diff --git a/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/JDBCMessageStore.java b/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/JDBCMessageStore.java index f8d93536bb..6fdfa40561 100644 --- a/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/JDBCMessageStore.java +++ b/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/JDBCMessageStore.java @@ -51,6 +51,7 @@ public class JDBCMessageStore extends AbstractJDBCMessageStore implements Messag public static final String TYPE = "JDBC"; public static final String CONNECTION_URL = "connectionURL"; + public static final String CONFIG_CONNECTION_URL = "configConnectionURL"; protected String _connectionURL; private ConnectionProvider _connectionProvider; @@ -280,11 +281,20 @@ public class JDBCMessageStore extends AbstractJDBCMessageStore implements Messag throws ClassNotFoundException, SQLException { + String connectionURL; + if(!isConfigStoreOnly()) + { + connectionURL = virtualHost.getAttribute(CONNECTION_URL) == null + ? String.valueOf(virtualHost.getAttribute(VirtualHost.STORE_PATH)) + : String.valueOf(virtualHost.getAttribute(CONNECTION_URL)); + } + else + { + connectionURL = virtualHost.getAttribute(CONFIG_CONNECTION_URL) == null + ? String.valueOf(virtualHost.getAttribute(VirtualHost.CONFIG_STORE_PATH)) + : String.valueOf(virtualHost.getAttribute(CONFIG_CONNECTION_URL)); - String connectionURL = virtualHost.getAttribute(CONNECTION_URL) == null - ? String.valueOf(virtualHost.getAttribute(VirtualHost.STORE_PATH)) - : String.valueOf(virtualHost.getAttribute(CONNECTION_URL)); - + } JDBCDetails details = null; String[] components = connectionURL.split(":",3); diff --git a/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/JDBCMessageStoreFactory.java b/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/JDBCMessageStoreFactory.java index 82d2275156..1144eaaf18 100644 --- a/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/JDBCMessageStoreFactory.java +++ b/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/JDBCMessageStoreFactory.java @@ -24,10 +24,12 @@ import java.util.HashMap; import java.util.Map; import org.apache.commons.configuration.Configuration; 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.store.DurableConfigurationStore; import org.apache.qpid.server.store.MessageStore; -public class JDBCMessageStoreFactory implements MessageStoreFactory +public class JDBCMessageStoreFactory implements MessageStoreFactory, DurableConfigurationStoreFactory { @Override @@ -43,6 +45,12 @@ public class JDBCMessageStoreFactory implements MessageStoreFactory } @Override + public DurableConfigurationStore createDurableConfigurationStore() + { + return new JDBCMessageStore(); + } + + @Override public Map<String, Object> convertStoreConfiguration(Configuration storeConfiguration) { Map<String,Object> convertedMap = new HashMap<String,Object>(); @@ -67,15 +75,32 @@ public class JDBCMessageStoreFactory implements MessageStoreFactory @Override public void validateAttributes(Map<String, Object> attributes) { - Object connectionURL = attributes.get(JDBCMessageStore.CONNECTION_URL); - if(!(connectionURL instanceof String)) + if(getType().equals(attributes.get(VirtualHost.STORE_TYPE))) + { + Object connectionURL = attributes.get(JDBCMessageStore.CONNECTION_URL); + if(!(connectionURL instanceof String)) + { + Object storePath = attributes.get(VirtualHost.STORE_PATH); + if(!(storePath instanceof String)) + { + throw new IllegalArgumentException("Attribute '"+ JDBCMessageStore.CONNECTION_URL + +"' is required and must be of type String."); + + } + } + } + if(getType().equals(attributes.get(VirtualHost.CONFIG_STORE_TYPE))) { - Object storePath = attributes.get(VirtualHost.STORE_PATH); - if(!(storePath instanceof String)) + Object connectionURL = attributes.get(JDBCMessageStore.CONFIG_CONNECTION_URL); + if(!(connectionURL instanceof String)) { - throw new IllegalArgumentException("Attribute '"+ JDBCMessageStore.CONNECTION_URL - +"' is required and must be of type String."); + Object storePath = attributes.get(VirtualHost.CONFIG_STORE_PATH); + if(!(storePath instanceof String)) + { + throw new IllegalArgumentException("Attribute '"+ JDBCMessageStore.CONFIG_CONNECTION_URL + +"' is required and must be of type String."); + } } } } diff --git a/qpid/java/broker-plugins/jdbc-store/src/main/resources/META-INF/services/org.apache.qpid.server.plugin.DurableConfigurationStoreFactory b/qpid/java/broker-plugins/jdbc-store/src/main/resources/META-INF/services/org.apache.qpid.server.plugin.DurableConfigurationStoreFactory new file mode 100644 index 0000000000..a77458f27d --- /dev/null +++ b/qpid/java/broker-plugins/jdbc-store/src/main/resources/META-INF/services/org.apache.qpid.server.plugin.DurableConfigurationStoreFactory @@ -0,0 +1,19 @@ +# +# 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.jdbc.JDBCMessageStoreFactory |
