You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Marco Mistroni <mm...@waersystems.com> on 2005/05/04 11:48:55 UTC

Struts 1.3, chain & command configuration / few thoughts..

Hello all,
	I am currently using Struts 1.3dev in my application, and I have
recently bothered the list to find a way to configure commands via
Spring.
Now, just yesterday, I came across an article
(http://www.onjava.com/pub/a/onjava/2005/03/02/commonchains2.html)
on how The new RequestProcessor is used in Struts 1.3...
Struts 1.3 uses a chain-config.xml and custom chan configs that allows
user
To 'override' or change the behaviour of request processor.

Following that article I have implemented my custom command for
pre-processing in RequestProcessor (as showed in article).

Question is: what if I want to use some of my spring beans in one of
those
'request processor' commands?

Currently, in my app, I am using commands for doing various logic, and
those
Commands are configured via Spring by using a Spring plugin..

But I am not sure I can do same with RequestProcessor commands, since
the chain-config.xml file is read at initialization time, when I suppose
the Spring plugin has not been initialized yet... so the bean won't be
available..

If I remember correct, there's a way in Spring to say that a 'bean' will
be initialized only after  'beanx' has been initialized (I guess is a
'depend' attribute ein applicationContext.xml)..

But will this work for RequestProcessor commands?

Hope I was clear enough to explain my problem...

Thanx in advance and regars
	marco


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


RE: Struts 1.3, chain & command configuration / few thoughts..

Posted by Joe Germuska <Jo...@Germuska.com>.
At 12:00 PM +0100 5/4/05, Marco Mistroni wrote:
>Hello joe,
>>So really, all you should need to do is write a custom subclass of
>>ComposableRequestProcessor which gets its base CatalogFactory from
>>Spring during the init method.   Then, you'd have to adapt the
>>default chain-config.xml into Spring's bean-factory XML syntax so as
>>to create a CatalogFactory and register the "struts" catalog all in
>>Spring.
>
>That's true... but spring & appContext are initialized only after
>The spring plugIn has been initialized, and I was wondering, are
>plugIn initialized AFTER ComposableRequestProcessor?
>Because, if it is so, then I am out of business :-)

Ah, yeah.  I've been using the ContextLoaderListener instead.

The other thing you could do in your RequestProcessor is lazily look 
up the CatalogFactory.  If you made sure that the instantiation in 
Spring was not lazy and was not a singleton then I guess you could 
retrieve it from the ApplicationContext on each request with no big 
issues.

It's possible that I still didn't quite get the 
ComposableRequestProcessor right for that kind of use case -- I'd 
have to look -- but I think you can still get there...

Joe



>
>Regards
>	marco
>
>
>
>
>
>
>
>
>
>Joe
>
>
>
>At 10:48 AM +0100 5/4/05, Marco Mistroni wrote:
>>Hello all,
>>	I am currently using Struts 1.3dev in my application, and I have
>>recently bothered the list to find a way to configure commands via
>>Spring.
>>Now, just yesterday, I came across an article
>>(http://www.onjava.com/pub/a/onjava/2005/03/02/commonchains2.html)
>>on how The new RequestProcessor is used in Struts 1.3...
>>Struts 1.3 uses a chain-config.xml and custom chan configs that allows
>>user
>>To 'override' or change the behaviour of request processor.
>>
>>Following that article I have implemented my custom command for
>>pre-processing in RequestProcessor (as showed in article).
>>
>>Question is: what if I want to use some of my spring beans in one of
>>those
>>'request processor' commands?
>>
>>Currently, in my app, I am using commands for doing various logic, and
>>those
>>Commands are configured via Spring by using a Spring plugin..
>>
>>But I am not sure I can do same with RequestProcessor commands, since
>>the chain-config.xml file is read at initialization time, when I
>suppose
>>the Spring plugin has not been initialized yet... so the bean won't be
>>available..
>>
>>If I remember correct, there's a way in Spring to say that a 'bean'
>will
>>be initialized only after  'beanx' has been initialized (I guess is a
>>'depend' attribute ein applicationContext.xml)..
>>
>>But will this work for RequestProcessor commands?
>>
>>Hope I was clear enough to explain my problem...
>>
>>Thanx in advance and regars
>>	marco
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>For additional commands, e-mail: user-help@struts.apache.org
>
>
>--
>Joe Germuska           
>Joe@Germuska.com 
>http://blog.germuska.com   
>"Narrow minds are weapons made for mass destruction"  -The Ex
>
>---------------------------------------------------------------------
>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


-- 
Joe Germuska            
Joe@Germuska.com  
http://blog.germuska.com    
"Narrow minds are weapons made for mass destruction"  -The Ex

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


RE: Struts 1.3, chain & command configuration / few thoughts..

Posted by Marco Mistroni <mm...@waersystems.com>.
Hello joe,
>So really, all you should need to do is write a custom subclass of 
>ComposableRequestProcessor which gets its base CatalogFactory from 
>Spring during the init method.   Then, you'd have to adapt the 
>default chain-config.xml into Spring's bean-factory XML syntax so as 
>to create a CatalogFactory and register the "struts" catalog all in 
>Spring.

That's true... but spring & appContext are initialized only after
The spring plugIn has been initialized, and I was wondering, are 
plugIn initialized AFTER ComposableRequestProcessor? 
Because, if it is so, then I am out of business :-)


