|
(In reply to comment #1)
> Sounds interesting. Can you provide a few more details on how this would > work? you'd have a command something like this: public class MyCommand extends DispatchCommand { public boolean create(Context ctx) { // do some creating return false; } public boolean update(Context ctx) { // do some updating return false; } public boolean delete(Context ctx) { // do some deleting return false; } } You wouldn't implement "execute(Context)" because the base class has an And then in your config, you could have > Also, you mentioned it would be an "abstract base" command. I'm not Good, because I put it in "generic" so far :^) "Abstract" just because it would Created an attachment (id=13888)
Incomplete draft of a Dispatch Action - totally untested Just to have something to look at... Created an attachment (id=13890)
Slightly revised, tested, and more documented DispatchAction Created an attachment (id=13891)
test case for DispatchCommand +1 for this idea (now that I understand it).
Basically the idea is to allow for the use of a single command with some You'll also need to modify the digester configuration stuff. Maybe you could We're doing something like this in our app. We've got several commands that Its not exactly the same as what you're doing I know, but I just wanted to put (In reply to comment #6)
> You'll also need to modify the digester configuration stuff. Maybe you could > extend or modify ConfigRuleSet? I'm not sure what changes need to be made; this should work as any command. How else would the setMethod be called (ignoring the context case)? Btw, I'm
kind of opposed to the context version. I think its better to make the user explicitly identify the methods upfront in the XML. I'm of the opinion that less in the Context is better but thats JMO. One other suggestion. Maybe change the method to setDispatchMethod or I will try and take a look at the configuration later tonight. Because the digester rules for <command> include "SetProperties", any XML
attribute in the <command> element whose name is a bean-property-name of the instantiated command will be used to set that property value with the attribute's value. So: <command name="foo" className="MyDispatchSubclass" method="doFoo" /> I don't feel strongly about the naming of the properties. I included the methodKey version mostly to keep consistency with other patterns OK sounds good. I wasn't aware that SetProperties was being used on the
command element (its hard for me to check source code at work.) You make a good argument for the context thing (even though it sounds like you agree with me that its not the best practice.) A couple of additional (minor) comments for you. I'm not sure if the evaluate
method is really necessary as a protected method. Whatever dispatch method is called should evaluate to true/false. I don't know that it makes sense to allow subclasses to get too crazy with the return parameter on this. I would also recommend making the method, methodKey and methods properties all Are we ready to commit this? I have some cool stuff in the works once we do.
I'll do it myself, as soon as I re-checkout the repository in read/write mode
and look harder at your last couple of suggestions... With all due respect, Sean, I decided to leave things as they were. Having
"extractMethod" protected is not very useful if the methods cache isn't available (well, it would be annoying to have to replicate it). And while the evaluateResult(...) may be surplus, I don't see that it hurts anything. No worries. I'm looking forward to playing with it.
Henri Yandell made changes - 16/May/06 09:50 AM
Henri Yandell made changes - 16/May/06 11:10 AM
Henri Yandell made changes - 16/May/06 12:17 PM
I agree with Sean's comment about making method, methodKey and methods properties all private (instead of protected).
There are two issues with it - firstly its exposing the Map implementation which from the FastHashMap experience in other components could be a PITA later and secondly it sets the visibility for all descendants which can't then be changed. Far better IMO to provide methods to access the cache rather than expose it this way. I just posted about this on the dev list (chain 1.1 release?) since the checkstyle report highlighted it - should have looked here first i'm fine with making all the actual properties protected. Are you going to do this? Do you want me to?
assume you meant private - I can do this when I get back from holiday (after Monday) but feel free to jump in if you want.
Henri Yandell made changes - 17/Feb/07 09:19 AM
Henri Yandell made changes - 02/Jan/08 07:01 AM
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
work? Also, you mentioned it would be an "abstract base" command. I'm not
sure whether you meant that it would go in the "impl" package or not, but I'd
recommend it would go in the "generic" package instead.