You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Mike Baranski <li...@secmgmt.com> on 2009/09/16 21:49:23 UTC
Calling an "init" method on an interceptor
I'm using Spring IOC, and need struts to call an init() method on an
interceptor *after* spring does its injection.
Can someone help, I'm stumped...
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
RE: Calling an "init" method on an interceptor
Posted by Mike Baranski <li...@secmgmt.com>.
>-----Original Message-----
>From: Marty Milligan [mailto:milligansisland@gmail.com]
>Sent: Thursday, September 17, 2009 2:16 PM
>To: Struts Users Mailing List
>Subject: Re: Calling an "init" method on an interceptor
>
>On Thu, Sep 17, 2009 at 1:03 PM, Mike Baranski
><li...@secmgmt.com> wrote:
>> I did see that, but I need spring to inject into the instantiated
>instance
>> from struts.xml, not the injected one from applicationContext.xml.
> They
>> seem to be 2 different ones if I have it in both.
>>
>> Maybe I can tell spring to grab the bean from struts, but I don't know
>how.
>
>You can do it the other way round fairly easily. Just use a Spring
>object factory. Just make sure the setters on the Spring side do
>everything you need done before the init.
>
>--
Thanks, I think I just didn't know what the "spring object factory" was
called so I couldn't search for it. That should do it.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Calling an "init" method on an interceptor
Posted by Marty Milligan <mi...@gmail.com>.
On Thu, Sep 17, 2009 at 1:03 PM, Mike Baranski
<li...@secmgmt.com> wrote:
> I did see that, but I need spring to inject into the instantiated instance
> from struts.xml, not the injected one from applicationContext.xml. They
> seem to be 2 different ones if I have it in both.
>
> Maybe I can tell spring to grab the bean from struts, but I don't know how.
You can do it the other way round fairly easily. Just use a Spring
object factory. Just make sure the setters on the Spring side do
everything you need done before the init.
--
cordially,
Marty Milligan PO Box 434, Falling Waters, WV 25419
http://milligansisland.com/ http://byteslinger.com/
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
RE: Calling an "init" method on an interceptor
Posted by Mike Baranski <li...@secmgmt.com>.
>-----Original Message-----
>From: Marty Milligan [mailto:milligansisland@gmail.com]
>Sent: Thursday, September 17, 2009 11:43 AM
>To: Struts Users Mailing List
>Subject: Re: Calling an "init" method on an interceptor
>
>On Thu, Sep 17, 2009 at 10:19 AM, Mike Baranski
><li...@secmgmt.com> wrote:
>> Right, that sounds reasonable, and does not sound too sketchy to me, I
>just
>> need to do a DB query for a config value, and don't want it to happen
>for
>> every action.
>
>Does it have to happen in Struts? There is a hook for this in Spring.
>
>See init-method and destroy-method bean attributes.
I did see that, but I need spring to inject into the instantiated instance
from struts.xml, not the injected one from applicationContext.xml. They
seem to be 2 different ones if I have it in both.
Maybe I can tell spring to grab the bean from struts, but I don't know how.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Calling an "init" method on an interceptor
Posted by Marty Milligan <mi...@gmail.com>.
On Thu, Sep 17, 2009 at 10:19 AM, Mike Baranski
<li...@secmgmt.com> wrote:
> Right, that sounds reasonable, and does not sound too sketchy to me, I just
> need to do a DB query for a config value, and don't want it to happen for
> every action.
Does it have to happen in Struts? There is a hook for this in Spring.
See init-method and destroy-method bean attributes.
--
cordially,
Marty Milligan PO Box 434, Falling Waters, WV 25419
http://milligansisland.com/ http://byteslinger.com/
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
RE: Calling an "init" method on an interceptor
Posted by Mike Baranski <li...@secmgmt.com>.
Right, that sounds reasonable, and does not sound too sketchy to me, I just
need to do a DB query for a config value, and don't want it to happen for
every action.
M.
>-----Original Message-----
>From: Dale Newfield [mailto:dale@newfield.org]
>Sent: Wednesday, September 16, 2009 4:12 PM
>To: Struts Users Mailing List
>Subject: Re: Calling an "init" method on an interceptor
>
>Mike Baranski wrote:
>> I'm using Spring IOC, and need struts to call an init() method on an
>> interceptor *after* spring does its injection.
>
>If you can detect in code when all the injections are done (all
>associated private members are non-null), then you could add a
>conditional call to your init method to the end of each DI setter, which
>should result in it getting called once as the last injection
>completes... (kind of a hack, but it should work)
>
>-Dale
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>For additional commands, e-mail: user-help@struts.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Calling an "init" method on an interceptor
Posted by Dale Newfield <da...@newfield.org>.
Mike Baranski wrote:
> I'm using Spring IOC, and need struts to call an init() method on an
> interceptor *after* spring does its injection.
If you can detect in code when all the injections are done (all
associated private members are non-null), then you could add a
conditional call to your init method to the end of each DI setter, which
should result in it getting called once as the last injection
completes... (kind of a hack, but it should work)
-Dale
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org