开发者

Parsing a List of Elements in a Mule Configuration

开发者 https://www.devze.com 2023-03-24 23:58 出处:网络
I am building a new Mule transport to allow communication with DDS.In order to keep QoS consistent, the connector needs \"flow controllers\".Zero or more flow controllers may exist.

I am building a new Mule transport to allow communication with DDS. In order to keep QoS consistent, the connector needs "flow controllers". Zero or more flow controllers may exist.

The connector's XSD has already been modified to allow the following:

<connector>
  <flowController attr="1">
  <flowController attr="2">
</connector>

It is easy to read a single flowController by using a ChildDefinitionParser, but that is not adequate.

ChildListEntryDefinitionParser returns a list with the correct number of elements, but each element is null.

ChildListDefinitionPars开发者_运维问答er does not work unless extended to provide the setters for all of the attributes. After doing this, I still only get the first entry.

The source and documentation have not been terribly helpful. Thanks in advance!


I had a similar use case. ChildListEntryDefinitionParser works fine (tested with Mule ESB 3.4). List elements will set correctly.

mule-config.xml

<your:xpath-resolver-transformer>
   <your:expression xpath="//order/status" />
   <your:expression xpath="//order/type" />
</your:xpath-resolver-transformer>

YourNamespaceHandler

MessageProcessorDefinitionParser xpathResolver = new MessageProcessorDefinitionParser(XPathResolver.class);
xpathResolver.registerPreProcessor(new CheckExclusiveAttributesAndChildren(new String[]
{ "xpath" }, new String[]
{ "expression" }));
registerBeanDefinitionParser("expression", new ChildListEntryDefinitionParser("xpathExpression", "xpath"));
registerBeanDefinitionParser("xpath-resolver-transformer", xpathResolver);

Mule XSD (mule-your.xsd)

<xsd:element name="xpath-resolver-transformer" type="xpathResolverTransformerType" substitutionGroup="mule:abstract-transformer" />     
<xsd:complexType name="xpathResolverTransformerType">
    <xsd:complexContent>
        <xsd:extension base="mule:abstractTransformerType">
            <xsd:sequence>
                <xsd:element name="expression" minOccurs="0" maxOccurs="unbounded">
                    <xsd:complexType>
                        <xsd:attribute name="xpath" type="xsd:string" use="required"></xsd:attribute>
                    </xsd:complexType>
                </xsd:element>
            </xsd:sequence>
        </xsd:extension>
    </xsd:complexContent>
</xsd:complexType>
0

精彩评论

暂无评论...
验证码 换一张
取 消