Hello Joe,
        Thanx a lot for the reply..
Actually in searching I found out following link
http://weblogs.java.net/blog/dcengija/archive/2005/03/commonschain_a.htm
l

which might be a starting point..

I can use then DelegatingACtionProxy as normal, by setting a property
'command' on my Action so that Spring could inject the proper
command/chain of commands to my Action....

I'll try it out and give feedback :-)

Thanx and regards
        marco


-----Original Message-----
From: Joe Germuska [mailto:[EMAIL PROTECTED] 
Sent: 05 April 2005 04:53
To: Marco Mistroni; 'Struts Users Mailing List'
Subject: Re: Struts/Spring integration & Struts 1.3

Marco:

This is clumsy, but you could probably figure out a way to 
instantiate commands and chains as Spring managed beans and then, 
rather than looking them up in a catalog, you could look them up in 
the ApplicationContext.  If you did this, then it would be easy to 
set up your commands with references to other kinds of objects in the 
ApplicationContext, which I presume is one of the major goals.

You could then extend the ExecuteCommand command, which is 
responsible for executing commands when the ActionConfig 
(ActionMapping) is appropriately configured.  You could override the 
"getCommand" method to have it look up the catalog and command using 
Spring instead of using the static CatalogFactory.getCatalog() method.

The only hitch here is getting a basic reference to the Spring 
ApplicationContext.  That this is even a hitch reveals a flaw in the 
commons-chain API (not that I'd really noticed before), but you could 
probably get away with extracting the context from the ServletContext 
with something like this:

WebApplicationContext wac = 
WebApplicationContextUtils.getWebApplicationContext(actionCtx.getContext
());

Something I hadn't really thought of before, but which seems clear as 
I try to think of answers for you, is that in all the many places in 
both Struts and commons-chain where lookups begin with a call to 
CatalogFactory.getInstance(), that code should be reworked to consult 
an instance property of type "CatalogFactory".  This property could 
be initialized using CatalogFactory.getInstance(), but could then be 
overridden.  This would set you up to use Spring as your sole method 
for instantiating Catalogs and Chains and you could have a 
SpringCatalogFactory which was ApplicationContextAware and which just 
looked up catalogs and commands in the ApplicationContext.

I just did a bit of the necessary refactoring to the commons-chain 
LookupAction, but it will be a few days or so before I can get to 
finding these things in both libraries, as well as giving it decent 
testing.

In the meantime, I think the first suggestion would work out...

Joe



At 10:17 AM +0100 4/4/05, Marco Mistroni wrote:
>Hello all,
>
>       I was wondering.. is using DelegatingActionProxy plus
>The Spring plugin for Struts the only way to integrate Spring beans
>Into struts?
>I am currently trying out Struts 1.3, and I would like to set my
>Spring beans in the command rather than in the action class.., or at
>least
>Make the catalog of commans available via spring
>The commands are loaded from a Catalog, which is loaded by a Listener..
>I have two question then:
>1 - is setting beans on the command the proper way to go, or is there a
>better approach?
>2 - if instead I follow old approach of using DelegatingActionProxy and
>setting Catalog on the Action, how can I make catalog available, if
>Catalog is loaded via a Listener?
>
>Thanx in advance and regards
>       marco
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]


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

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to