Return-Path: X-Original-To: apmail-jackrabbit-oak-dev-archive@minotaur.apache.org Delivered-To: apmail-jackrabbit-oak-dev-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 35E7710039 for ; Tue, 18 Mar 2014 08:40:28 +0000 (UTC) Received: (qmail 79480 invoked by uid 500); 18 Mar 2014 08:40:27 -0000 Delivered-To: apmail-jackrabbit-oak-dev-archive@jackrabbit.apache.org Received: (qmail 79311 invoked by uid 500); 18 Mar 2014 08:40:19 -0000 Mailing-List: contact oak-dev-help@jackrabbit.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: oak-dev@jackrabbit.apache.org Delivered-To: mailing list oak-dev@jackrabbit.apache.org Received: (qmail 78805 invoked by uid 99); 18 Mar 2014 08:40:16 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 18 Mar 2014 08:40:15 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of chetan.mehrotra@gmail.com designates 209.85.214.182 as permitted sender) Received: from [209.85.214.182] (HELO mail-ob0-f182.google.com) (209.85.214.182) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 18 Mar 2014 08:40:08 +0000 Received: by mail-ob0-f182.google.com with SMTP id uz6so6771158obc.13 for ; Tue, 18 Mar 2014 01:39:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=XW2t+LRRbgXvDJmSNr/G4zyhHFycw69Hm+To+CEL9Ro=; b=a15l6hN3a9pGybUKOpZKRz4VGsG83mYXcUQJTn0anpXgyZ3zoGp0rHmTqvH3WBWJur aDcsdRbh9PBNn5PMK4YFdx2NP42a6Jz/KMFURFiwHyYnVm0SB+pv6445cS9W2L+QaalS gq/lIMbejOtWovD7fuV7TLsDkAl5LGiCemPvdIY59a9+j2uX1r/9/VBMk6qEnpBNgOcQ urpYAaE1xzmI47mYNy7nIWt5GzKzthvOuHSkg57qtZe0HE/52L72ogX12YHIuOUOwKmt lsnlG/+iJz/W6UHHqwC0qXr+mhEBkA0ErBuHwl/D/pPWF5uP7iNz/rZ6tlTWR7/H7u22 dxkw== MIME-Version: 1.0 X-Received: by 10.60.73.164 with SMTP id m4mr25187811oev.8.1395131987405; Tue, 18 Mar 2014 01:39:47 -0700 (PDT) Received: by 10.60.93.163 with HTTP; Tue, 18 Mar 2014 01:39:47 -0700 (PDT) In-Reply-To: <20140317150856.5941E2388A33@eris.apache.org> References: <20140317150856.5941E2388A33@eris.apache.org> Date: Tue, 18 Mar 2014 14:09:47 +0530 Message-ID: Subject: Re: svn commit: r1578423 - in /jackrabbit/oak/trunk/oak-core: ./ src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/ From: Chetan Mehrotra To: oak-dev@jackrabbit.apache.org Content-Type: text/plain; charset=ISO-8859-1 X-Virus-Checked: Checked by ClamAV on apache.org It would be better if we make DataSource as part of Builder itself and remove all such logic from RDB. Or better for testing purpose or even in normal case the RDBDocumentStore be instantiated outside and passed in Builder. Then main code would not have to worry about creating DataStource and handle all possible config options that comes with that Chetan Mehrotra On Mon, Mar 17, 2014 at 8:38 PM, wrote: > Author: reschke > Date: Mon Mar 17 15:08:55 2014 > New Revision: 1578423 > > URL: http://svn.apache.org/r1578423 > Log: > OAK-1533 - add dbcp BasicDataSource (WIP) > > Added: > jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBDataSourceFactory.java (with props) > Modified: > jackrabbit/oak/trunk/oak-core/pom.xml > jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBBlobStore.java > jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBDocumentStore.java > > Modified: jackrabbit/oak/trunk/oak-core/pom.xml > URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/pom.xml?rev=1578423&r1=1578422&r2=1578423&view=diff > ============================================================================== > --- jackrabbit/oak/trunk/oak-core/pom.xml (original) > +++ jackrabbit/oak/trunk/oak-core/pom.xml Mon Mar 17 15:08:55 2014 > @@ -276,6 +276,11 @@ > 1.3.158 > true > > + > + commons-dbcp > + commons-dbcp > + 1.4 > + > > > > > Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBBlobStore.java > URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBBlobStore.java?rev=1578423&r1=1578422&r2=1578423&view=diff > ============================================================================== > --- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBBlobStore.java (original) > +++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBBlobStore.java Mon Mar 17 15:08:55 2014 > @@ -19,7 +19,6 @@ package org.apache.jackrabbit.oak.plugin > import java.io.Closeable; > import java.io.IOException; > import java.sql.Connection; > -import java.sql.DriverManager; > import java.sql.PreparedStatement; > import java.sql.ResultSet; > import java.sql.SQLException; > @@ -29,14 +28,14 @@ import java.util.Iterator; > > import javax.sql.DataSource; > > -import com.google.common.collect.AbstractIterator; > - > import org.apache.jackrabbit.mk.api.MicroKernelException; > -import org.apache.jackrabbit.oak.plugins.blob.CachingBlobStore; > import org.apache.jackrabbit.oak.commons.StringUtils; > +import org.apache.jackrabbit.oak.plugins.blob.CachingBlobStore; > import org.slf4j.Logger; > import org.slf4j.LoggerFactory; > > +import com.google.common.collect.AbstractIterator; > + > public class RDBBlobStore extends CachingBlobStore implements Closeable { > /** > * Creates a {@linkplain RDBBlobStore} instance using an embedded H2 > @@ -45,8 +44,8 @@ public class RDBBlobStore extends Cachin > public RDBBlobStore() { > try { > String jdbcurl = "jdbc:h2:mem:oaknodes"; > - Connection connection = DriverManager.getConnection(jdbcurl, "sa", ""); > - initialize(connection); > + DataSource ds = RDBDataSourceFactory.forJdbcUrl(jdbcurl, "sa", ""); > + initialize(ds.getConnection()); > } catch (Exception ex) { > throw new MicroKernelException("initializing RDB blob store", ex); > } > @@ -58,8 +57,8 @@ public class RDBBlobStore extends Cachin > */ > public RDBBlobStore(String jdbcurl, String username, String password) { > try { > - Connection connection = DriverManager.getConnection(jdbcurl, username, password); > - initialize(connection); > + DataSource ds = RDBDataSourceFactory.forJdbcUrl(jdbcurl, username, password); > + initialize(ds.getConnection()); > } catch (Exception ex) { > throw new MicroKernelException("initializing RDB blob store", ex); > } > > Added: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBDataSourceFactory.java > URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBDataSourceFactory.java?rev=1578423&view=auto > ============================================================================== > --- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBDataSourceFactory.java (added) > +++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBDataSourceFactory.java Mon Mar 17 15:08:55 2014 > @@ -0,0 +1,38 @@ > +/* > + * 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.jackrabbit.oak.plugins.document.rdb; > + > +import java.sql.Driver; > +import java.sql.DriverManager; > +import java.sql.SQLException; > + > +import javax.sql.DataSource; > + > +import org.apache.commons.dbcp.BasicDataSource; > + > +public class RDBDataSourceFactory extends RDBMeta { > + > + public static DataSource forJdbcUrl(String url, String username, String passwd) throws SQLException { > + BasicDataSource bds = new BasicDataSource(); > + Driver d = DriverManager.getDriver(url); > + bds.setDriverClassName(d.getClass().getName()); > + bds.setUsername(username); > + bds.setPassword(passwd); > + bds.setUrl(url); > + return bds; > + } > +} > > Propchange: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBDataSourceFactory.java > ------------------------------------------------------------------------------ > svn:eol-style = native > > Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBDocumentStore.java > URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBDocumentStore.java?rev=1578423&r1=1578422&r2=1578423&view=diff > ============================================================================== > --- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBDocumentStore.java (original) > +++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/plugins/document/rdb/RDBDocumentStore.java Mon Mar 17 15:08:55 2014 > @@ -17,7 +17,6 @@ > package org.apache.jackrabbit.oak.plugins.document.rdb; > > import java.sql.Connection; > -import java.sql.DriverManager; > import java.sql.PreparedStatement; > import java.sql.ResultSet; > import java.sql.SQLException; > @@ -69,8 +68,8 @@ public class RDBDocumentStore implements > public RDBDocumentStore(DocumentMK.Builder builder) { > try { > String jdbcurl = "jdbc:h2:mem:oaknodes"; > - Connection connection = DriverManager.getConnection(jdbcurl, "sa", ""); > - initialize(connection, builder); > + DataSource ds = RDBDataSourceFactory.forJdbcUrl(jdbcurl, "sa", ""); > + initialize(ds.getConnection(), builder); > } catch (Exception ex) { > throw new MicroKernelException("initializing RDB document store", ex); > } > @@ -94,8 +93,8 @@ public class RDBDocumentStore implements > */ > public RDBDocumentStore(String jdbcurl, String username, String password, DocumentMK.Builder builder) { > try { > - Connection connection = DriverManager.getConnection(jdbcurl, username, password); > - initialize(connection, builder); > + DataSource ds = RDBDataSourceFactory.forJdbcUrl(jdbcurl, "sa", ""); > + initialize(ds.getConnection(), builder); > } catch (Exception ex) { > throw new MicroKernelException("initializing RDB document store", ex); > } > >