You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by "Poggenpohl, Daniel" <Da...@isst.fraunhofer.de> on 2015/07/28 15:31:55 UTC

Contributing a Symbol Provider

Hello,

I want to provide additional configuration on startup to my Tapestry application. I want to store the additional configuration in a file containing lines "key=value".
I know I can contribute a symbol provider to load a file and access the symbols this way.

But I can't find the documentation for
- what method to write in the AppModule to contribute the Symbol Provider
- How to write a Symbol Provider

Can anyone help?

Regards,
Daniel P.

Re: Contributing a Symbol Provider

Posted by Richard Kirby <rb...@capdm.com>.
Hi Daniel,

I use the following sort of code:

SymbolProvider provider = new MySymbolProvider(File configFile);
ContributionDef contribution = new
org.apache.tapestry5.internal.SyntheticSymbolSourceContributionDef("MyConfig",
provider, "before:ApplicationDefaults");

...

RegistryBuilder builder = new RegistryBuilder();
builder.add(new
org.apache.tapestry5.internal.SyntheticModuleDef(contribution));

Note that I am using 2 internal package classes, so not guaranteed across
Tapestry versions, but it does work for me.

Richard

On 28 July 2015 at 14:31, Poggenpohl, Daniel <
Daniel.Poggenpohl@isst.fraunhofer.de> wrote:

> Hello,
>
> I want to provide additional configuration on startup to my Tapestry
> application. I want to store the additional configuration in a file
> containing lines "key=value".
> I know I can contribute a symbol provider to load a file and access the
> symbols this way.
>
> But I can't find the documentation for
> - what method to write in the AppModule to contribute the Symbol Provider
> - How to write a Symbol Provider
>
> Can anyone help?
>
> Regards,
> Daniel P.
>



-- 

Richard Kirby, Technical Director

CAPDM Limited

Direct phone: 0131 477 8629

Email: rbk@capdm.com  Website: www.capdm.com

Registered in Scotland: SC168970       VAT: 682 846 983

Registered address: 22 Forth Street, Edinburgh, EH1 3LH, UK

Re: AW: Contributing a Symbol Provider

Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Tue, 28 Jul 2015 15:19:33 -0300, Poggenpohl, Daniel  
<Da...@isst.fraunhofer.de> wrote:

> Hi,

Hi!

> I've implemented a working solution using the method on this page:
>
> http://wiki.apache.org/tapestry/Tapestry5HowToReadSymbolsFromPropertiesFile
> I implemented a SymbolProvider, a buildFileSymbolProvider method and a  
> contributeSymbolSource method.
>
> How is your method different from that one?

The method is exactly the same: creating one SymbolSource implementation  
and contribute it to the SymbolSource distributed configuration. The URL  
above just provides two SymbolSource implementations based on property  
files and declares both as services, which is good but not a requirement  
for it to work, while I just provided a sketch on how to implement them  
and how to contribute them.

-- 
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: Contributing a Symbol Provider

Posted by Richard Kirby <rb...@capdm.com>.
Hi Daniel,

No, your method is fine. I needed my method as I needed some properties
accessible before I could start up the Registry, so this killed two birds
with one stone.

If you don't need the properties until after building the Registry, then
you will be fine with the documented method.

Richard

On 28 July 2015 at 19:19, Poggenpohl, Daniel <
Daniel.Poggenpohl@isst.fraunhofer.de> wrote:

