The current workaround for dealing with objects with non-default ctors is to use a container implementing org.jboss.xml.binding.GenericValueContainer. For the ModuleOption:
| package org.jboss.test.xml.mbeanserver;
|
| import javax.xml.namespace.QName;
| import org.jboss.xml.binding.GenericValueContainer;
|
| /**
| * ModuleOption declares a constructor that takes name as a parameter while the value should be set
| * with the setter. This use-case is not supported out-of-the-box. So, we use this container.
| *
| * @author <a href="mailto:al...@jb...">Alexey Loubyansky</a>
| * @version <tt>$Revision: 1.1 $</tt>
| */
| public class ModuleOptionContainer
| implements GenericValueContainer
| {
| private String name;
| private Object value;
|
| public void addChild(QName name, Object value)
| {
| if("name".equals(name.getLocalPart()))
| {
| this.name = (String)value;
| }
| else
| {
| this.value = value;
| }
| }
|
| public Object instantiate()
| {
| ModuleOption option = new ModuleOption(name);
| option.setValue(value);
| return option;
| }
| }
|
|
I guess both attributes and elements are treated the same and passed to the addChild method. The associated xsd fragment is:
| <xs:element name="module-option">
| <xs:complexType mixed="true">
| <xsd:annotation>
| <xsd:appinfo>
| <!-- ModuleOption declares a constructor that takes name as a parameter
| while the value should be set with the setter.
| This use-case is not supported out-of-the-box. So, we use this container. -->
| <jbxb:class impl="org.jboss.test.xml.mbeanserver.ModuleOptionContainer"/>
| </xsd:appinfo>
| </xsd:annotation>
| <xs:sequence>
| <xs:any minOccurs="0" maxOccurs="1" namespace="##other" />
| </xs:sequence>
| <xs:attribute name="name" use="required" type="xs:string"/>
| </xs:complexType>
| </xs:element>
|
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3882411#3882411
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3882411
|