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