From: <kea...@na...> - 2003-03-26 20:25:59
|
I think it would be great to add this Constructor, but it's a bit more complicated. The args to the WM constructor are used to determine the Broker instance. Currently the key used to retreive the Broker for a Servlet is just the ServletContext. Since the broker manages the settings, you would want a separate broker instance for each ServletContext/Settings combination AFAICT. The best approach may be to implement a new Broker class that the new WM constructor would use. Then the new Broker could handle the various kinds of settings that you want to throw at it transparently. btw, this seems like a lot of extra complexity in order to accommodate this particular functionality. I'm guessing that the idea here is that this would require less system resources than lots of separate Web apps. Perhaps this should be a post 1.0 enhancement? Just a thought. (I like to follow the XP model of building the simplest solution first and then refactoring.) Keats > -----Original Message----- > From: Marc Palmer [mailto:ma...@an...] > Sent: Wednesday, March 26, 2003 2:49 PM > To: web...@li... > Subject: [Webmacro-devel] The webapp: I need help with WM > config hassles > > > > Hi all, > > I'm trying to create instances of WM at runtime based on the > "modules" a > user has configured in this webapp I'm writing. Basically > each "module" has > its own properties file with settings for the webapp, but > also they can > supply WebMacro properties that would normally be in > WebMacro.properties. > > The problem is that I need to load templates from the webapp > context, but > if I use the WM(Servlet) constructor I cannot force it to use > a specific > .properties file for the settings. > > If I don't use the WM(Servlet) constructor, things won't work > obviously. > I'm using the delegating template provider and need to use > webapp:/WEB- > INF/templates (for example) as a path. > > I think I would need to introduce a new ctor for WM - > WM(Servlet, String > configFile). What do you think? > > Following on from this, I actually want my webapp to > predetermine some of > the settings, without them existing in a file. For example I > want to set > the template provider to the delegating template provider, > and set the > default template path to webapp:/WEB-INF/templates and > webapp:/templates > and webapp:/ - and still allow the module writer to override > this with new > settings in their module properties file. > > To do this programmatically I would plan to create a > Properties object and > set my template path properties on it. Then I would create another > Properties and set the first Properties I created as its > "ancestor" in the > constructor - and then load the module's specific properties into it. > > THEN I would pass that Properties to the constructor of WM... which I > can't. Is there any reason anyone can see why I can't just > add a ctor to WM > that takes a Properties object instead of the filename? Of > coure I'd have > to add WM(Servlet, Properties) too. > > Thoughts? > > Marc > |