You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by Lukasz Lenart <lu...@googlemail.com> on 2009/07/27 22:42:36 UTC

Xwork injecting

Hi,

I'm working on two bugs regarding injecting custom TextProvider into
XWork classes. The default TextProvider is defined in
XWorkConfigurationProvider class, but when I tried to define my own
bean in a xml config file, I've got exception:

Caused by: Bean type interface com.opensymphony.xwork2.TextProvider
with the name system has already been loaded by [unknown location] -
bean - file:/C:/java-projects/xwork-2-1-x-trunk/core/target/test-classes/com/opensymphony/xwork2/config/providers/xwork-test-text-provider.xml:8:137
	at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register(XmlConfigurationProvider.java:205)

So, I removed the default TextProvider definition from
XWorkConfigurationProvider class, update default xwork-default.xml
file (which is mismatched in many places ;-) and so on. After few more
changes only one test is falling: SpringObjectFactoryTest, but is it
possible to override such definition and omit all that changes I made?


Regards
-- 
Lukasz
http://www.lenart.org.pl/
http://dailylog.lenart.org.pl/

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: Xwork injecting

Posted by Musachy Barroso <mu...@gmail.com>.
XWork has a similar class, it is called XWorkConfigurationProvider.

musachy

On Mon, Jul 27, 2009 at 11:31 PM, Lukasz
Lenart<lu...@googlemail.com> wrote:
> 2009/7/27 Musachy Barroso <mu...@gmail.com>:
>> <constant name="struts.textProvider.class" value="mytextprovider" />
>>
>> Then you register the bean in BeanSelectionProvider, like:
>>
>> alias(TextProvider.class, "struts.textProvider.class", builder, props);
>
> But this will work only for Struts and not for XWork where the problem
> is, right? As I understand XWork first build configuration base on
> XWorkConfigurationProvider and on any number of
> XmlConfigurationProviders (one for each xml config file). And base on
> that, the Conatainer is created with defined beans ready to inject.
> So, the only option to override bean definition is to put it in
> xwork-default.xml and remove hard coded factory from
> XWorkConfigurationProvider?
>
> Or what is the difference between DefaultTextProvider (which looks
> like it should be used only by Xwork internals) and
> TextProviderSupport? Maybe all I need to do is to clean up such
> separation of concern and make as musachy suggest? Anybody knows?
>
>
> Regards
> --
> Lukasz
> http://www.lenart.org.pl/
> http://dailylog.lenart.org.pl/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> For additional commands, e-mail: dev-help@struts.apache.org
>
>



-- 
"Hey you! Would you help me to carry the stone?" Pink Floyd

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: Xwork injecting

Posted by Lukasz Lenart <lu...@googlemail.com>.
2009/7/27 Musachy Barroso <mu...@gmail.com>:
> <constant name="struts.textProvider.class" value="mytextprovider" />
>
> Then you register the bean in BeanSelectionProvider, like:
>
> alias(TextProvider.class, "struts.textProvider.class", builder, props);

But this will work only for Struts and not for XWork where the problem
is, right? As I understand XWork first build configuration base on
XWorkConfigurationProvider and on any number of
XmlConfigurationProviders (one for each xml config file). And base on
that, the Conatainer is created with defined beans ready to inject.
So, the only option to override bean definition is to put it in
xwork-default.xml and remove hard coded factory from
XWorkConfigurationProvider?

Or what is the difference between DefaultTextProvider (which looks
like it should be used only by Xwork internals) and
TextProviderSupport? Maybe all I need to do is to clean up such
separation of concern and make as musachy suggest? Anybody knows?


Regards
-- 
Lukasz
http://www.lenart.org.pl/
http://dailylog.lenart.org.pl/

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Re: Xwork injecting

Posted by Musachy Barroso <mu...@gmail.com>.
you can't define 2 beans with the same type and the same name (in this
case empty by default). if you want to make it pluggable(that a word?)
 you first need to give it a name, like

<bean type="sometype" class="mytextprovider" name="mytextprovider" />

that will register the bean in the container (also give a default name
to the current provider, like "struts"). Now, that bean is not used,
because xwork is wired to use the default provider. So you need to add
a constant that will act like a "switch" for text provider
implementations:

<constant name="struts.textProvider.class" value="mytextprovider" />

Then you register the bean in BeanSelectionProvider, like:

alias(TextProvider.class, "struts.textProvider.class", builder, props);

The ActionMapper is a perfect example of this, look at
struts-default.xml and BeanSelectionProvider.

musachy

On Mon, Jul 27, 2009 at 1:42 PM, Lukasz
Lenart<lu...@googlemail.com> wrote:
> Hi,
>
> I'm working on two bugs regarding injecting custom TextProvider into
> XWork classes. The default TextProvider is defined in
> XWorkConfigurationProvider class, but when I tried to define my own
> bean in a xml config file, I've got exception:
>
> Caused by: Bean type interface com.opensymphony.xwork2.TextProvider
> with the name system has already been loaded by [unknown location] -
> bean - file:/C:/java-projects/xwork-2-1-x-trunk/core/target/test-classes/com/opensymphony/xwork2/config/providers/xwork-test-text-provider.xml:8:137
>        at com.opensymphony.xwork2.config.providers.XmlConfigurationProvider.register(XmlConfigurationProvider.java:205)
>
> So, I removed the default TextProvider definition from
> XWorkConfigurationProvider class, update default xwork-default.xml
> file (which is mismatched in many places ;-) and so on. After few more
> changes only one test is falling: SpringObjectFactoryTest, but is it
> possible to override such definition and omit all that changes I made?
>
>
> Regards
> --
> Lukasz
> http://www.lenart.org.pl/
> http://dailylog.lenart.org.pl/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> For additional commands, e-mail: dev-help@struts.apache.org
>
>



-- 
"Hey you! Would you help me to carry the stone?" Pink Floyd

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org