Specify SymbolProvider at runtime

2014-02-14 Thread Daniel Jue
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(
OrderedConfigurationSymbolProvider 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

2014-02-14 Thread Thiago H de Paula Figueiredo

On Fri, 14 Feb 2014 15:24:53 -0200, Daniel Jue teamp...@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(
OrderedConfigurationSymbolProvider 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-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org



Re: Specify SymbolProvider at runtime

2014-02-14 Thread Daniel Jue
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 
thiag...@gmail.com wrote:

 On Fri, 14 Feb 2014 15:24:53 -0200, Daniel Jue teamp...@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(
 OrderedConfigurationSymbolProvider 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-unsubscr...@tapestry.apache.org
 For additional commands, e-mail: users-h...@tapestry.apache.org