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/01 19:12:10 UTC

chains: refering to another chain in my chain

Hello there folks...
Isnt it possible to refer to a chain as a command from another chain?
let me explain:

<chain name="doSomething">
    <command name="foo" className="foo"/>
    <command name="bar" className="bar"/>
</chain>

<chain name="doSomethingElse">
    <command name="doSomething"/> //inheirts everthing this chain provides
    <command name="boo" className="boo"/>
<chain>


I think this would be a great adition to the api





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


Re: chains: refering to another chain in my chain

Posted by Vinicius Caldeira Carvalho <vi...@squadra.com.br>.
Well I tried it here and it throw an infame nullPointerException.... I 
did just like the example (only with real classnames :D )

>A chain is a command, so the answer has to be yes.
>
>Jack
>
>On Apr 1, 2005 9:12 AM, Vinicius Caldeira Carvalho
><vi...@squadra.com.br> wrote:
>  
>
>>Hello there folks...
>>Isnt it possible to refer to a chain as a command from another chain?
>>let me explain:
>>
>><chain name="doSomething">
>>    <command name="foo" className="foo"/>
>>    <command name="bar" className="bar"/>
>></chain>
>>
>><chain name="doSomethingElse">
>>    <command name="doSomething"/> //inheirts everthing this chain provides
>>    <command name="boo" className="boo"/>
>><chain>
>>
>>I think this would be a great adition to the api
>>
>>---------------------------------------------------------------------
>>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: refering to another chain in my chain

Posted by Dakota Jack <da...@gmail.com>.
A chain is a command, so the answer has to be yes.

Jack

On Apr 1, 2005 9:12 AM, Vinicius Caldeira Carvalho
<vi...@squadra.com.br> wrote:
> Hello there folks...
> Isnt it possible to refer to a chain as a command from another chain?
> let me explain:
> 
> <chain name="doSomething">
>     <command name="foo" className="foo"/>
>     <command name="bar" className="bar"/>
> </chain>
> 
> <chain name="doSomethingElse">
>     <command name="doSomething"/> //inheirts everthing this chain provides
>     <command name="boo" className="boo"/>
> <chain>
> 
> I think this would be a great adition to the api
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
> 
> 


-- 
"You can lead a horse to water but you cannot make it float on its back."
~Dakota Jack~

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


Re: Configuring Catalogs via Spring

Posted by Craig McClanahan <cr...@gmail.com>.
On Apr 5, 2005 1:03 AM, Marco Mistroni <mm...@waersystems.com> wrote:
> Hello all,
>         Does anybody know how to configure a commons chain catalog via
> Spring using XML file?
> I had a look at code, and the only component that configures catalog via
> XML is the ChainListener.
> And, if I use CatalogFactory, I have to add commands programmatically
> 
> How can integrate then Spring and Chains, if I don't want to use
> Listener?
> 

The code in ChainListener that actually does the XML configuration is
pretty straightforward, and can be used to configure the chains
however you'd like:

    ConfigParser parser = new ConfigParser();
    URL url = ... URL to your configuration document ...
    parser.parse(url);

> Thanx and regards
>         marco

Craig

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


Re: chains: refering to another chain in my chain

Posted by Vinicius Caldeira Carvalho <vi...@squadra.com.br>.
Craig McClanahan wrote:

>On Apr 4, 2005 6:06 AM, Vinicius Caldeira Carvalho
><vi...@squadra.com.br> wrote:
>  
>
>>Vinicius Caldeira Carvalho wrote:
>>
>>    
>>
>>>PS: I'm using org.apache.commons.chain.CONFIG_WEB_RESOURCE I thought
>>>this may add some extra info :-)
>>>
>>>---------------------------------------------------------------------
>>>To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
>>>For additional commands, e-mail: commons-user-help@jakarta.apache.org
>>>
>>>
>>>
>>>      
>>>
>>Well, I found out that the property for the catalog is
>>catalogName="something" and not catalog="something", Thanks lord for
>>OpenSource :D
>>
>><command className="org.apache.commons.chain.generic.LookupCommand"
>>name="validarRegraCompraPlanoCobertura" catalogName="catalog"/>
>>
>>Now I get:
>>java.lang.IllegalArgumentException: Cannot find catalog 'catalog'
>>
>>here's my web.xml
>>
>><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>
>>
>>    
>>
>
>Specifying the catalog name as a context param implies that you are
>using the old style (now deprecated) mechanism for configuring
>[chain], which (most importantly) does *not* register the catalog with
>CatalogFactory.  Instead, you'll want to leave out the second
><context-param> entry, and make sure your chain definitions document
>includes information about the catalogs to be used:
>
><catalogs>
>    <catalog name="catalog">
>        <chain .../>
>        <chain .../>
>    </catalog>
>    <catalog name="otherCatalog">
>        <chain .../>
>        <chain .../>
>    </catalog>
></catalogs>
>
>Craig
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: commons-user-help@jakarta.apache.org
>
>
>
>  
>
Well I guess I'm doing something terrible wrong here. But it's not 
working using <catalogs></catalogs>

