Re: [digester] populating beans fixed to BeanUtils?
One of the beauties of digster + beanutils is, that you can use this: pattern value=signal set-properties-rule alias attr-name=attrA prop-name=attrA / alias attr-name=attrB prop-name=foo.attrB / /set-properties-rule /pattern and get the second property setter deferenced to getFoo().setAttrB() which I wouldn't want to miss for anything in the world. So please keep Beanutils. :-) henning, probably just miscommunication, it was not my intention to rip out the heart of digester ;) only that it should be possible to achive the behaviour you described by other means than BeanUtils (which could be used by default) ricardo Want to chat instantly with your online friends? Get the FREE Yahoo! Messenger http://mail.messenger.yahoo.co.uk - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [digester] populating beans fixed to BeanUtils?
robert, i like beanutils very much. but the assumption being made is, that the target object either implements set/get according to spec or is an instance of DynaBean. imo it would be appreciated by many users (at least in the longterm) if an interface and/or factory is provided which, call it a use case, allows for custom DynaBean-like behaviour. regards, ricardo ps. do you mean sending example implementation? --- robert burrell donkin [EMAIL PROTECTED] wrote: hi ricky beanutils adds quite a few powerful features which (seems to me to) justify these dependencies. there are some good reasons why it might be useful to abstract the actual population from the mechanism used to perform the population. i'm not sure whether the best way to do this would be through delegation to a strategy interface or through inheritance. i'd be interested to here other people's views on this. i don't seem to get as much coding time as i'd like these days so i probably won't get round to coding this any time soon but patches (including test cases ;) would be gratefully received. Want to chat instantly with your online friends? Get the FREE Yahoo! Messenger http://mail.messenger.yahoo.co.uk - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [digester] populating beans fixed to BeanUtils?
simon, BeanUtils does the actual setting of properties. there are many other JavaSpec conforming utilities. (i use castor for introspection and generating relevant information) you are right, i can always use new rules... i still feel the dependency on BeanUtils in the populate() and setProperty() cases is too much - while ok in CallMethodRule etc ricardo --- Simon Kitching [EMAIL PROTECTED] wrote: On Wed, 2003-10-22 at 11:27, Ricky Panaglucci wrote: hello, is it by design, that SetPropertyRule and SetPropertiesRule use BeanUtils.populate()? it would be usefull to use other binders as well. Well, the term property in the name of these rules is intended to refer to the definition of a JavaBean property as per the official JavaBean specification. The BeanUtils library implements that specification, so there doesn't seem to be much need for allowing the user to configure alternate implementations. If you do wish to map xml attributes to class methods in a way other than the JavaBean spec defines, you can always create your own rule, like SetRicardoPropertyRule(...) which uses some other algorithm for determining which method to invoke on an object given an xml attribute or element name. What other binder do you have in mind? Regards, Simon - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] Want to chat instantly with your online friends? Get the FREE Yahoo! Messenger http://mail.messenger.yahoo.co.uk - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [digester] why private XXXRule in DigesterRuleParser?
hello, below is a case, where the existing PatternRule would be usefull ricardo myrules.xml: digester-rules pattern value=*/MyObject object-create-rule classname=MyObject/ set-generic-property-rule pattern=attr name=name value=value/ /pattern /digester-rules myobject.xml: ?xml version=1.0? jLab MyObject attr name=att1 value=val1/ attr name=att2 value=val2/ /MyObject /jLab Digester d=new Digester() DigesterRuleParser drp=new DigesterRuleParser(d); d.addFactoryCreate(*/set-generic-property-rule, new SetGenericPropertyRuleFactory()); //*** would like to write d.addRule(*/set-generic-property-rule, drp.new PatternRule(pattern)); d.addRule(*/set-generic-property-rule, new XPatternRule(pattern)); d.addSetNext(*/set-generic-property-rule, add, Rule.class.getName()); RuleSet ruleSet = new FromXmlRuleSet(new Files(myrules).toURL(), drp, d); d.addRuleSet(ruleSet); MyObject obj = (MyObject)d.parse(new File(myobject.xml); public class SetGenericPropertyRuleFactory extends AbstractObjectCreationFactory { public SetGenericPropertyRuleFactory() { } public Object createObject(Attributes attributes) { String name = attributes.getValue(name); String value = attributes.getValue(value); return new GenericPropertyRule( name, value); } } public class GenericPropertiesRule extends Rule { //***source copied from SetPropertyRule with some } public class XPatternRule { //***source copied from PatternRule } --- robert burrell donkin [EMAIL PROTECTED] wrote: +1 i'd be happy to see the nested classed in the xmlrules made public if a need could be demonstrated. - robert On Monday, October 20, 2003, at 10:12 PM, Simon Kitching wrote: Hi Ricky, You must be referring to xmlrules/DigesterRuleParser.java I'm no expert on the xmlrules package. However it is normal practice for classes created solely for the purpose of implementing function X to be declared private. The PatternRule class appears to have been created *not* with the intention of providing additional services to users of Digester, but solely as an implementation detail of the xmlrules functionality. As such, private seems the appropriate scope to me. If you feel that the functionality of the PatternRule is useful outside of the xmlrules package, then consideration could be given to promoting the class to public. Note however that any class or method declared public (or protected) is part of the public interface to a package, and must: (a) be documented much more thoroughly than private/package classes (b) be backwards-compatible in future releases (c) be deprecated before removal So a class really should only be public if it needs to be. Regards, Simon On Tue, 2003-10-21 at 10:02, Ricky Panaglucci wrote: hello, why do classes like PatternRule have private access? now, for adding my own rules which may use surrounding pattern, i just copied the PatternRule source [very brown imho] why not make them protected or public? ricardo Want to chat instantly with your online friends? Get the FREE Yahoo! Messenger http://mail.messenger.yahoo.co.uk - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] Want to chat instantly with your online friends? Get the FREE Yahoo! Messenger http://mail.messenger.yahoo.co.uk - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
[digester] populating beans fixed to BeanUtils?
hello, is it by design, that SetPropertyRule and SetPropertiesRule use BeanUtils.populate()? it would be usefull to use other binders as well. ricardo Want to chat instantly with your online friends? Get the FREE Yahoo! Messenger http://mail.messenger.yahoo.co.uk - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
[digester] why private XXXRule in DigesterRuleParser?
hello, why do classes like PatternRule have private access? now, for adding my own rules which may use surrounding pattern, i just copied the PatternRule source [very brown imho] why not make them protected or public? ricardo Want to chat instantly with your online friends? Get the FREE Yahoo! Messenger http://mail.messenger.yahoo.co.uk - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: [digester] why private XXXRule in DigesterRuleParser?
simon, nevermind, i don't remember what i did, but pattern value=child object-create-rule classname=xxx/ set-generic-properties-rule/ set-next-rule methodname=addChild/ /pattern now works with [d instanceof Digester] d.addFactoryCreate(*/set-generic-properties-rule, new SetGenericPropertiesRuleFactory()); // d.addRule(*/set-generic-properties-rule, new XPatternRule(pattern)); --- thought i need this d.addSetNext(*/set-generic-properties-rule, add, Rule.class.getName()); (XXGenericXX some Castor related stuff) i've been using Digester for 3 days now and haven't digged the push/pop stuff completely yet... your arguments regarding private use have been absorbed though thanks ricardo --- Simon Kitching [EMAIL PROTECTED] wrote: Hi Ricky, You must be referring to xmlrules/DigesterRuleParser.java I'm no expert on the xmlrules package. However it is normal practice for classes created solely for the purpose of implementing function X to be declared private. The PatternRule class appears to have been created *not* with the intention of providing additional services to users of Digester, but solely as an implementation detail of the xmlrules functionality. As such, private seems the appropriate scope to me. If you feel that the functionality of the PatternRule is useful outside of the xmlrules package, then consideration could be given to promoting the class to public. Note however that any class or method declared public (or protected) is part of the public interface to a package, and must: (a) be documented much more thoroughly than private/package classes (b) be backwards-compatible in future releases (c) be deprecated before removal So a class really should only be public if it needs to be. Regards, Simon On Tue, 2003-10-21 at 10:02, Ricky Panaglucci wrote: hello, why do classes like PatternRule have private access? now, for adding my own rules which may use surrounding pattern, i just copied the PatternRule source [very brown imho] why not make them protected or public? ricardo Want to chat instantly with your online friends? Get the FREE Yahoo! Messenger http://mail.messenger.yahoo.co.uk - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] Want to chat instantly with your online friends? Get the FREE Yahoo! Messenger http://mail.messenger.yahoo.co.uk - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]