Bugs item #505657, was opened at 2002-01-18 22:07
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=376685&aid=505657&group_id=22866
Category: JBossServer
>Group: v3.0 Rabbit Hole
>Status: Closed
>Resolution: Fixed
Priority: 5
Submitted By: Nathan W. Phelps (nphelps)
>Assigned to: David Jencks (d_jencks)
Summary: ServiceConfiguration XML attributes
Initial Comment:
When using an mbean attribute of type XML Element any
XML elements within your custom XML named "attribute"
causes the ServiceConfiguration to try and set those
attributes on your mbean. This is caused because the
code gets a reference to the element mbean, then does
a getElementsByTagName("attribute") which returns all
elements named "attribute" regardless if they are
direct children of the element "mbean." This also
effects any elements within a custom xml attribute
named "mbean" or "depends." While it is very easy to
simply rename your custom XML Elements, generally one
tries to create uniformity when possible.
Example:
<mbean code="org.someco.MyService"
name="user:service=My Service">
<attribute name="Name">John Smith</attribute>
<attribute name="XmlConfig">
<my-xml>
<attribute name="JBossShouldntTouch">But it
will, because its getting all elements namd
attribute</attribute>
<mbean code="Blah">This would cause an error
too</mbean>
<depends>this too</depends>
</my-xml>
</attribute>
</mbean>
----------------------------------------------------------------------
>Comment By: David Jencks (d_jencks)
Date: 2002-02-05 10:03
Message:
Logged In: YES
user_id=60525
Ok, now I can mark it closed/fixed. If this needs to go
into 2.4.4 complain loudly.
----------------------------------------------------------------------
Comment By: David Jencks (d_jencks)
Date: 2002-02-04 19:58
Message:
Logged In: YES
user_id=60525
I've fixed this with a slightly different approach that
works for depends and depends-list as well.
----------------------------------------------------------------------
Comment By: Nathan W. Phelps (nphelps)
Date: 2002-02-03 15:45
Message:
Logged In: YES
user_id=130188
Thanks for you followup. I'll give the diff a try. What
I was getting at with the comment on mbean or demends was
that elements with those names cause problems as well. In
my comment I said attributes, but ment elements.
----------------------------------------------------------------------
Comment By: Jeff Tulley (jtulley)
Date: 2002-02-01 17:23
Message:
Logged In: YES
user_id=341242
Here's a fix (it looks like a lot, but I had to indent a
big block, wrapping it with another if statement, the
actual change is just right at the start):
diff -u -r1.43 ConfigurationService.java
--- ConfigurationService.java 2002/01/12 21:14:25 1.43
+++ ConfigurationService.java 2002/02/02 01:16:50
@@ -225,43 +225,46 @@
for (int j = 0; j < attrs.getLength(); j++)
{
Element attributeElement = (Element)
attrs.item(j);
- String attributeName =
attributeElement.getAttribute("name");
- if (attributeElement.hasChildNodes())
+ // make sure that out parent is mbean, so
that we haven't found
+ // a different element's child
named "attribute"
+ if (attributeElement.getParentNode
().getNodeName().equals("mbean"))
{
- String attributeValue = ((Text)
attributeElement.getFirstChild()).getData();
-
- if (autoTrim)
+ String attributeName =
attributeElement.getAttribute("name");
+ if (attributeElement.hasChildNodes())
{
- attributeValue = attributeValue.trim
();
- }
+ String attributeValue = ((Text)
attributeElement.getFirstChild()).getData();
- MBeanAttributeInfo[] attributes =
info.getAttributes();
- for (int k = 0; k < attributes.length;
k++)
- {
- if (attributeName.equals(attributes
[k].getName()))
+ if (autoTrim)
{
- String typeName = attributes
[k].getType();
- Class typeClass;
- if (primitives.containsKey
(typeName))
- {
- typeClass = (Class)
primitives.get(typeName);
- } else
- {
- typeClass = Class.forName
(typeName);
- }
- PropertyEditor editor =
PropertyEditorManager.findEditor(typeClass);
- Object value = attributeValue;
- if( editor != null )
+ attributeValue =
attributeValue.trim();
+ }
+
+ MBeanAttributeInfo[] attributes =
info.getAttributes();
+ for (int k = 0; k <
attributes.length; k++)
+ {
+ if (attributeName.equals(attributes
[k].getName()))
{
- editor.setAsText
(attributeValue);
- value = editor.getValue();
- }
+ String typeName = attributes
[k].getType();
+ Class typeClass;
+ if (primitives.containsKey
(typeName))
+ {
+ typeClass = (Class)
primitives.get(typeName);
+ } else
+ {
+ typeClass = Class.forName
(typeName);
+ }
+ PropertyEditor editor =
PropertyEditorManager.findEditor(typeClass);
+ Object value = attributeValue;
+ if( editor != null )
+ {
+ editor.setAsText
(attributeValue);
+ value = editor.getValue();
+ }
- if (debug)
- log.debug(attributeName + " set
to " + attributeValue + " in " + objectName);
- server.setAttribute(objectName,
new Attribute(attributeName, value));
+ if (debug)
+ log.debug(attributeName + "
set to " + attributeValue + " in " + objectName);
+ server.setAttribute(objectName,
new Attribute(attributeName, value));
- break;
+ break;
+ }
}
}
}
My only worry would be that in the change:
if (attributeElement.getParentNode().getNodeName().equals
("mbean")) {
That the parent node could be null. (according to the
docs, but that is only applicable if you are building a
DOM, not loading something in from disk, AFAICT). So, it
might pay to separate this out into multiple lines.
I only fixed the attribute problem, not the mbean or
depends potential problems. (I don't see the depends
issue, maybe I did not look hard enough).
----------------------------------------------------------------------
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=376685&aid=505657&group_id=22866
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development