commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Marco Mistroni" <>
Subject RE: chains problems persists
Date Fri, 08 Apr 2005 14:17:41 GMT
	I am 'trying' to use commons-chain.
I did a sample application, and it worked fine for the use (1 command

I found out also that in order to initialize the catalog, you have to

But other than that, it was ok.

Try to put your catalog.xml  in your CLASSES directory. 
I have tried also to put it in WEB-INF, and what I got as result?
NULL(A) (which means nothing in Italian :-) )

I found out also those 'limitation' on the catalog issue, since I would
To initialize it via spring... got following answer from Mr Joe Germuska
(see below)

In meantime, hope what I have said before will keep you going on with

I am trying chains too, so it is more likely that next week I'll be
More often asking for solutions to my (future) problems :0

Hope this helps



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 = 

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 

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


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

-----Original Message-----
From: Vinicius Caldeira Carvalho
Sent: 08 April 2005 15:11
To: Jakarta Commons Users List
Subject: chains problems persists

Well I guess I tried everthing. From debuging the source code to read 
the entire javadoc. I've just downloaded the latest nightly build from 
chains, tried to understand both apps bundle within it. And as far as I 
know I'm not very stupid.

So I tried everthing, and I can say that The only way to put it to work 
is through the old config style:



Otherwise the listener will *not* register my catalog with the context. 
Well unless a magic happens, cuz on the ChainListener code there's no 
code indicating that. Also I'd like to know how to use that 
CatalogFactory, I did not find any way to initialize it. And trying to 
use a ConfigCatalogRule as my rule-set throws an

Craig, dude I'm sorry I really didn't know who you are. Thanks for 
struts  ;)

But guys, are you all using commons chains? How could this simple tasks 
be done? I really don't see how to register my catalog with my 
webcontext in other way besides the old depracated one...

Thanks all

To unsubscribe, e-mail:
For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message