You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Vinicius Caldeira Carvalho <vi...@squadra.com.br> on 2005/04/08 16:10:43 UTC

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:

<context-param>
  <param-name>org.apache.commons.chain.CONFIG_WEB_RESOURCE</param-name>
  <param-value>/WEB-INF/catalog.xml</param-value>
</context-param>

<context-param>
    <param-name>org.apache.commons.chain.CONFIG_ATTR</param-name>
    <param-value>catalog</param-value>
</context-param>

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 invocationtargetexception.

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: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Re: chains problems persists

Posted by Martin Cooper <mf...@gmail.com>.
On Apr 8, 2005 7:10 AM, Vinicius Caldeira Carvalho
<vi...@squadra.com.br> wrote:
> 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:
> 
> <context-param>
>   <param-name>org.apache.commons.chain.CONFIG_WEB_RESOURCE</param-name>
>   <param-value>/WEB-INF/catalog.xml</param-value>
> </context-param>
> 
> <context-param>
>     <param-name>org.apache.commons.chain.CONFIG_ATTR</param-name>
>     <param-value>catalog</param-value>
> </context-param>
> 
> 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 invocationtargetexception.
> 
> 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...

I am using Commons Chain, yes, and all I have in my web.xml is this:

  <!-- Chain listener configuration  -->
  <context-param>
    <param-name>org.apache.commons.chain.CONFIG_WEB_RESOURCE</param-name>
    <param-value>/WEB-INF/chain-config.xml</param-value>
  </context-param>

Then I access the catalog (I'm using the default catalog) like this:

  Catalog catalog = CatalogFactory.getInstance().getCatalog();

As simple as can be, and it all works just fine. :-)

--
Martin Cooper


> Thanks all
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
> 
>

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


RE: chains problems persists

Posted by Marco Mistroni <mm...@waersystems.com>.
Hello,
	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
set the CONFIG_ATTR

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
like
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
chains


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

Hope this helps

Regards
	marco




arco:

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
>



-----Original Message-----
From: Vinicius Caldeira Carvalho
[mailto:vinicius.carvalho@squadra.com.br] 
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:

<context-param>
  <param-name>org.apache.commons.chain.CONFIG_WEB_RESOURCE</param-name>
  <param-value>/WEB-INF/catalog.xml</param-value>
</context-param>

<context-param>
    <param-name>org.apache.commons.chain.CONFIG_ATTR</param-name>
    <param-value>catalog</param-value>
</context-param>

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
invocationtargetexception.

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: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


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