Re: Access the ApplicationGlobals inside the AppModule::bind() method

2008-10-07 Thread Edouard sur edouardmercier.fr
Thank you for this very quick and clear answer!

Does it mean that I will be able to inject the
PropertiesFileSymbolProvider object inside the
AppModule::bind(ServiceBinder binder,
@InjectService(PropertiesFileSymbolProvider) SymbolProvider
propertiesFileSymbolProvider) method this way? Or should I declare a
@Inject @Symbol(value=MyParam) private String myParam; (should be
static) inside my AppModule (after having declared the properties
symbol provider via the public PropertiesFileSymbolProvider
buildPropertiesFileSymbolProvider(Logger logger) and public static
void contributeSymbolSource(OrderedConfigurationSymbolProvider
configuration, ... methods)?

Because I need to access the property before the service is created,
since it's implementation should depend on some property.

Thank you.
Édouard

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Access the ApplicationGlobals inside the AppModule::bind() method

2008-10-07 Thread Ulrich Stärk
Some of us (including me) tried to do the same thing but failed. See here
http://markmail.org/message/hdcboxjrxkrgruyy for the discussion. It seems
to come down to the order in which services are instantiated. By the time
your service is being instantiated, the ServletContext has not yet been
set in the ApplicationGlobals service and thus is null. At the moment,
there doesn't seem to be a workaround if you want to configure your
services whith init-params. You could, however, use a properties file. How
to do that is explained here:
http://wiki.apache.org/tapestry/Tapestry5HowToReadSymbolsFromPropertiesFile

HTH,

Uli

Am Di, 7.10.2008, 10:42, schrieb Edouard sur edouardmercier.fr:
 Hello again.

 I would like the service implementation binding (inside the
 AppModule::bind(ServiceBinder binder)) to depend on the web.xml
 configuration file. This is the reason why I would like to access the
 ApplicationGlobal instance inside the method (in order to call as
 globals.getServletContext().getInitParameter(MyParam)), so as to
 provide the right implementation depending on some context-param
 value.

 Is it feasible? Is there a work-around, or another way to achieve that,
 please?

 Thank you so much for your help.
 Édouard

 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]





-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Access the ApplicationGlobals inside the AppModule::bind() method

2008-10-07 Thread Ulrich Stärk
After you defined the PropertiesFileSymbolProvider, you have to contribute
it to the SymbolSource service (see the HOWTO). Afterwards you can just
@Inject @Symbol(your-symbol-name-here) final String something into your
service builder method, e.g.

public YourService buildYourService(@Inject @Symbol(mysymbol) final
String mysymbol)
{
  // do something using mysymbol
}

The symbol's value will be searched in different places (see the HOWTO),
including the PropertiesFileSymbolProvider if contributed...

Uli

Am Di, 7.10.2008, 11:07, schrieb Edouard sur edouardmercier.fr:
 Thank you for this very quick and clear answer!

 Does it mean that I will be able to inject the
 PropertiesFileSymbolProvider object inside the
 AppModule::bind(ServiceBinder binder,
 @InjectService(PropertiesFileSymbolProvider) SymbolProvider
 propertiesFileSymbolProvider) method this way? Or should I declare a
 @Inject @Symbol(value=MyParam) private String myParam; (should be
 static) inside my AppModule (after having declared the properties
 symbol provider via the public PropertiesFileSymbolProvider
 buildPropertiesFileSymbolProvider(Logger logger) and public static
 void contributeSymbolSource(OrderedConfigurationSymbolProvider
 configuration, ... methods)?

 Because I need to access the property before the service is created,
 since it's implementation should depend on some property.

 Thank you.
 Édouard

 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]





-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Access the ApplicationGlobals inside the AppModule::bind() method

2008-10-07 Thread Ville Virtanen

Just 

bind(@Inject @Symbol(some.identifier) String someSymbol)

I think. This initiates the construction of symbolsource, which in turn
calls the contribute in your appmodule which initiates the construction of
the PropertiesFileSymbolProvider which reads the file.

And btw, I would recommend http://www.nabble.com/Tapestry-f302.html to read
the post lists. You see both developer and user forums from that link, but
can filter either one by choosing the appropriate one from the top of the
page. (Child Forums)



Edouard sur edouardmercier.fr wrote:
 
 Thank you for this very quick and clear answer!
 
 Does it mean that I will be able to inject the
 PropertiesFileSymbolProvider object inside the
 AppModule::bind(ServiceBinder binder,
 @InjectService(PropertiesFileSymbolProvider) SymbolProvider
 propertiesFileSymbolProvider) method this way? Or should I declare a
 @Inject @Symbol(value=MyParam) private String myParam; (should be
 static) inside my AppModule (after having declared the properties
 symbol provider via the public PropertiesFileSymbolProvider
 buildPropertiesFileSymbolProvider(Logger logger) and public static
 void contributeSymbolSource(OrderedConfigurationSymbolProvider
 configuration, ... methods)?
 
 Because I need to access the property before the service is created,
 since it's implementation should depend on some property.
 
 Thank you.
 Édouard
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 

-- 
View this message in context: 
http://www.nabble.com/Access-the-ApplicationGlobals-inside-the-%22AppModule%3A%3Abind%28%29%22-method-tp19853806p19854609.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]