summaryrefslogtreecommitdiff
path: root/qpid/java/broker-plugins/jdbc-store/src
diff options
context:
space:
mode:
authorRobert Godfrey <rgodfrey@apache.org>2014-07-26 22:57:11 +0000
committerRobert Godfrey <rgodfrey@apache.org>2014-07-26 22:57:11 +0000
commitb71bbd227dfacaedaba411e908853b05e8fbd243 (patch)
tree34c186991ae516bef5e0322558aae4843a8545b2 /qpid/java/broker-plugins/jdbc-store/src
parent151622bd91d7eb031498ff598a31a295af27799b (diff)
downloadqpid-python-b71bbd227dfacaedaba411e908853b05e8fbd243.tar.gz
QPID-5165 : Change the Broker stores to use the generic ConfigurationStore implementations and remove old EntryStore implementations
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1613739 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/java/broker-plugins/jdbc-store/src')
-rw-r--r--qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/GenericJDBCConfigurationStore.java26
-rw-r--r--qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/JDBCSystemConfig.java39
-rw-r--r--qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/JDBCSystemConfigImpl.java86
-rw-r--r--qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/virtualhostnode/jdbc/JDBCVirtualHostNodeImpl.java3
4 files changed, 148 insertions, 6 deletions
diff --git a/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/GenericJDBCConfigurationStore.java b/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/GenericJDBCConfigurationStore.java
index 6764b7b715..4f88e011fb 100644
--- a/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/GenericJDBCConfigurationStore.java
+++ b/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/GenericJDBCConfigurationStore.java
@@ -29,14 +29,18 @@ import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.atomic.AtomicBoolean;
+import javax.security.auth.Subject;
+
import org.apache.log4j.Logger;
import org.apache.qpid.server.model.ConfiguredObject;
import org.apache.qpid.server.plugin.JDBCConnectionProviderFactory;
import org.apache.qpid.server.security.SecurityManager;
-import org.apache.qpid.server.store.*;
-
-import javax.security.auth.Subject;
+import org.apache.qpid.server.store.AbstractJDBCConfigurationStore;
+import org.apache.qpid.server.store.ConfiguredObjectRecord;
+import org.apache.qpid.server.store.MessageStore;
+import org.apache.qpid.server.store.MessageStoreProvider;
+import org.apache.qpid.server.store.StoreException;
/**
* Implementation of a DurableConfigurationStore backed by Generic JDBC Database
@@ -60,9 +64,17 @@ public class GenericJDBCConfigurationStore extends AbstractJDBCConfigurationStor
private boolean _useBytesMethodsForBlob;
private ConfiguredObject<?> _parent;
+ private final Class<? extends ConfiguredObject> _rootClass;
+
+ public GenericJDBCConfigurationStore(final Class<? extends ConfiguredObject> rootClass)
+ {
+ _rootClass = rootClass;
+ }
@Override
- public void openConfigurationStore(ConfiguredObject<?> parent)
+ public void openConfigurationStore(ConfiguredObject<?> parent,
+ final boolean overwrite,
+ final ConfiguredObjectRecord... initialRecords)
throws StoreException
{
if (_configurationStoreOpen.compareAndSet(false, true))
@@ -117,7 +129,11 @@ public class GenericJDBCConfigurationStore extends AbstractJDBCConfigurationStor
_useBytesMethodsForBlob = details.isUseBytesMethodsForBlob();
_bigIntType = details.getBigintType();
- createOrOpenConfigurationStoreDatabase();
+ createOrOpenConfigurationStoreDatabase(overwrite);
+ if(hasNoConfigurationEntries())
+ {
+ update(true, initialRecords);
+ }
}
}
diff --git a/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/JDBCSystemConfig.java b/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/JDBCSystemConfig.java
new file mode 100644
index 0000000000..9fe64577bb
--- /dev/null
+++ b/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/JDBCSystemConfig.java
@@ -0,0 +1,39 @@
+/*
+ *
+ * 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 org.apache.qpid.server.model.ManagedAttribute;
+import org.apache.qpid.server.model.SystemConfig;
+
+public interface JDBCSystemConfig<X extends JDBCSystemConfig<X>> extends SystemConfig<X>, JDBCSettings
+{
+ @ManagedAttribute(mandatory=true, defaultValue = "${systemConfig.connectionUrl}")
+ String getConnectionUrl();
+
+ @ManagedAttribute(defaultValue=DefaultConnectionProviderFactory.TYPE)
+ String getConnectionPoolType();
+
+ @ManagedAttribute(defaultValue = "${systemConfig.username}")
+ String getUsername();
+
+ @ManagedAttribute(secure=true, defaultValue = "${systemConfig.password}")
+ String getPassword();
+}
diff --git a/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/JDBCSystemConfigImpl.java b/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/JDBCSystemConfigImpl.java
new file mode 100644
index 0000000000..fd1cad7de4
--- /dev/null
+++ b/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/store/jdbc/JDBCSystemConfigImpl.java
@@ -0,0 +1,86 @@
+/*
+ *
+ * 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 org.apache.qpid.server.BrokerOptions;
+import org.apache.qpid.server.configuration.updater.TaskExecutor;
+import org.apache.qpid.server.logging.EventLogger;
+import org.apache.qpid.server.logging.LogRecorder;
+import org.apache.qpid.server.model.AbstractSystemConfig;
+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.SystemConfigFactoryConstructor;
+import org.apache.qpid.server.store.DurableConfigurationStore;
+
+@ManagedObject( category = false, type = JDBCSystemConfigImpl.SYSTEM_CONFIG_TYPE)
+public class JDBCSystemConfigImpl extends AbstractSystemConfig<JDBCSystemConfigImpl> implements JDBCSystemConfig<JDBCSystemConfigImpl>
+{
+ public static final String SYSTEM_CONFIG_TYPE = "JDBC";
+
+ @ManagedAttributeField
+ private String _connectionUrl;
+ @ManagedAttributeField
+ private String _connectionPoolType;
+ @ManagedAttributeField
+ private String _username;
+ @ManagedAttributeField
+ private String _password;
+
+ @SystemConfigFactoryConstructor
+ public JDBCSystemConfigImpl(final TaskExecutor taskExecutor,
+ final EventLogger eventLogger,
+ final LogRecorder logRecorder,
+ final BrokerOptions brokerOptions)
+ {
+ super(taskExecutor, eventLogger, logRecorder, brokerOptions);
+ }
+
+ @Override
+ protected DurableConfigurationStore createStoreObject()
+ {
+ return new GenericJDBCConfigurationStore(Broker.class);
+ }
+
+ @Override
+ public String getConnectionUrl()
+ {
+ return _connectionUrl;
+ }
+
+ @Override
+ public String getConnectionPoolType()
+ {
+ return _connectionPoolType;
+ }
+
+ @Override
+ public String getUsername()
+ {
+ return _username;
+ }
+
+ @Override
+ public String getPassword()
+ {
+ return _password;
+ }
+}
diff --git a/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/virtualhostnode/jdbc/JDBCVirtualHostNodeImpl.java b/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/virtualhostnode/jdbc/JDBCVirtualHostNodeImpl.java
index 01acb9e0b5..eab53e6744 100644
--- a/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/virtualhostnode/jdbc/JDBCVirtualHostNodeImpl.java
+++ b/qpid/java/broker-plugins/jdbc-store/src/main/java/org/apache/qpid/server/virtualhostnode/jdbc/JDBCVirtualHostNodeImpl.java
@@ -26,6 +26,7 @@ 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.model.VirtualHost;
import org.apache.qpid.server.store.DurableConfigurationStore;
import org.apache.qpid.server.store.jdbc.GenericJDBCConfigurationStore;
import org.apache.qpid.server.virtualhostnode.AbstractStandardVirtualHostNode;
@@ -61,7 +62,7 @@ public class JDBCVirtualHostNodeImpl extends AbstractStandardVirtualHostNode<JDB
@Override
protected DurableConfigurationStore createConfigurationStore()
{
- return new GenericJDBCConfigurationStore();
+ return new GenericJDBCConfigurationStore(VirtualHost.class);
}
@Override