struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Davis, Chad" <>
Subject RE: implementaiton advise on custom TextProvider
Date Mon, 15 Oct 2012 15:19:02 GMT

> > ActionSupport#getTextProviderSupport() uses the TextProviderFactory to
> obtain it's instance of a support object.  Since it uses the di to inject this into
> the factory, my custom version is correctly injected.  However, I need to
> initialize my custom support object with a resource that it needs to conduct
> its business.  Note, the default TextPRoviderSupport also needs a couple of
> resources, and those are initialized in the factory's createInstance( Class
> class, LocaleProvider provider ).  So, while I've injected my own class, there
> doesn't seem to be a clean way to make sure that it's initialized properly.
> Should I extend the factory to handle my class and init it too?  Doesn't seem
> very DI-ish . . . hardcoding type specific init logic, I mean.
> >
> > Or should I create an interceptor that will inject the correct resources into
> my text support object?
> ActionSupport base on property injections so you cannot base on anything
> which is injectable - you cannot use getTextProvider during initialisation time
> (construction time). You can implement your own ActionSupport with
> constructor injected TextProvider that should solve your problem.

I'm not sure I follow you.  Just for clarity, let me restate my problem.  I have written a
custom extension of TextProviderSupport.  I want to have it
injected as the framework's default TextProvider.  I have achieved this by configuring it
in struts.xml, declaring my implementation with a <bean/> element and then setting the
constant struts.xworkTextProvider to point at my bean.  

This works, but my implementation needs to be properly injected.  Right now, it's being created
with the default no-arg constructor.  How can I best have my dependencies injected when the
framework creates this bean?  What are my options?  

I restate this because it seems that you are suggesting that I override the ActionSupport
base class inorder to achieve this.  This seems to me to be skipping the framework and simply
creating and injecting my textprovider myself.  Perhaps I misunderstand.    

View raw message