Regards
	marco









Joe



At 10:48 AM +0100 5/4/05, Marco Mistroni wrote:
>Hello all,
>	I am currently using Struts 1.3dev in my application, and I have
>recently bothered the list to find a way to configure commands via
>Spring.
>Now, just yesterday, I came across an article
>(http://www.onjava.com/pub/a/onjava/2005/03/02/commonchains2.html)
>on how The new RequestProcessor is used in Struts 1.3...
>Struts 1.3 uses a chain-config.xml and custom chan configs that allows
>user
>To 'override' or change the behaviour of request processor.
>
>Following that article I have implemented my custom command for
>pre-processing in RequestProcessor (as showed in article).
>
>Question is: what if I want to use some of my spring beans in one of
>those
>'request processor' commands?
>
>Currently, in my app, I am using commands for doing various logic, and
>those
>Commands are configured via Spring by using a Spring plugin..
>
>But I am not sure I can do same with RequestProcessor commands, since
>the chain-config.xml file is read at initialization time, when I
suppose
>the Spring plugin has not been initialized yet... so the bean won't be
>available..
>
>If I remember correct, there's a way in Spring to say that a 'bean'
will
>be initialized only after  'beanx' has been initialized (I guess is a
>'depend' attribute ein applicationContext.xml)..
>
>But will this work for RequestProcessor commands?
>
>Hope I was clear enough to explain my problem...
>
>Thanx in advance and regars
>	marco
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>For additional commands, e-mail: user-help@struts.apache.org


-- 
Joe Germuska            
Joe@Germuska.com  
http://blog.germuska.com    
"Narrow minds are weapons made for mass destruction"  -The Ex

---------------------------------------------------------------------
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: Struts 1.3, chain & command configuration / few thoughts..

Posted by Joe Germuska <Jo...@Germuska.com>.
Hi, Marco:

Since you first brought up using Spring to configure the chain, that 
has been on the back of my mind.  Probably like you, as I use Spring 
more in an application I find it frustrating to bump up against 
places where I can't seem to connect to the ApplicationContext or 
otherwise use Spring's DI services.

I haven't needed what you describe yet, but I've been thinking about 
it.  I've made a few changes both to commons-chain and Struts and I 
think the path is now clear, although you'll still have to write some 
code.

Last week I committed changes to commons-chain LookupCommand and the 
base Struts RequestProcessor which expose the CatalogFactory as a 
settable property.  This gets around the fundamental problem of 
having them always go to the static CatalogFactory instance managed 
by the CatalogFactory class.  Now you can have both of them use a CF 
created by Spring.

So really, all you should need to do is write a custom subclass of 
ComposableRequestProcessor which gets its base CatalogFactory from 
Spring during the init method.   Then, you'd have to adapt the 
default chain-config.xml into Spring's bean-factory XML syntax so as 
to create a CatalogFactory and register the "struts" catalog all in 
Spring.

Until/unless Struts actually has a dependency upon Spring, I'm not 
sure that we can do much more in the core library itself.  But I 
think you can get there if you want to.

Joe



At 10:48 AM +0100 5/4/05, Marco Mistroni wrote:
>Hello all,
>	I am currently using Struts 1.3dev in my application, and I have
>recently bothered the list to find a way to configure commands via
>Spring.
>Now, just yesterday, I came across an article
>(http://www.onjava.com/pub/a/onjava/2005/03/02/commonchains2.html)
>on how The new RequestProcessor is used in Struts 1.3...
>Struts 1.3 uses a chain-config.xml and custom chan configs that allows
>user
>To 'override' or change the behaviour of request processor.
>
>Following that article I have implemented my custom command for
>pre-processing in RequestProcessor (as showed in article).
>
>Question is: what if I want to use some of my spring beans in one of
>those
>'request processor' commands?
>
>Currently, in my app, I am using commands for doing various logic, and
>those
>Commands are configured via Spring by using a Spring plugin..
>
>But I am not sure I can do same with RequestProcessor commands, since
>the chain-config.xml file is read at initialization time, when I suppose
>the Spring plugin has not been initialized yet... so the bean won't be
>available..
>
>If I remember correct, there's a way in Spring to say that a 'bean' will
>be initialized only after  'beanx' has been initialized (I guess is a
>'depend' attribute ein applicationContext.xml)..
>
>But will this work for RequestProcessor commands?
>
>Hope I was clear enough to explain my problem...
>
>Thanx in advance and regars
>	marco
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>For additional commands, e-mail: user-help@struts.apache.org


-- 
Joe Germuska            
Joe@Germuska.com  
http://blog.germuska.com    
"Narrow minds are weapons made for mass destruction"  -The Ex

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