cayenne-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrus Adamchik <and...@objectstyle.org>
Subject Re: DBCPDataSourceFactory Issue
Date Mon, 07 Dec 2009 16:23:17 GMT
FYI, here is a 3.1 rewritten version of the factory:

https://svn.apache.org/repos/asf/cayenne/main/trunk/framework/cayenne-jdk1.5-unpublished/src/main/java/org/apache/cayenne/configuration/DBCPDataSourceFactory.java

It is much cleaner and works off of injectable ResourceService that  
can be defined by the user.


>
> Then my cayenne.xml could say:
>
>   datasource="/path/to/dbcp.properties"

Will probably rename this attribute to "location" in 3.1, as currently  
the name "datasource" makes no sense, and it initializes the  
"location" property in the Java descriptor class.

Andrus


On Dec 7, 2009, at 11:18 AM, Michael Gentry wrote:

> FWIW (if it might help others), I cheated and did this:
>
>
> package org.apache.cayenne.conf;
>
> public class Config
> {
>   public static void configureCayenne()
>   {
>       DefaultConfiguration conf = new DefaultConfiguration();
>       conf.locator.setSkipAbsolutePath(false);
>       Configuration.initializeSharedConfiguration(conf);
>   }
> }
>
>
> Then my cayenne.xml could say:
>
>   datasource="/path/to/dbcp.properties"
>
>
> This seems hackish, but works.  I had to create my config class in
> Cayenne's package space because the locator variable is protected and
> I didn't see a way to get it to set the path properties otherwise.
>
> mrg
>
>
> On Fri, Dec 4, 2009 at 5:01 PM, Andrus Adamchik <andrus@objectstyle.org 
> > wrote:
>> I guess the easiest way is to write your own factory using Cayenne- 
>> provided
>> one as a template.
>>
>> BTW, Cayenne implementation of DBCPDataSourceFactory is over- 
>> engineered. It
>> overlooks a simple way to configure DBCP via
>> org.apache.commons.dbcp.BasicDataSource. So the factory internally  
>> shouldn't
>> look as scary as it does now, and hopefully we'll take advantage of  
>> that
>> during 3.1 DI refactoring.
>>
>> Andrus
>>
>> On Dec 4, 2009, at 9:51 PM, Michael Gentry wrote:
>>
>>> I'm trying to use DBCPDataSourceFactory and load my data source
>>> information from a location external to the project.  I keep getting
>>> errors that it can't find the file.  Has anyone does this
>>> successfully?
>>>
>>> Thanks!
>>>
>>> mrg
>>>
>>
>>
>


Mime
View raw message