Re: [Simpleweb-Support] Multiple File Roots
Brought to you by:
niallg
From: Niall G. <gal...@ya...> - 2005-11-28 17:40:30
|
Hi Brian, No, you do not have to rewrite the LoaderEngine to do this. What you can do is extend it in much the same way as the MapperEngine does. If you wish to add multiple paths to the classpath used by the loader engine then you can delegate to the following constructor. LoaderEngine(Context context, URL[] codebase); Simply add additional URLs in the form file:///a/b/c/path, etc. If you would like the Context to find files from multiple roots, then you should consider using the Locator. The locator performs a search for files from multiple locations. I typically use this for loading configuration files. The simple.http.serve.FileLocator is good for this. For example you could use: Locator loc = context.getLocator(); loc.getFile("/my/file.txt"); The file is searched for within all roots specified to the FileLocator. To increase the number of roots you can do the following: new FileLocator(new File[]{new File("root1"), new File("root2")}); Also you will have to extend the FileContext like follows: class MyFileContext extends FileContext { private Locator loc; public MyFileContext(File base, Locator loc) { super(base); this.loc = loc; } public Locator getLocator() { return loc; } } Hope this helps. Niall --- Brian Davis <wic...@gm...> wrote: > Hi > > I am using a FileContext with a LoaderEngine to set > the 'root' of the > web server. > > FileContext context = new FileContext(new > File("webserverroot/")); > > LoaderEngine engine = new > LoaderEngine(context); > > > This works just dandy.. but I would like to support > the concept of > multiple server roots... > > Do I have to rewrite the LoaderEngine to accomplish > this? > > LoaderEngine engine = new LoaderEngine(); > > engine.addContext(new FileContext(new > File("root1")); > engine.addContext(new FileContext(new > File("root2")); > > Also.. would be nice if the resolver tried to > resolve in root1.. then > root2.. then fail.. > > Any help would be much appreciated.. > > Thanks! > > Brian > > > ------------------------------------------------------- > This SF.net email is sponsored by: Splunk Inc. Do > you grep through log files > for problems? Stop! Download the new AJAX search > engine that makes > searching your log files as easy as surfing the > web. DOWNLOAD SPLUNK! > http://ads.osdn.com/?ad_idv37&alloc_id865&op=click > _______________________________________________ > Simpleweb-Support mailing list > Sim...@li... > https://lists.sourceforge.net/lists/listinfo/simpleweb-support > Niall Gallagher __________________________________ Yahoo! Mail - PC Magazine Editors' Choice 2005 http://mail.yahoo.com |