You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Daniel Jue <te...@gmail.com> on 2014/02/14 18:24:53 UTC
Specify SymbolProvider at runtime
Hi, I was wondering what is the best way of doing this:
>From the JVM arguments, I want our developers to specify a location to a
properties file, which will be treated as a symbol source. I tried a naive
approach and got a recursion error on SymbolSource.
In one of my modules I have this:
@Contribute(SymbolSource.class)
public void contributePropertiesFileAsSymbols(
OrderedConfiguration<SymbolProvider> configuration) {
configuration.add("DatabaseConfiguration",
new ClasspathResourceSymbolProvider(dbPropertiesFileLocation),
"after:SystemProperties", "before:ApplicationDefaults");
}
and essentially I'd like the variable dbPropertiesFileLocation to be
something provided on the command line, i.e.
-Dmyapp.db-properties-file-location="C:\mydatabase.properties"
Inside the properties file are several settings that I want to use as
inject-able Symbols. That part already working when I provide the location
in the contribute method, but now I want to tell Tapestry where that file
lives on startup.
Re: Specify SymbolProvider at runtime
Posted by Daniel Jue <te...@gmail.com>.
Thanks Thiago, you are right. I was so caught up in trying to use the
Symbols that I forgot the obvious. :-)
On Fri, Feb 14, 2014 at 2:38 PM, Thiago H de Paula Figueiredo <
thiagohp@gmail.com> wrote:
> On Fri, 14 Feb 2014 15:24:53 -0200, Daniel Jue <te...@gmail.com> wrote:
>
> Hi, I was wondering what is the best way of doing this:
>>
>
> Hi!
>
>
>
> From the JVM arguments, I want our developers to specify a location to a
>> properties file, which will be treated as a symbol source. I tried a
>> naive
>> approach and got a recursion error on SymbolSource.
>>
>> In one of my modules I have this:
>>
>> @Contribute(SymbolSource.class)
>> public void contributePropertiesFileAsSymbols(
>> OrderedConfiguration<SymbolProvider> configuration) {
>> configuration.add("DatabaseConfiguration",
>> new ClasspathResourceSymbolProvider(dbPropertiesFileLocation),
>> "after:SystemProperties", "before:ApplicationDefaults");
>> }
>>
>
> Why don't you use System.getProperty() to get the value passed as a
> command-line parameter?
>
> --
> Thiago H. de Paula Figueiredo
> Tapestry, Java and Hibernate consultant and developer
> http://machina.com.br
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
Re: Specify SymbolProvider at runtime
Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Fri, 14 Feb 2014 15:24:53 -0200, Daniel Jue <te...@gmail.com> wrote:
> Hi, I was wondering what is the best way of doing this:
Hi!
> From the JVM arguments, I want our developers to specify a location to a
> properties file, which will be treated as a symbol source. I tried a
> naive
> approach and got a recursion error on SymbolSource.
>
> In one of my modules I have this:
>
> @Contribute(SymbolSource.class)
> public void contributePropertiesFileAsSymbols(
> OrderedConfiguration<SymbolProvider> configuration) {
> configuration.add("DatabaseConfiguration",
> new ClasspathResourceSymbolProvider(dbPropertiesFileLocation),
> "after:SystemProperties", "before:ApplicationDefaults");
> }
Why don't you use System.getProperty() to get the value passed as a
command-line parameter?
--
Thiago H. de Paula Figueiredo
Tapestry, Java and Hibernate consultant and developer
http://machina.com.br
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org