There's not a problem with loading the files from a URL. I think it works fine for certain cases and I've used that technique in the past for a couple projects.
Java's classloader is worth becoming familliar with because it can be used for all sorts of things. Using it in the way we've been discussing here allows you to avoid being concerned with absolute paths and urls regardless of where you're doing development or deploying your application. Another advantage is that since it's already built-in to the jvm you don't need to rely on external components like webservers to host yout config info. I like to use Classloaders because they give me flexibility in terms of packaging the files. Throughout development the config files can sit unpackaged in a directory somewhere, but when I package up my app, I can put the config files that don't need to change into the jar with the rest of my classes. The same can be done with images and other resources -- keeping everything bundled together into a single jar keeps things simple. It's also easy to override elements that may be packaged in the jar, as long as they appear in a directory referred to by the CLASSPATH prior to the jar's entry in the classpath. Here's one article I found on the subject: http://java.sun.com/j2se/1.3/docs/guide/resources/resources.html hth, Drew. ----- Original Message ----- From: "Smith, Kevin" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Friday, March 01, 2002 12:21 PM Subject: [castor-dev] RE: [castor-dev] R�p. : Re: [castor-dev] Location of files > I've been following this thread, and I'm a bit lost. What's wrong with > loading the files as a URL? That's what I was planning on doing in my > environment. If there is a problem with doing it, I'd like to know. > > --Kevin > > -----Original Message----- > From: Drew Farris [mailto:[EMAIL PROTECTED]] > Sent: Friday, March 01, 2002 12:14 PM > To: [EMAIL PROTECTED] > Subject: Re: [castor-dev] R�p. : Re: [castor-dev] Location of files > > > In the application server environment, you might have to do some tricks to > get the proper ClassLoader which can find your database.xml document. > > ClassLoader.getSystemResourceAsStream will use the SystemClassLoader to get > a > stream, which could be different from the classloader that is actually used > to load your classes. > > perhaps you can use the line: > > this.getClass().getClassLoader().getResourceAsStream(systemId); > > from your EntityResolver implementation. That will make sure that the > classloader that loaded the EntityResolver can be used to load database.xml > instead of the System ClassLoader. > > > On Friday 01 March 2002 09:50 am, Sylvie RAMON wrote: > > Hi, > > > > I "run" slowly in this problem ... > > > > When i use EntityResolver in a simple main() method : It's successfull. > > All xml file are found without indicate physical location. > > > > BUT , with an web application, this failed. > > I use the same method that i use in simple main() method. > > My database.xml is not found! > > The directory wich contain dtabase.xml is in the CLASSPATH. > > > > i don't understand. > > > > Someone has an idea ?? > > > > Thanks for your help. > > > > >>> [EMAIL PROTECTED] 01/03/02 10:07:55 >>> > > > > Hi, > > > > I put the directory where there are files castor in CLASSPATH and my > > application finds database.xml using EntityResolver. > > > > That's a good thing. > > > > BUT now, this os the jdo-conf.dtd which is not found! > > and i think, all mapping.xml will not foud too. > > > > I know that i can put an url for jdo-conf.dtd, but I can't access to > > internet from my pc and so i have pb. So I put jdo-conf.dtd in local. > > > > I can't apply EntityResolver in dtabase.xml, so how can i do that ?? > > > > Thanks for your help. > > Sylvie > > > > > > > > Thanks at all for your help. > > > > I try the EntityResolter solution, but it failed. > > I have the exception "Unable to resolve entity: .... " > > > > When you write "castortest/database.xml" , is castortest in the classpath > > ?? > > > > My castor file are in : > > "root WSAD .../workspace/umm/webApplication/Castor/..xml > > > > There is something i don't understand. > > I continue to search . > > > > Thanks a lot. > > > > >>> [EMAIL PROTECTED] 27/02/02 15:07:54 >>> > > > > I work with VAJ 3.5.2, but I imagine WASD is similar. > > > > I've got the Castor supplied resources in a directory on my classpath. > > c:\Projects\Cim\Resources is on my Workspace classpath, and org\exolab\... > > folders etc are under c:\Projects\Cim\Resources. > > > > For my application specific xml files, I use an EntityResolver with the > > resources on the classpath just like the Castor supplied resources. > > > > Here is how I used the EntityResolver. > > > > try > > { > > lJdo = new JDO(); > > lJdo.setDatabaseName("EMAILD1"); > > > > EmailEntityResolver lEmailEntityResolver = new > > EmailEntityResolver(); > > > > InputSource lDatabaseConfiguration = > > lEmailEntityResolver.resolveEntity(null, > > "castortest/database.xml"); > > > > lJdo.loadConfiguration(lDatabaseConfiguration, > > lEmailEntityResolver, null); > > > > ... > > > > Here is the resolveEntity() method of my EntityResolver. > > > > public org.xml.sax.InputSource resolveEntity(String publicId, > > String systemId) throws IOException, SAXException > > { > > InputStream lInputStream = > > ClassLoader.getSystemResourceAsStream(systemId); > > > > if (lInputStream != null) > > { > > return new InputSource(lInputStream); > > } > > else > > { > > throw new IOException("Unable to resolve entity: " + > > systemId); > > } > > } > > > > -----Original Message----- > > From: Sylvie RAMON [mailto:[EMAIL PROTECTED]] > > Sent: Wednesday, February 27, 2002 3:06 AM > > To: [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.. ) > ----------------------------------------------------------- If you wish to unsubscribe from this mailing, send mail to [EMAIL PROTECTED] with a subject of: unsubscribe castor-dev
