Sylvie,

I have had luck obtaining a reference to the database an mapping 
config files using the classloader. This way the files can reside 
anywhere in my CLASSPATH and they can be found.

Use ClassLoader.getResourceAsStream() to make the database configuration
file available as a stream using the ClassLoader, and then 
create an InputSource around that Stream. 

You will also need to implement an EntityResolver that also uses.
ClassLoader.getResourceAsStream() to load mapping files. This is pretty 
easy, as you only need something like this:

public InputSource resolveEntity (String publicId, String systemId) {
 return new InputSource(classLoader.getResourseAsStream(systemId));
}

(you will need to do exception handling etc, yourself)

JDO.loadConfiguration(org.xml.sax.InputSource source,
                      org.xml.sax.EntityResolver resolver, 
                      java.lang.ClassLoader loader) 


If you do this, you should be able to place your database.xml and 
mapping.xml files anywhere in the project classpath instead of requiring 
that an absolute path to the files be provided.

If you look at the JavaDoc documentation for each of the classes I've 
mentioned, it should all make sense. 

Good Luck!

Drew.

On Wed, 27 Feb 2002, Sylvie RAMON wrote:

> Date: Wed, 27 Feb 2002 10:05:31 +0100
> From: Sylvie RAMON <[EMAIL PROTECTED]>
> Reply-To: "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
> To: "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
> Subject: [castor-dev] Location of files
> 
> Hi, 
> 
> I have an another question and i don't find response .
> I work with WSAD.
> 
> With JDo and xml, we have to work with a lot of file  ( xml, dtd, etc.. ) .
> I put these files directly on a subdirecory of my project.
> 
> In all my applications, i have to put the physical location of these files ( real 
>location "d:\....." or from root of wsad "/workspace/...".
> 
> So when an another developper want to work with my application or when i deploy 
>application on WAS4, i have problems with the location.
> 
> I would like to put a logical location. Is it possible??
> Is there an another solution to that??
> Do i have to put files in a directory out of my projet ??
> 
> Thanks for your help.
> 
> ----------------------------------------------------------- 
> If you wish to unsubscribe from this mailing, send mail to
> [EMAIL PROTECTED] with a subject of:
>       unsubscribe castor-dev
> 
> 

----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
        unsubscribe castor-dev

Reply via email to