Hmm... I can't find any code that's using it. All my incantations ended up causing recursion with the Alias service.
Here is something that works by being lazy: @Contribute(SymbolSource.class) public void addTestResourceSymbols(OrderedConfiguration<SymbolProvider> configuration, @InjectService("ApplicationGlobals") final ApplicationGlobals applicationGlobals ) { configuration.add("testResources", new SymbolProvider() { private volatile ContextResourceSymbolProvider provider = null; public String valueForSymbol(String symbolName) { if (provider == null) { synchronized (this) { if (provider == null) provider = new ContextResourceSymbolProvider(applicationGlobals.getContext(), "test.properties"); } } return provider.valueForSymbol(symbolName); } }); } On Thu, Jul 21, 2011 at 8:27 AM, Erik Fäßler <erik.faess...@uni-jena.de> wrote: > Hey all, > > I've been struggling for a while with what seems to be a simple task at > first: > > "On WebApp startup, load a configuration file - located in the app's > context, i.e. in the WEB-INF directory - and contribute its contents to > Tapestry's SymbolSource service." > > I always get in trouble by the (servlet)context being null when > contributing. I get the ApplicationGlobals service and get the context from > it. > I have a solution were the context is _sometimes_ null and sometimes not - > so I just have to restart the servlet container as often enough as it will > eventually work. Of course, this is nothing to keep it this way. In fact, > it's quite annoying ;-) > In the end I thought that it would just not be possible to access the > ServletContext for contributing a SymbolSource depending on it. But then I > came about the "ContextResourceSymbolProvider" class. I would have thought > you would use it that way: > > public static void contributeSymbolSource(final > OrderedConfiguration<SymbolProvider> configuration, > @InjectService("ApplicationGlobals")ApplicationGlobals applicationGlobals) { > configuration.add("SemedicoToolsSymbols", new > ContextResourceSymbolProvider(applicationGlobals.getContext(), > "configuration.properties"), "before:ApplicationDefaults"); > } > > but this does not work as described above: At this point of application > startup, the context (gotten by applicationGlobals.getContext() as shown > above) is null. > > So I have two questions: > 1) How to use ContextResourceSymbolProvider? I currently can't imagine a > useful employment of this class without being able to contribute it to > Tapestry's SymbolSource. > 2) Is it at all possible to read a file from the context and contribute it > to the SymbolSource service? Goal: Being able to configure my WebApp from > file rather than being forced to edit the code every time I change > deployment (from test to productive for instance; I would have to change my > local paths to the correct paths in the productive environment; other > developers have their own local resources, etc). > > Thanks for your time! > > Best, > > Erik > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org > For additional commands, e-mail: users-h...@tapestry.apache.org > > --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org