You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Manfred Wolff <wo...@manfred-wolff.de> on 2004/06/17 20:23:40 UTC
[commons-chain] Configuration of the ChainBase class
Moin.
Short description: We use commons-chain in a productive project for
configuring strategies and filters. The user itsself should be able to
customize the chains and brings the right order in chains (commands,
filters ...). Some commands has dependencies to other commands so it
might be the situation, that a command b can only be executed if a
command a is still executed in the same chain. At runtime it is no
problem to check such dependencies (b can look into the context if a has
done his work). But because of the posibility of configuration the
chains by customer it might be a good idea to do a check at the start of
the app so configuration errors might not come into being at runtime.
For that I have subclassed the Command, the ChainBase etc. Unfortunaly
in the class that have to be instanciated
(org.apache.commons.chain.impl.ChainBase) is hard coded in the
ConfigRuleSet class. So I have subclassed the RuleSet, the ConfigParser
... I think it make no sense to subclass all classes of a framework so I
like to contribute a solution for generic instanciation support. For me
it is enough to make the instanciaten class configurable (see my diff
patchConfigRuleSet.txt). So I can subclass the ConfgParser and set the
className attribute if needed. I have still some other solutions
expanding the configuration file. All is possible by subclassing.
A new feature were good: It might be possible to configure chains in
chains like that:
<chain name="single">
<command className="org.strutsit.chain.CommandForTestSomething"/>
<command className="org.strutsit.chain.CommandForTestAnything"/>
</chain>
<chain name="depend">
<chain refid=single"/>
<command className="org.strutsit.chain.CommandForTestFalse"/>
<command className="org.strutsit.chain.CommandForTestTrueDepend"/>
</chain>
In the moment I have no knowledge how to configure a digester to do such
things. If anybody has please contact me. I will implement the rest and
contribute it too.
Thanks a lot.
Manfred.
Re: [commons-chain] Configuration of the ChainBase class
Posted by Craig McClanahan <cr...@apache.org>.
Manfred Wolff wrote:
> Moin.
>
> Short description: We use commons-chain in a productive project for
> configuring strategies and filters. The user itsself should be able to
> customize the chains and brings the right order in chains (commands,
> filters ...). Some commands has dependencies to other commands so it
> might be the situation, that a command b can only be executed if a
> command a is still executed in the same chain. At runtime it is no
> problem to check such dependencies (b can look into the context if a
> has done his work). But because of the posibility of configuration the
> chains by customer it might be a good idea to do a check at the start
> of the app so configuration errors might not come into being at runtime.
>
> For that I have subclassed the Command, the ChainBase etc. Unfortunaly
> in the class that have to be instanciated
> (org.apache.commons.chain.impl.ChainBase) is hard coded in the
> ConfigRuleSet class. So I have subclassed the RuleSet, the
> ConfigParser ... I think it make no sense to subclass all classes of a
> framework so I like to contribute a solution for generic instanciation
> support. For me it is enough to make the instanciaten class
> configurable (see my diff patchConfigRuleSet.txt). So I can subclass
> the ConfgParser and set the className attribute if needed. I have
> still some other solutions expanding the configuration file. All is
> possible by subclassing.
>
> A new feature were good: It might be possible to configure chains in
> chains like that:
>
> <chain name="single">
> <command className="org.strutsit.chain.CommandForTestSomething"/>
> <command className="org.strutsit.chain.CommandForTestAnything"/>
> </chain>
>
> <chain name="depend">
> <chain refid=single"/>
> <command className="org.strutsit.chain.CommandForTestFalse"/>
> <command className="org.strutsit.chain.CommandForTestTrueDepend"/>
> </chain>
>
> In the moment I have no knowledge how to configure a digester to do
> such things. If anybody has please contact me. I will implement the
> rest and contribute it too.
>
I just added the chainClass property as you proposed below, which means
you can now set the default implementation class for all <chain>
elements to be processed. Note that, even before this change, you could
use the "className" attribute on a <chain> element just like you could
on a "command" element -- but I agree that having a default is nice.
> Thanks a lot.
>
> Manfred.
>
>
>
Craig
>------------------------------------------------------------------------
>
>RCS file: /home/cvspublic/jakarta-commons-sandbox/chain/src/java/org/apache/commons/chain/config/ConfigRuleSet.java,v
>retrieving revision 1.5
>diff -r1.5 ConfigRuleSet.java
>67a68
>
>
>> private String className= "org.apache.commons.chain.impl.ChainBase";
>>
>>
>143a145,161
>
>
>>
>> /**
>> * Return the classname that will use to instanciate chains.
>> * @return Returns the classeName.
>> */
>> public String getClassName() {
>> return className;
>> }
>>
>>
>> /**
>> * Sets the classname that will use to instanciate chains.
>> * @param classeName The classeName to set.
>> */
>> public void setClassName(String classeName) {
>> this.className = classeName;
>> }
>>
>>
>161c179
>< "org.apache.commons.chain.impl.ChainBase",
>---
>
>
>> getClassName(),
>>
>>
>
>
>
>------------------------------------------------------------------------
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org