|
From: <jue...@we...> - 2004-07-01 07:32:43
|
Note that the DTD specifies "default" as default value for the =
attribute:
=20
<!ATTLIST bean dependency-check (none | objects | simple | all | =
default) "default">
=20
So if there's no value specified, the XML parser will return "default", =
triggering the correct behavior in DefaultXmlBeanDefinitionParser.
=20
The test suite just verified this for the "autowire" attribute, so I've =
just added a similar test for "dependency-check".
=20
Juergen
=20
________________________________
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 =3D
ele.getAttribute(DEPENDENCY_CHECK_ATTRIBUTE);
if (DEFAULT_VALUE.equals(dependencyCheck)) {
dependencyCheck =3D 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
>
>=20
>
>>-----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
>>
>> =20
>>
>>>-----Original Message-----
>>>From: spr...@li...
>>>[mailto:spr...@li...] On
>>> =20
>>>
>>Behalf
>> =20
>>
>>>Of Colin Sampaleanu
>>>Sent: Thursday, July 01, 2004 1:01 AM
>>>To: spr...@li...
>>>Subject: [Springframework-developer] Anybody know historical purpose
>>> =20
>>>
>>of
>> =20
>>
>>>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
>>> =20
>>>
>>almost
>> =20
>>
>>>like an accident.
>>>
>>> protected int getDependencyCheck(String att) {
>>> int dependencyCheckCode =3D
>>>RootBeanDefinition.DEPENDENCY_CHECK_NONE;
>>> if (DEPENDENCY_CHECK_ALL_ATTRIBUTE_VALUE.equals(att)) {
>>> dependencyCheckCode =3D
>>> =20
>>>
>>RootBeanDefinition.DEPENDENCY_CHECK_ALL;
>> =20
>>
>>> }
>>> else if (DEPENDENCY_CHECK_SIMPLE_ATTRIBUTE_VALUE.equals(att))
>>> =20
>>>
>>{
>> =20
>>
>>> dependencyCheckCode =3D
>>>RootBeanDefinition.DEPENDENCY_CHECK_SIMPLE;
>>> }
>>> else if =
(DEPENDENCY_CHECK_OBJECTS_ATTRIBUTE_VALUE.equals(att))
>>> =20
>>>
>>{
>> =20
>>
>>> dependencyCheckCode =3D
>>>RootBeanDefinition.DEPENDENCY_CHECK_OBJECTS;
>>> }
>>> // else leave default value
>>> return dependencyCheckCode;
>>> }
>>>
>>>Is 'default' still needed?
>>>
>>>Colin
>>> =20
>>>
-------------------------------------------------------
This SF.Net email sponsored by Black Hat Briefings & Training.
Attend Black Hat Briefings & Training, Las Vegas July 24-29 -
digital self defense, top technical experts, no vendor pitches,
unmatched networking opportunities. Visit www.blackhat.com
_______________________________________________
Springframework-developer mailing list
Spr...@li...
https://lists.sourceforge.net/lists/listinfo/springframework-developer
|