|
From: Colin S. <col...@ex...> - 2004-07-01 11:44:11
|
Ok, my bad... I will however add a comment at each of the specific bean
attributes (dependency-check, autowire, and lazy-init attributes)
mentioning the default handling (inherit from setting in beans).
jürgen höller [werk3AT] wrote:
>Note that the DTD specifies "default" as default value for the attribute:
>
><!ATTLIST bean dependency-check (none | objects | simple | all | default) "default">
>
>So if there's no value specified, the XML parser will return "default", triggering the correct behavior in DefaultXmlBeanDefinitionParser.
>
>The test suite just verified this for the "autowire" attribute, so I've just added a similar test for "dependency-check".
>
>Juergen
>
>
>________________________________
>
>Von: spr...@li... im Auftrag von Colin Sampaleanu
>Gesendet: Do 01.07.2004 04:25
>An: spr...@li...
>Betreff: Re: [Springframework-developer] Anybody know historical purpose of dependency-check 'default' value?
>
>
>
>You're right, I didn't look closely enough at the code calling the
>method I listed, which also looks at the attribute value:
>
> String dependencyCheck =
>ele.getAttribute(DEPENDENCY_CHECK_ATTRIBUTE);
> if (DEFAULT_VALUE.equals(dependencyCheck)) {
> dependencyCheck = this.defaultDependencyCheck;
> }
> bd.setDependencyCheck(getDependencyCheck(dependencyCheck));
>
>However, along the way a discrepancy has been introduced. I could just
>document for the 'bean' element 'dependency-check' attribute level that
>'default' means to take the default value from the root beans element.
>But this is not in fact how the comment for the root 'beans' element is
>saying the 'default-dependency-check' attribute is supposed to be treated:
>
><!--
> Default values for all bean definitions. Can be overridden at
> the "bean" level. See those attribute definitions for details.
>-->
><!ATTLIST beans default-lazy-init (true | false) "false">
><!ATTLIST beans default-dependency-check (none | objects | simple | all) "none">
><!ATTLIST beans default-autowire (no | byName | byType | constructor | autodetect) "no">
>
>As I read this anyways, a bean element should use the default value
>unless overriden. Right now it will use the default value only when
>'default' is set at the bean level. The autowire and lazy init defaults
>are treated the same way.
>
>I am curious why the defualting was done in this fashion. I was around
>at the time (autowire, anyways), but didn't pay too much attention. I
>think it doesn't make that much sense; at least the comment above has to
>be changed a bit, and the 'default' value has to be documented at the
>level of the bean.
>
>I would personally also be ok with making these default true default
>(i.e. without people needing to use the explicit 'default' value,
>although this may not be appropriate given that it is not backwards
>compatible.
>
>Colin
>
>
>Christophe Roudet wrote:
>
>
>
>>It may have a relation with the beans root node default-dependency-check
>>attribute.
>>
>><!ATTLIST beans default-dependency-check (none | objects | simple | all)
>>"none">
>>
>>When dependency-check is set to default on some beans, it should use the
>>value specified on the beans node.
>>
>>Just my thought...
>>
>>Christophe
>>
>>
>>
>>
>>
>>>-----Original Message-----
>>>From: spr...@li...
>>>[mailto:spr...@li...] On Behalf
>>>Of Alef Arendsen
>>>Sent: Wednesday, June 30, 2004 7:35 PM
>>>To: spr...@li...
>>>Subject: RE: [Springframework-developer] Anybody know historical purpose
>>>of dependency-check 'default' value?
>>>
>>>I don't know,
>>>
>>>I've searched a bit through my email archives and have attached a couple
>>>of mail related to the introduction of the dependency checking features.
>>>
>>>I think we (or however implemented this) chose to have a default
>>>attributes to allow for future modification of the default if needed??
>>>
>>>Alef
>>>
>>>
>>>
>>>
>>>
>>>>-----Original Message-----
>>>>From: spr...@li...
>>>>[mailto:spr...@li...] On
>>>>
>>>>
>>>>
>>>>
>>>Behalf
>>>
>>>
>>>
>>>
>>>>Of Colin Sampaleanu
>>>>Sent: Thursday, July 01, 2004 1:01 AM
>>>>To: spr...@li...
>>>>Subject: [Springframework-developer] Anybody know historical purpose
>>>>
>>>>
>>>>
>>>>
>>>of
>>>
>>>
>>>
>>>
>>>>dependency-check 'default' value?
>>>>
>>>>I'm trying to figure out why the DTD allows both 'none' and 'default'
>>>>for the dependency-check attribute.
>>>>
>>>><!--
>>>> Optional attribute controlling whether to check whether all this
>>>> beans dependencies, expressed in its properties, are satisfied.
>>>> Default is no dependency checking.
>>>>
>>>> "simple" type dependency checking includes primitives and String
>>>> "object" includes collaborators (other beans in the factory)
>>>> "all" includes both types of dependency checking
>>>>-->
>>>><!ATTLIST bean dependency-check (none | objects | simple | all |
>>>>default) "default">
>>>>
>>>>If you look at the code, none is the default (when nothing is
>>>>specified). 'default gets treated exactly like none, but it seems
>>>>
>>>>
>>>>
>>>>
>>>almost
>>>
>>>
>>>
>>>
>>>>like an accident.
>>>>
>>>> protected int getDependencyCheck(String att) {
>>>> int dependencyCheckCode =
>>>>RootBeanDefinition.DEPENDENCY_CHECK_NONE;
>>>> if (DEPENDENCY_CHECK_ALL_ATTRIBUTE_VALUE.equals(att)) {
>>>> dependencyCheckCode =
>>>>
>>>>
>>>>
>>>>
>>>RootBeanDefinition.DEPENDENCY_CHECK_ALL;
>>>
>>>
>>>
>>>
>>>> }
>>>> else if (DEPENDENCY_CHECK_SIMPLE_ATTRIBUTE_VALUE.equals(att))
>>>>
>>>>
>>>>
>>>>
>>>{
>>>
>>>
>>>
>>>
>>>> dependencyCheckCode =
>>>>RootBeanDefinition.DEPENDENCY_CHECK_SIMPLE;
>>>> }
>>>> else if (DEPENDENCY_CHECK_OBJECTS_ATTRIBUTE_VALUE.equals(att))
>>>>
>>>>
>>>>
>>>>
>>>{
>>>
>>>
>>>
>>>
>>>> dependencyCheckCode =
>>>>RootBeanDefinition.DEPENDENCY_CHECK_OBJECTS;
>>>> }
>>>> // else leave default value
>>>> return dependencyCheckCode;
>>>> }
>>>>
>>>>Is 'default' still needed?
>>>>
>>>>Colin
>>>>
>>>>
|