> Hi,
>
> I've implemented a working solution using the method on this page:
>
> http://wiki.apache.org/tapestry/Tapestry5HowToReadSymbolsFromPropertiesFile
> I implemented a SymbolProvider, a buildFileSymbolProvider method and a
> contributeSymbolSource method.
>
> How is your method different from that one? Should I prefer your method?
> What will happen when I use my method?
>
> Regards,
> Daniel P.
>
> -----Ursprüngliche Nachricht-----
> Von: Thiago H de Paula Figueiredo [mailto:thiagohp@gmail.com]
> Gesendet: Dienstag, 28. Juli 2015 16:56
> An: Tapestry users
> Betreff: Re: Contributing a Symbol Provider
>
> On Tue, 28 Jul 2015 10:31:55 -0300, Poggenpohl, Daniel <
> Daniel.Poggenpohl@isst.fraunhofer.de> wrote:
>
> > Hello,
>
> Hi!
>
> > I want to provide additional configuration on startup to my Tapestry
> > application. I want to store the additional configuration in a file
> > containing lines "key=value".
> > I know I can contribute a symbol provider to load a file and access
> > the symbols this way.
> >
> > But I can't find the documentation for
> > - How to write a Symbol Provider
>
> Implement the SymbolProvider interface. It has a single method, String
> valueForSymbol(String symbolName). It should return a String if that
> implementation provides a value for that symbol name and null if not.
>
> > - what method to write in the AppModule to contribute the Symbol
> > Provider
>
> public static void
> contributeSymbolProvider(OrderedConfiguration<SymbolProvider>
> configuration) {
>         configuration.add("MyProvider", new
> YourSymbolProviderImplementation(),
> "before:*");
> }
>
> --
> 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
>
>


-- 

Richard Kirby, Technical Director

CAPDM Limited

Direct phone: 0131 477 8629

Email: rbk@capdm.com  Website: www.capdm.com

Registered in Scotland: SC168970       VAT: 682 846 983

Registered address: 22 Forth Street, Edinburgh, EH1 3LH, UK

AW: Contributing a Symbol Provider

Posted by "Poggenpohl, Daniel" <Da...@isst.fraunhofer.de>.
Hi,

I've implemented a working solution using the method on this page:

http://wiki.apache.org/tapestry/Tapestry5HowToReadSymbolsFromPropertiesFile
I implemented a SymbolProvider, a buildFileSymbolProvider method and a contributeSymbolSource method.

How is your method different from that one? Should I prefer your method? What will happen when I use my method?

Regards,
Daniel P.

-----Ursprüngliche Nachricht-----
Von: Thiago H de Paula Figueiredo [mailto:thiagohp@gmail.com] 
Gesendet: Dienstag, 28. Juli 2015 16:56
An: Tapestry users
Betreff: Re: Contributing a Symbol Provider

On Tue, 28 Jul 2015 10:31:55 -0300, Poggenpohl, Daniel <Da...@isst.fraunhofer.de> wrote:

> Hello,

Hi!

> I want to provide additional configuration on startup to my Tapestry 
> application. I want to store the additional configuration in a file 
> containing lines "key=value".
> I know I can contribute a symbol provider to load a file and access 
> the symbols this way.
>
> But I can't find the documentation for
> - How to write a Symbol Provider

Implement the SymbolProvider interface. It has a single method, String valueForSymbol(String symbolName). It should return a String if that implementation provides a value for that symbol name and null if not.

> - what method to write in the AppModule to contribute the Symbol 
> Provider

public static void
contributeSymbolProvider(OrderedConfiguration<SymbolProvider>
configuration) {
	configuration.add("MyProvider", new YourSymbolProviderImplementation(),
"before:*");
}

--
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: Contributing a Symbol Provider

Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Tue, 28 Jul 2015 10:31:55 -0300, Poggenpohl, Daniel  
<Da...@isst.fraunhofer.de> wrote:

> Hello,

Hi!

> I want to provide additional configuration on startup to my Tapestry  
> application. I want to store the additional configuration in a file  
> containing lines "key=value".
> I know I can contribute a symbol provider to load a file and access the  
> symbols this way.
>
> But I can't find the documentation for
> - How to write a Symbol Provider

Implement the SymbolProvider interface. It has a single method, String  
valueForSymbol(String symbolName). It should return a String if that  
implementation provides a value for that symbol name and null if not.

> - what method to write in the AppModule to contribute the Symbol Provider

public static void  
contributeSymbolProvider(OrderedConfiguration<SymbolProvider>  
configuration) {
	configuration.add("MyProvider", new YourSymbolProviderImplementation(),  
"before:*");
}

-- 
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