here's my catalog.xml:



<catalogs>
    <catalog name="catalog">
        <chain name="validarRegraCompraPlanoCobertura">
            <command 
className="myCompanySystem.view.administrarregracompra.action.commands.InitSalvarRegraCompraCommand"/>
            <command 
className="myCompanySystem.view.administrarregracompra.action.commands.RemoverItensCommand"/>    
   
            <command 
className="myCompanySystem.view.administrarregracompra.action.commands.VerificarItensDuplicadosCommand"/>
            <command 
className="myCompanySystem.view.administrarregracompra.action.commands.VerificarExistenciaItemCommand"/>
            <command 
className="myCompanySystem.view.administrarregracompra.action.commands.AssembleRegraCompraCommand"/>
            <command 
className="myCompanySystem.view.administrarregracompra.action.commands.VerificarCategoriaPaiCommand"/>
            <command 
className="myCompanySystem.view.administrarregracompra.action.commands.VerificarHierarquiaItemsCommand"/>
            <command 
className="myCompanySystem.view.administrarregracompra.action.commands.UpdateRegraCompraCommand"/>
        </chain>
        <chain name="ordernarRegraCompraPlanoCobertura">
            <command 
className="myCompanySystem.view.administrarregracompra.action.commands.InitSalvarRegraCompraCommand"/>
            <command 
className="myCompanySystem.view.administrarregracompra.action.commands.RemoverItensCommand"/>    
   
            <command 
className="myCompanySystem.view.administrarregracompra.action.commands.VerificarItensDuplicadosCommand"/>
            <command 
className="myCompanySystem.view.administrarregracompra.action.commands.VerificarExistenciaItemCommand"/>
            <command 
className="myCompanySystem.view.administrarregracompra.action.commands.AssembleRegraCompraCommand"/>
            <command 
className="myCompanySystem.view.administrarregracompra.action.commands.VerificarCategoriaPaiCommand"/>
            <command 
className="myCompanySystem.view.administrarregracompra.action.commands.VerificarHierarquiaItemsCommand"/>
            <command 
className="myCompanySystem.view.administrarregracompra.action.commands.UpdateRegraCompraCommand"/>
            <command 
className="myCompanySystem.view.administrarregracompra.action.commands.OrganizarRegraCompraCommand"/>
        </chain>
    </catalog>
</catalogs>

Here's my web.xml:
  <context-param>
  <param-name>org.apache.commons.chain.CONFIG_WEB_RESOURCE</param-name>
  <param-value>/WEB-INF/catalog.xml</param-value>
</context-param>

<listener>
  
<listener-class>org.apache.commons.chain.web.ChainListener</listener-class>
</listener>

Now It doesn't run the commands:
10:00:14,110 INFO  [STDOUT] java.lang.NullPointerException
10:00:14,110 INFO  [STDOUT]     at 
com.araujo.convenios.view.action.CommandAction.getCommand(CommandAction.java:32)
10:00:14,110 INFO  [STDOUT]     at 
com.araujo.convenios.view.administrarregracompra.action.OrganizarRegraCompraAction.doExecute(OrganizarRegraCompraAction.java:39)

Could someone please help?

Thanx

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


Re: Configuring Catalogs via Spring

Posted by Duong BaTien <du...@gmail.com>.
Marco Mistroni wrote:

>Hello all,
>	Does anybody know how to configure a commons chain catalog via 
>Spring using XML file?
>I had a look at code, and the only component that configures catalog via
>XML is the ChainListener.
>And, if I use CatalogFactory, I have to add commands programmatically
>
>How can integrate then Spring and Chains, if I don't want to use
>Listener?
>
>Thanx and regards
>	marco
>
>
>  
>
I extend Catalog and Chain implementations to wrap the commands with 
generic Map and List so they become standard POJO, configurable by 
Spring IoC.

BaTien
DBGROUPS

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


Configuring Catalogs via Spring

Posted by Marco Mistroni <mm...@waersystems.com>.
Hello all,
	Does anybody know how to configure a commons chain catalog via 
Spring using XML file?
I had a look at code, and the only component that configures catalog via
XML is the ChainListener.
And, if I use CatalogFactory, I have to add commands programmatically

How can integrate then Spring and Chains, if I don't want to use
Listener?

Thanx and regards
	marco




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


Re: chains: refering to another chain in my chain

Posted by Craig McClanahan <cr...@gmail.com>.
On Apr 4, 2005 6:06 AM, Vinicius Caldeira Carvalho
<vi...@squadra.com.br> wrote:
> Vinicius Caldeira Carvalho wrote:
> 
> > PS: I'm using org.apache.commons.chain.CONFIG_WEB_RESOURCE I thought
> > this may add some extra info :-)
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: commons-user-help@jakarta.apache.org
> >
> >
> >
> Well, I found out that the property for the catalog is
> catalogName="something" and not catalog="something", Thanks lord for
> OpenSource :D
> 
> <command className="org.apache.commons.chain.generic.LookupCommand"
> name="validarRegraCompraPlanoCobertura" catalogName="catalog"/>
> 
> Now I get:
> java.lang.IllegalArgumentException: Cannot find catalog 'catalog'
> 
> here's my web.xml
> 
> <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>
> 

