You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Sigbjørn Tvedt <si...@gmail.com> on 2012/01/25 10:15:19 UTC
A question about the MappedConfiguration add/override
Hi.
I am trying to integrate tapestry5-ckeditor(1) in the quickstart examples,
but I have a problem figuring out how tapestry is adding/updating the
application_version key.
In the AppModule, application_version is added by using override(x,y).
In the DevelopmentModule, application_version is added bye using add(x,y).
I am writing the values to the console before they are assigned, and this
is what I get:
-----
DevelopmentModule: SymbolConstants.APPLICATION_VERSION=1.0-SNAPSHOT-DEV
AppModule:SymbolConstants.APPLICATION_VERSION=1.0-SNAPSHOT
-----
According to the printline, DevelopmentModule is added before AppModule
overrides the application_version.
The part where I have a problem understanding is that the application is
using the value from developmentModule where I am adding the value instead
of using the value that was overridden in AppModule. I have also noticed
that if I try to move the line that adds the from DevelopmentModule into
AppModule, I will get and exception saying that the value already exists,
and no key if I try the opposite.
Also, I think I found a bug in the override code (
org.apache.tapestry5.ioc.MappedConfiguration). The comment on the method is:
/**
* Overrides an existing contribution by its key.
*
* @param key
* unique id of value to override
* @param value
* new value, or null to remove the key entirely
* @since 5.1.0.0
*/
void override(K key, V value);
This looks good, but in the ValidatingMappedConfigurationWrapper, an
exception is thrown if the key exists (even if you try to insert a "null")
To sum up:
Why is the value inserted by a call to add used instead of the value
inserted by using override
Why should you use override in AppModule and add in other modules
How is it possible to replace a key?
Is the comment wrong at the override code or should I file a jira?
Regards.
Sigbjørn Tvedt
1: https://github.com/plannowtech/tapestry5-ckeditor
Re: A question about the MappedConfiguration add/override
Posted by Sigbjørn Tvedt <si...@gmail.com>.
You are correct about the processing. The thing that threw me off track is
that the quickstart application mixes where it overrides the symbol.
AppModule has a contributeFactoryDefaults where it sets the application
version and it says that it is possible to override this further in in the
DevelopmentModule wihtout saying that this has to be done in
contributeApplicationDefaults. (I added a jira with a suggestion for an
amendment to the current text in the quickstart. TAP5-1830)
As for the override, I have not been able to create a test case yet (I
think grade dislikes me), but reproducing is quite simple.
In contributeApplicationDefaults (DevelopmentModule.java) I added the
following line:
configuration.override(SymbolConstants.APPLICATION_VERSION,
"1.0-SNAPSHOT-DEV-override");
This runs as expected, but if I want to remove the key using this line
afterwards, I get an exception stating that the key exists:
configuration.override(SymbolConstants.APPLICATION_VERSION, null);
According to the documentation(2), a null value should remove the key, not
throw an exception.(@param value - new value, or null to remove the key
entirely)
Do you remember if this is a feature that is supposed to be removed and the
documentation needs to be updated, or should I try to create a patch+test
for this?
Regards
Sigbjørn Tvedt
2:
http://tapestry.apache.org/tapestry5/apidocs/org/apache/tapestry5/ioc/MappedConfiguration.html#override(K,
V)
On 25 January 2012 17:23, Howard Lewis Ship <hl...@gmail.com> wrote:
> You can only override a key that has been added, and only provide a
> single override for any key. Processing goes in two steps: first the
> adds are applied, then the overrides. In any case, I'm very confident
> about the code and tests for this logic, so if you open a JIRA, be
> sure to include a test case demonstrating the failure.
>
> Tapestry has evolved over time; the override logic came later: in
> earlier code, similar effects were accomplished by having multiple
> services; this is how SymbolSource works to this day: there's the
> "ApplicationDefaults" SymbolProvider, and the "FactoryDefaults"
> SymbolProvider; most likely (without looking at your code) the issue
> is that you are mixing and matching between these two services, just
> causing your confusion. For an example, an override inside
> FactoryDefaults will be ignored in favor of an add to
> ApplicationDefaults.
>
> On Wed, Jan 25, 2012 at 1:15 AM, Sigbjørn Tvedt <si...@gmail.com>
> wrote:
> > Hi.
> >
> > I am trying to integrate tapestry5-ckeditor(1) in the quickstart
> examples,
> > but I have a problem figuring out how tapestry is adding/updating the
> > application_version key.
> >
> > In the AppModule, application_version is added by using override(x,y).
> > In the DevelopmentModule, application_version is added bye using
> add(x,y).
> >
> >
> > I am writing the values to the console before they are assigned, and this
> > is what I get:
> > -----
> > DevelopmentModule: SymbolConstants.APPLICATION_VERSION=1.0-SNAPSHOT-DEV
> > AppModule:SymbolConstants.APPLICATION_VERSION=1.0-SNAPSHOT
> > -----
> >
> >
> > According to the printline, DevelopmentModule is added before AppModule
> > overrides the application_version.
> > The part where I have a problem understanding is that the application is
> > using the value from developmentModule where I am adding the value
> instead
> > of using the value that was overridden in AppModule. I have also noticed
> > that if I try to move the line that adds the from DevelopmentModule into
> > AppModule, I will get and exception saying that the value already exists,
> > and no key if I try the opposite.
> >
> >
> >
> > Also, I think I found a bug in the override code (
> > org.apache.tapestry5.ioc.MappedConfiguration). The comment on the method
> is:
> >
> > /**
> > * Overrides an existing contribution by its key.
> > *
> > * @param key
> > * unique id of value to override
> > * @param value
> > * new value, or null to remove the key entirely
> > * @since 5.1.0.0
> > */
> > void override(K key, V value);
> >
> > This looks good, but in the ValidatingMappedConfigurationWrapper, an
> > exception is thrown if the key exists (even if you try to insert a
> "null")
> >
> >
> > To sum up:
> > Why is the value inserted by a call to add used instead of the value
> > inserted by using override
> > Why should you use override in AppModule and add in other modules
> > How is it possible to replace a key?
> > Is the comment wrong at the override code or should I file a jira?
> >
> >
> >
> > Regards.
> > Sigbjørn Tvedt
> >
> >
> > 1: https://github.com/plannowtech/tapestry5-ckeditor
>
>
>
> --
> Howard M. Lewis Ship
>
> Creator of Apache Tapestry
>
> The source for Tapestry training, mentoring and support. Contact me to
> learn how I can get you up and productive in Tapestry fast!
>
> (971) 678-5210
> http://howardlewisship.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
Re: A question about the MappedConfiguration add/override
Posted by Howard Lewis Ship <hl...@gmail.com>.
You can only override a key that has been added, and only provide a
single override for any key. Processing goes in two steps: first the
adds are applied, then the overrides. In any case, I'm very confident
about the code and tests for this logic, so if you open a JIRA, be
sure to include a test case demonstrating the failure.
Tapestry has evolved over time; the override logic came later: in
earlier code, similar effects were accomplished by having multiple
services; this is how SymbolSource works to this day: there's the
"ApplicationDefaults" SymbolProvider, and the "FactoryDefaults"
SymbolProvider; most likely (without looking at your code) the issue
is that you are mixing and matching between these two services, just
causing your confusion. For an example, an override inside
FactoryDefaults will be ignored in favor of an add to
ApplicationDefaults.
On Wed, Jan 25, 2012 at 1:15 AM, Sigbjørn Tvedt <si...@gmail.com> wrote:
> Hi.
>
> I am trying to integrate tapestry5-ckeditor(1) in the quickstart examples,
> but I have a problem figuring out how tapestry is adding/updating the
> application_version key.
>
> In the AppModule, application_version is added by using override(x,y).
> In the DevelopmentModule, application_version is added bye using add(x,y).
>
>
> I am writing the values to the console before they are assigned, and this
> is what I get:
> -----
> DevelopmentModule: SymbolConstants.APPLICATION_VERSION=1.0-SNAPSHOT-DEV
> AppModule:SymbolConstants.APPLICATION_VERSION=1.0-SNAPSHOT
> -----
>
>
> According to the printline, DevelopmentModule is added before AppModule
> overrides the application_version.
> The part where I have a problem understanding is that the application is
> using the value from developmentModule where I am adding the value instead
> of using the value that was overridden in AppModule. I have also noticed
> that if I try to move the line that adds the from DevelopmentModule into
> AppModule, I will get and exception saying that the value already exists,
> and no key if I try the opposite.
>
>
>
> Also, I think I found a bug in the override code (
> org.apache.tapestry5.ioc.MappedConfiguration). The comment on the method is:
>
> /**
> * Overrides an existing contribution by its key.
> *
> * @param key
> * unique id of value to override
> * @param value
> * new value, or null to remove the key entirely
> * @since 5.1.0.0
> */
> void override(K key, V value);
>
> This looks good, but in the ValidatingMappedConfigurationWrapper, an
> exception is thrown if the key exists (even if you try to insert a "null")
>
>
> To sum up:
> Why is the value inserted by a call to add used instead of the value
> inserted by using override
> Why should you use override in AppModule and add in other modules
> How is it possible to replace a key?
> Is the comment wrong at the override code or should I file a jira?
>
>
>
> Regards.
> Sigbjørn Tvedt
>
>
> 1: https://github.com/plannowtech/tapestry5-ckeditor
--
Howard M. Lewis Ship
Creator of Apache Tapestry
The source for Tapestry training, mentoring and support. Contact me to
learn how I can get you up and productive in Tapestry fast!
(971) 678-5210
http://howardlewisship.com
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org