Search |
||
Commons-chain: a few tips.Posted by dcengija on March 8, 2005 at 7:08 AM PST
ONJava.com published an article titled "A Look at Commons Chain: The New Java Framework" by Bill Siggelkow. Being a commons-chain user myself for some time now, I thought people might find useful a tip or two. Return valueI find very confusing the return policy of the chained commands. If you want your chain to continue, then return false, if you want it to stop, then return true. Solution: create a
public static final boolean CHAIN_STOP = true;
public static final boolean CHAIN_CONTINUE = false;
Now, instead of returning Spring configurationIf you don't use Spring, well, you should start using it :-) I'm very happy with it and somehow I thought Spring should be able to configure the chains as well. And of course, it is. This piece of Spring's context config file should help you get started:
<bean name="myExecutionChain" class="org.apache.commons.chain.impl.ChainBase">
<constructor-arg>
<list>
<ref bean="firstCmd"/>
<ref bean="secondCmd"/>
</list>
</constructor-arg>
</bean>
<bean name="firstCmd" class="...SomeCommand">
<property name="...">
</property>
</bean>
<!-- and other commands -->
<bean id="chainRunner" class="...ChainRunner">
<property name="executionChain">
<ref bean="myExecutionChain"/>
</property>
</bean>
And that's it for now. More tips will come as I progress in my usage of commons-chain. »
Related Topics >>
Programming Comments
Comments are listed in date ascending order (oldest first)
|
||
|
|