Specifying the catalog name as a context param implies that you are
using the old style (now deprecated) mechanism for configuring
[chain], which (most importantly) does *not* register the catalog with
CatalogFactory.  Instead, you'll want to leave out the second
<context-param> entry, and make sure your chain definitions document
includes information about the catalogs to be used:

<catalogs>
    <catalog name="catalog">
        <chain .../>
        <chain .../>
    </catalog>
    <catalog name="otherCatalog">
        <chain .../>
        <chain .../>
    </catalog>
</catalogs>

Craig

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


Re: chains: refering to another chain in my chain

Posted by Vinicius Caldeira Carvalho <vi...@squadra.com.br>.
Vinicius Caldeira Carvalho wrote:

> PS: I'm using org.apache.commons.chain.CONFIG_WEB_RESOURCE I thought 
> this may add some extra info :-)
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>
>
>
Well, I found out that the property for the catalog is 
catalogName="something" and not catalog="something", Thanks lord for 
OpenSource :D

<command className="org.apache.commons.chain.generic.LookupCommand" 
name="validarRegraCompraPlanoCobertura" catalogName="catalog"/>

Now I get:
java.lang.IllegalArgumentException: Cannot find catalog 'catalog'

here's my web.xml

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

Thanks

PS: Craig dispite my stupid rage attack, I think your impl of the COR is 
AWESOME dude. Please keep the good work ;)

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


Re: chains: refering to another chain in my chain

Posted by Vinicius Caldeira Carvalho <vi...@squadra.com.br>.
PS: I'm using org.apache.commons.chain.CONFIG_WEB_RESOURCE I thought 
this may add some extra info :-)

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


Re: chains: refering to another chain in my chain

Posted by Vinicius Caldeira Carvalho <vi...@squadra.com.br>.
Nice...

I tried this:
<command className="org.apache.commons.chain.generic.LookupCommand" 
name="validarRegraCompraPlanoCobertura" catalog="catalog"/>

but I get this when running the command:
                                         
java.lang.IllegalArgumentException: Cannot find default catalog
My catalog is registred as "catalog". I didn't get how could it not find 
it...

Thanks


Craig McClanahan wrote:

>On Apr 1, 2005 9:12 AM, Vinicius Caldeira Carvalho
><vi...@squadra.com.br> wrote:
>  
>
>>Hello there folks...
>>Isnt it possible to refer to a chain as a command from another chain?
>>let me explain:
>>
>><chain name="doSomething">
>>    <command name="foo" className="foo"/>
>>    <command name="bar" className="bar"/>
>></chain>
>>
>><chain name="doSomethingElse">
>>    <command name="doSomething"/> //inheirts everthing this chain provides
>>    <command name="boo" className="boo"/>
>><chain>
>>
>>I think this would be a great adition to the api
>>
>>    
>>
>
>It doesn't need to be in the API ... there needs to be a command that
>looks up and executes other chains.  Oh wait, there already is :-)
>
>    <command className="org.apache.commons.chain.generic.LookupCommand"
>        name="doSomething" [ catalog="catalogName" ] [ optional="true" ] />
>
>This uses the catalog and name identifiers to look up some other
>defined command and executes it.  The optional parameter lets you say
>"if the command doesn't exist, just silently continue instead of
>throwing an error."  This is perfect for letting people optionally
>customize a chain without having to reconfigure it.
>
>Craig
>
>---------------------------------------------------------------------
>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: refering to another chain in my chain

Posted by Craig McClanahan <cr...@gmail.com>.
On Apr 1, 2005 9:12 AM, Vinicius Caldeira Carvalho
<vi...@squadra.com.br> wrote:
> Hello there folks...
> Isnt it possible to refer to a chain as a command from another chain?
> let me explain:
> 
> <chain name="doSomething">
>     <command name="foo" className="foo"/>
>     <command name="bar" className="bar"/>
> </chain>
> 
> <chain name="doSomethingElse">
>     <command name="doSomething"/> //inheirts everthing this chain provides
>     <command name="boo" className="boo"/>
> <chain>
> 
> I think this would be a great adition to the api
> 

It doesn't need to be in the API ... there needs to be a command that
looks up and executes other chains.  Oh wait, there already is :-)

    <command className="org.apache.commons.chain.generic.LookupCommand"
        name="doSomething" [ catalog="catalogName" ] [ optional="true" ] />

This uses the catalog and name identifiers to look up some other
defined command and executes it.  The optional parameter lets you say
"if the command doesn't exist, just silently continue instead of
throwing an error."  This is perfect for letting people optionally
customize a chain without having to reconfigure it.

Craig

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