Return-Path: Delivered-To: apmail-cayenne-user-archive@www.apache.org Received: (qmail 330 invoked from network); 3 May 2008 00:22:11 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 3 May 2008 00:22:11 -0000 Received: (qmail 39057 invoked by uid 500); 3 May 2008 00:22:12 -0000 Delivered-To: apmail-cayenne-user-archive@cayenne.apache.org Received: (qmail 39046 invoked by uid 500); 3 May 2008 00:22:12 -0000 Mailing-List: contact user-help@cayenne.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@cayenne.apache.org Delivered-To: mailing list user@cayenne.apache.org Received: (qmail 39035 invoked by uid 99); 3 May 2008 00:22:12 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 02 May 2008 17:22:12 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: local policy) Received: from [66.196.97.96] (HELO web56907.mail.re3.yahoo.com) (66.196.97.96) by apache.org (qpsmtpd/0.29) with SMTP; Sat, 03 May 2008 00:21:19 +0000 Received: (qmail 67983 invoked by uid 60001); 3 May 2008 00:21:39 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=X-YMail-OSG:Received:Date:From:Subject:To:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding:Message-ID; b=D36beUHL5E2GmoEHt8s7vzWYeLCyfTzs2EHvm51nUlAxF7lzqkQtRCAEMPQ/xNe54npTaBU6NGfR1mp1nJFisnUeA1QsK2OXLFHAkMsU8hV8j0n4/lBOu5tkC/yBOPX1QFYxvTHokBKCrjijTu85J0cKHGpBTKnRCcAgb4tzuZM=; X-YMail-OSG: xEBSjK8VM1mSWoC.F4au.ZRFZyYoCNAhI9ygaZiENG7LLjxk0IsmaEKAUIcTD9nI_Zb2twYcB2hZXAaaViYEPAbn0bFu36PKTyup Received: from [71.210.77.114] by web56907.mail.re3.yahoo.com via HTTP; Fri, 02 May 2008 17:21:39 PDT Date: Fri, 2 May 2008 17:21:39 -0700 (PDT) From: Brian Nelson Subject: Re: Custom configuration class ignored in 3.0 snapshot To: user@cayenne.apache.org In-Reply-To: <80225B65-134A-4C59-998F-7302E08CBF5A@objectstyle.org> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Message-ID: <510358.67972.qm@web56907.mail.re3.yahoo.com> X-Virus-Checked: Checked by ClamAV on apache.org Andrus, I'm not sure exactly how you want the code sample. If you need me to provide a self contained app I can do that. For now I'll just copy the code from my app so you can take a look at it. I have a static method that configures my custom DataSourceFactory. The call to DbUtils.openDb succeeds, but the getDataSourceFactory method in CompanyConfiguration is never called. public class DbUtils { private static DataContext globalContext; private static DataContext estimateContext; private static DataContext roomContext; private static DataContext assemblyContext; private static DataContext partsContext; public static void openDb(String pathToDb) throws Exception { try { CompanyDataSourceFactory.setDbPath(pathToDb); Configuration.initializeSharedConfiguration(CompanyConfiguration.class); Configuration config = Configuration.getSharedConfiguration(); DataDomain domain = config.getDomain(); globalContext = DataContext.createDataContext(domain.getName()); estimateContext = DataContext.createDataContext(domain.getName()); roomContext = DataContext.createDataContext(domain.getName()); assemblyContext = DataContext.createDataContext(domain.getName()); partsContext = DataContext.createDataContext(domain.getName()); } catch (Exception e) { throw new Exception("Unable to initialize database!", e); } } } public class CompanyConfiguration extends DefaultConfiguration { private static CompanyDataSourceFactory factory = new CompanyDataSourceFactory(); @Override public DataSourceFactory getDataSourceFactory() { return factory; } } public class CompanyDataSourceFactory implements DataSourceFactory { private static DataSource ds = null; private static String dbPath = "Companies/db"; public static void setDbPath(String val) { dbPath = val; } @Override public DataSource getDataSource(String arg0) throws Exception { if(dbPath.startsWith("server")) { // server:host ClientDataSource40 tmpDS = new ClientDataSource40(); String[] sArray = dbPath.split(":"); tmpDS.setServerName(sArray[1]); tmpDS.setDatabaseName("db"); tmpDS.setUser("user"); tmpDS.setPassword("pass"); ds = tmpDS; } else { EmbeddedDataSource40 tmpDS = new EmbeddedDataSource40(); tmpDS.setDatabaseName(dbPath); tmpDS.setUser("user"); tmpDS.setPassword("db"); ds = tmpDS; } return ds; } @Override public void initializeWithParentConfiguration(Configuration arg0) { } } Hopefully that's enough. If not let me know what I should provide. Thanks for your help! Brian --- Andrus Adamchik wrote: > Strange. That should still work the same. The only change to > Configuration since M3 was related to the DataSourceFactory handling > (CAY-785)... Do you have a code example that demonstrates the problem? > > Thanks, > Andrus > > > On May 1, 2008, at 10:29 PM, Brian Nelson wrote: > > I've been using a custom subclass of DefaultConfiguration to > > customize my database connection. > > This works great with 3.0M3. However, today I upgraded to the > > snapshot build and it seems to be > > ignoring the custom configuration class I pass into the > > Configuration.initializeSharedConfiguration method. Has the way > > custom configurations work > > changed? > > > > Thanks in advance! > > > > Brian > > > > > >