summaryrefslogtreecommitdiff
path: root/qpid/java/broker-plugins
diff options
context:
space:
mode:
Diffstat (limited to 'qpid/java/broker-plugins')
-rw-r--r--qpid/java/broker-plugins/jdbc-provider-bone/src/main/java/org/apache/qpid/server/store/jdbc/bonecp/BoneCPConnectionProvider.java59
-rw-r--r--qpid/java/broker-plugins/jdbc-provider-bone/src/main/java/org/apache/qpid/server/store/jdbc/bonecp/BoneCPConnectionProviderFactory.java42
-rw-r--r--qpid/java/broker-plugins/jdbc-provider-bone/src/main/resources/META-INF/services/org.apache.qpid.server.plugin.JDBCConnectionProviderFactory19
3 files changed, 120 insertions, 0 deletions
diff --git a/qpid/java/broker-plugins/jdbc-provider-bone/src/main/java/org/apache/qpid/server/store/jdbc/bonecp/BoneCPConnectionProvider.java b/qpid/java/broker-plugins/jdbc-provider-bone/src/main/java/org/apache/qpid/server/store/jdbc/bonecp/BoneCPConnectionProvider.java
new file mode 100644
index 0000000000..7545b84611
--- /dev/null
+++ b/qpid/java/broker-plugins/jdbc-provider-bone/src/main/java/org/apache/qpid/server/store/jdbc/bonecp/BoneCPConnectionProvider.java
@@ -0,0 +1,59 @@
+/*
+ *
+ * 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.bonecp;
+
+import com.jolbox.bonecp.BoneCP;
+import com.jolbox.bonecp.BoneCPConfig;
+import java.sql.Connection;
+import java.sql.SQLException;
+import org.apache.commons.configuration.Configuration;
+import org.apache.qpid.server.store.jdbc.ConnectionProvider;
+
+public class BoneCPConnectionProvider implements ConnectionProvider
+{
+ public static final int DEFAULT_MIN_CONNECTIONS_PER_PARTITION = 5;
+ public static final int DEFAULT_MAX_CONNECTIONS_PER_PARTITION = 10;
+ public static final int DEFAULT_PARTITION_COUNT = 4;
+ private final BoneCP _connectionPool;
+
+ public BoneCPConnectionProvider(String connectionUrl, Configuration storeConfiguration) throws SQLException
+ {
+ BoneCPConfig config = new BoneCPConfig();
+ config.setJdbcUrl(connectionUrl);
+
+ config.setMinConnectionsPerPartition(storeConfiguration.getInteger("minConnectionsPerPartition", DEFAULT_MIN_CONNECTIONS_PER_PARTITION));
+ config.setMaxConnectionsPerPartition(storeConfiguration.getInteger("maxConnectionsPerPartition", DEFAULT_MAX_CONNECTIONS_PER_PARTITION));
+ config.setPartitionCount(storeConfiguration.getInteger("partitionCount",DEFAULT_PARTITION_COUNT));
+ _connectionPool = new BoneCP(config);
+ }
+
+ @Override
+ public Connection getConnection() throws SQLException
+ {
+ return _connectionPool.getConnection();
+ }
+
+ @Override
+ public void close() throws SQLException
+ {
+ _connectionPool.shutdown();
+ }
+}
diff --git a/qpid/java/broker-plugins/jdbc-provider-bone/src/main/java/org/apache/qpid/server/store/jdbc/bonecp/BoneCPConnectionProviderFactory.java b/qpid/java/broker-plugins/jdbc-provider-bone/src/main/java/org/apache/qpid/server/store/jdbc/bonecp/BoneCPConnectionProviderFactory.java
new file mode 100644
index 0000000000..71c59c7772
--- /dev/null
+++ b/qpid/java/broker-plugins/jdbc-provider-bone/src/main/java/org/apache/qpid/server/store/jdbc/bonecp/BoneCPConnectionProviderFactory.java
@@ -0,0 +1,42 @@
+/*
+ *
+ * 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.bonecp;
+
+import java.sql.SQLException;
+import org.apache.commons.configuration.Configuration;
+import org.apache.qpid.server.plugin.JDBCConnectionProviderFactory;
+import org.apache.qpid.server.store.jdbc.ConnectionProvider;
+
+public class BoneCPConnectionProviderFactory implements JDBCConnectionProviderFactory
+{
+ @Override
+ public String getType()
+ {
+ return "BONECP";
+ }
+
+ @Override
+ public ConnectionProvider getConnectionProvider(String connectionUrl, Configuration storeConfiguration)
+ throws SQLException
+ {
+ return new BoneCPConnectionProvider(connectionUrl, storeConfiguration);
+ }
+}
diff --git a/qpid/java/broker-plugins/jdbc-provider-bone/src/main/resources/META-INF/services/org.apache.qpid.server.plugin.JDBCConnectionProviderFactory b/qpid/java/broker-plugins/jdbc-provider-bone/src/main/resources/META-INF/services/org.apache.qpid.server.plugin.JDBCConnectionProviderFactory
new file mode 100644
index 0000000000..70157b44c3
--- /dev/null
+++ b/qpid/java/broker-plugins/jdbc-provider-bone/src/main/resources/META-INF/services/org.apache.qpid.server.plugin.JDBCConnectionProviderFactory
@@ -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.bonecp.BoneCPConnectionProviderFactory