You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cxf.apache.org by Dan Diephouse <da...@envoisolutions.com> on 2007/06/27 17:21:44 UTC
AbstractBeanDefinitionParser [was Re: svn commit: r550965 ...]
Thanks for the helpful comments Glen. I'll fix the first/last bug you
mentioned.
I didn't write the code below, does anyone know what the multiple name logic
is for?
> > + protected String getIdOrName(Element elem) {
> > + String id = elem.getAttribute(
> BeanDefinitionParserDelegate.ID_ATTRIBUTE);
> > +
> > + if (null == id || "".equals(id)) {
> > + String names = elem.getAttribute(BeanConstants.NAME_ATTR);
> > + if (null != names) {
> > + StringTokenizer st =
> > + new StringTokenizer(names,
> BeanDefinitionParserDelegate.BEAN_NAME_DELIMITERS);
> > + if (st.countTokens() > 0) {
> > + id = st.nextToken();
> > + }
> > + }
> > + }
> > + return id;
> > + }
> > +
> > +}
>
> Since an id="" is invalid here (it causes one to search for the names
> instead), you might wish for this method to return null for an id=""
> with no names found (presently it will return an empty string). This
> way the caller of this method needs only to check for 'null' (not both
> 'null' or an 'empty string').
>
> Also, I don't know enough about the business logic, but, just to
> confirm, are you certain you would want to return the last name in the
> set if there are multiple names--instead of the first name available,
> or, actually, to raise an exception if more than one name is present?
>
>
--
Dan Diephouse
Envoi Solutions
http://envoisolutions.com | http://netzooid.com/blog
Re: AbstractBeanDefinitionParser [was Re: svn commit: r550965 ...]
Posted by Glen Mazza <gl...@verizon.net>.
Am Mittwoch, den 27.06.2007, 16:32 +0100 schrieb Andrea Smyth:
> >> > + protected String getIdOrName(Element elem) {
> >> > + String id = elem.getAttribute(
> >> BeanDefinitionParserDelegate.ID_ATTRIBUTE);
> >> > +
> >> > + if (null == id || "".equals(id)) {
> >> > + String names =
> >> elem.getAttribute(BeanConstants.NAME_ATTR);
> >> > + if (null != names) {
> >> > + StringTokenizer st =
> >> > + new StringTokenizer(names,
> >> BeanDefinitionParserDelegate.BEAN_NAME_DELIMITERS);
> >> > + if (st.countTokens() > 0) {
> >> > + id = st.nextToken();
> >> > + }
> >> > + }
> >> > + }
> >> > + return id;
> >> > + }
> >> > +
> >> > +}
> >>
> >> Since an id="" is invalid here (it causes one to search for the names
> >> instead), you might wish for this method to return null for an id=""
> >> with no names found (presently it will return an empty string). This
> >> way the caller of this method needs only to check for 'null' (not both
> >> 'null' or an 'empty string').
> >>
> >> Also, I don't know enough about the business logic, but, just to
> >> confirm, are you certain you would want to return the last name in the
> >> set if there are multiple names--instead of the first name available,
> >> or, actually, to raise an exception if more than one name is present?
> >
> But it does return the first alias if there are any - not the last?
>
Oops--sorry about that! Yes, I stand corrected, indeed, it does return
the first alias.
Glen
> Andrea.
>
> >>
> >>
> >
> >
>
> ----------------------------
> IONA Technologies PLC (registered in Ireland)
> Registered Number: 171387
> Registered Address: The IONA Building, Shelbourne Road, Dublin 4, Ireland
Re: AbstractBeanDefinitionParser [was Re: svn commit: r550965 ...]
Posted by Andrea Smyth <an...@iona.com>.
Dan Diephouse wrote:
> Thanks for the helpful comments Glen. I'll fix the first/last bug you
> mentioned.
>
> I didn't write the code below, does anyone know what the multiple name
> logic
> is for?
See
http://static.springframework.org/spring/docs/2.0.x/reference/beans.html#beans-beanname
for information on the id and name attributes of the bean element.
The part is taken from
org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.parseBeanDefinitionElement
so CXF custom beans behave like Spring beans where possible, e.g. w.r.t
identification (id, name attribute), instantiation (lazy-init attribute)
etc.
>
>
>> > + protected String getIdOrName(Element elem) {
>> > + String id = elem.getAttribute(
>> BeanDefinitionParserDelegate.ID_ATTRIBUTE);
>> > +
>> > + if (null == id || "".equals(id)) {
>> > + String names =
>> elem.getAttribute(BeanConstants.NAME_ATTR);
>> > + if (null != names) {
>> > + StringTokenizer st =
>> > + new StringTokenizer(names,
>> BeanDefinitionParserDelegate.BEAN_NAME_DELIMITERS);
>> > + if (st.countTokens() > 0) {
>> > + id = st.nextToken();
>> > + }
>> > + }
>> > + }
>> > + return id;
>> > + }
>> > +
>> > +}
>>
>> Since an id="" is invalid here (it causes one to search for the names
>> instead), you might wish for this method to return null for an id=""
>> with no names found (presently it will return an empty string). This
>> way the caller of this method needs only to check for 'null' (not both
>> 'null' or an 'empty string').
>>
>> Also, I don't know enough about the business logic, but, just to
>> confirm, are you certain you would want to return the last name in the
>> set if there are multiple names--instead of the first name available,
>> or, actually, to raise an exception if more than one name is present?
>
But it does return the first alias if there are any - not the last?
Andrea.
>>
>>
>
>
----------------------------
IONA Technologies PLC (registered in Ireland)
Registered Number: 171387
Registered Address: The IONA Building, Shelbourne Road, Dublin 4, Ireland
Re: AbstractBeanDefinitionParser [was Re: svn commit: r550965 ...]
Posted by Dan Diephouse <da...@envoisolutions.com>.
BTW Glen: patches are welcome! You definitely seem to have a great eye for
detail (which I don't) and know your way around things :-)
On 6/27/07, Dan Diephouse <da...@envoisolutions.com> wrote:
>
> Thanks for the helpful comments Glen. I'll fix the first/last bug you
> mentioned.
>
> I didn't write the code below, does anyone know what the multiple name
> logic is for?
>
>
> > > + protected String getIdOrName(Element elem) {
> > > + String id = elem.getAttribute(
> > BeanDefinitionParserDelegate.ID_ATTRIBUTE);
> > > +
> > > + if (null == id || "".equals(id)) {
> > > + String names = elem.getAttribute(BeanConstants.NAME_ATTR
> > );
> > > + if (null != names) {
> > > + StringTokenizer st =
> > > + new StringTokenizer(names,
> > BeanDefinitionParserDelegate.BEAN_NAME_DELIMITERS);
> > > + if (st.countTokens() > 0) {
> > > + id = st.nextToken();
> > > + }
> > > + }
> > > + }
> > > + return id;
> > > + }
> > > +
> > > +}
> >
> > Since an id="" is invalid here (it causes one to search for the names
> > instead), you might wish for this method to return null for an id=""
> > with no names found (presently it will return an empty string). This
> > way the caller of this method needs only to check for 'null' (not both
> > 'null' or an 'empty string').
> >
> > Also, I don't know enough about the business logic, but, just to
> > confirm, are you certain you would want to return the last name in the
> > set if there are multiple names--instead of the first name available,
> > or, actually, to raise an exception if more than one name is present?
> >
> >
>
>
> --
> Dan Diephouse
> Envoi Solutions
> http://envoisolutions.com | http://netzooid.com/blog
--
Dan Diephouse
Envoi Solutions
http://envoisolutions.com | http://netzooid.com/blog