Return-Path: X-Original-To: apmail-tomcat-users-archive@www.apache.org Delivered-To: apmail-tomcat-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 53A58CD42 for ; Wed, 8 Aug 2012 12:19:59 +0000 (UTC) Received: (qmail 60211 invoked by uid 500); 8 Aug 2012 12:19:56 -0000 Delivered-To: apmail-tomcat-users-archive@tomcat.apache.org Received: (qmail 59901 invoked by uid 500); 8 Aug 2012 12:19:56 -0000 Mailing-List: contact users-help@tomcat.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tomcat Users List" Delivered-To: mailing list users@tomcat.apache.org Received: (qmail 59887 invoked by uid 99); 8 Aug 2012 12:19:55 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 08 Aug 2012 12:19:55 +0000 X-ASF-Spam-Status: No, hits=-5.0 required=5.0 tests=RCVD_IN_DNSWL_HI,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: local policy) Received: from [208.91.2.12] (HELO smtp-outbound-1.vmware.com) (208.91.2.12) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 08 Aug 2012 12:19:46 +0000 Received: from sc9-mailhost2.vmware.com (sc9-mailhost2.vmware.com [10.113.161.72]) by smtp-outbound-1.vmware.com (Postfix) with ESMTP id 0C0B7282FA for ; Wed, 8 Aug 2012 05:19:25 -0700 (PDT) Received: from zimbra-prod-mta-3.vmware.com (zimbra-prod-mta-3.vmware.com [10.113.160.227]) by sc9-mailhost2.vmware.com (Postfix) with ESMTP id 07B8CB0585 for ; Wed, 8 Aug 2012 05:19:25 -0700 (PDT) Received: from localhost (localhost.localdomain [127.0.0.1]) by zimbra-prod-mta-3.vmware.com (Postfix) with ESMTP id 0494EE2C02 for ; Wed, 8 Aug 2012 05:19:25 -0700 (PDT) X-Virus-Scanned: amavisd-new at zimbra-prod-mta-3.vmware.com Received: from zimbra-prod-mta-3.vmware.com ([127.0.0.1]) by localhost (zimbra-prod-mta-3.vmware.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id s15svYhAnCPs for ; Wed, 8 Aug 2012 05:19:24 -0700 (PDT) Received: from zimbra-prod-mbox-5.vmware.com (lbv-sc9-t2prod2-int.vmware.com [10.113.160.246]) by zimbra-prod-mta-3.vmware.com (Postfix) with ESMTP id DDC7CE2A9F for ; Wed, 8 Aug 2012 05:19:24 -0700 (PDT) Date: Wed, 8 Aug 2012 05:19:24 -0700 (PDT) From: Daniel Mikusa To: Tomcat Users List Message-ID: <22519108.50.1344428364267.JavaMail.daniel@cleveland> In-Reply-To: Subject: Re: tomcat-jdbc: correct way to create a new separated org.apache.tomcat.jdbc.pool.DataSource from another one MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [71.72.51.173] X-Mailer: Zimbra 7.2.0_GA_2669 (Zimbra Desktop/7.1.4_11299_Linux) ----- Original Message ----- > Hello. >=20 > I have an use case in which I would want to copy an > `org.apache.tomcat.jdbc.pool.DataSource`, to have two disjoint > connection > pools, with some pool properties changed. >=20 > My first thought was to do something like this: >=20 > PoolProperties props =3D new > PoolProperties(baseDataSource.getPoolProperties()); > // set custom props ... > DataSource newDataSource =3D new DataSource(props); >=20 >=20 > The problem is that the PoolProperties class doesn't have such > constructor. > Another option could be to share the PoolProperties object, but, for > what > I've looked into the code, it doesn't seem safe. >=20 > The PoolProperties class implements the Cloneable interface, so I > guess > it's ok to use its clone method. The problem I have with this option > is > that DataSource#getPoolProperties() returns a PoolConfiguration which > doesn't implements Cloneable. In my case I think it would be safe to > cast > the PoolConfiguration to PoolProperties, but it doesn't seem safe for > the > general case. >=20 > What would be the correct way to create a new separated DataSource > from > another one having some properties changed? >=20 > I'm using tomcat-jdbc 7.0.29 as a standalone library. >=20 > Thank you. >=20 > Regards, > Germ=C3=A1n >=20 Have you looked at the method "parsePoolProperties" on the DataSourceFactor= y class? public static PoolConfiguration parsePoolProperties(Properties properties= ) You could load your configuration into a Properties object, create you firs= t pool configuration with "parsePoolProperties", alter the Properties objec= t and then call "parsePoolProperties" on the modified Properties object to = create your second pool configuration. Dan --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org For additional commands, e-mail: users-help@tomcat.apache.org