Announcement Announcement Module
Collapse
No announcement yet.
chained bean parsers Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • chained bean parsers

    I need to write a Bean parser for a Bean that has:

    1) bean properties correspond to simple leaf child elements with text
    2) Collection members of beans similer to (1)

    Example:

    <order>
    <orderId>123</orderId>
    <zip>92122<zip>
    <lineItems>
    <product>ipod</product>
    </lineItems>
    </order>

    This is a fairly common case of an object graph unmarshalling. I was hoping that spring would handle (at least for the single level case), but I was able to write an instance of AbstractSingleBeanDefinitionParser to preform this.

    What I would like to know is if there is a way to write a single BeanDefinitionParser for each bean in this hierarchy (Order and LineItem) which handle just the properties. I want to somehow chain the BeanDefinitionParsers so that the bean output for LineItem is used somewhat transparently by the Order Bean Parser.

    It appears, however, that with AbstractSingleBeanDefinitionParser, you get handed the whole sub-tree, with no help from spring on unmarshalling inner bean definitions.

    erik

  • #2
    Inner bean definitions are a special kind of bean - by their nature they can't exist w/o their parent and that's why they don't require a name or they can't be addressed or looked up manually.
    I would suggest to either make the bean a top level bean and use references to it or use a different parser strategy. I'm wild guessing here but if you are using XStream, you have plenty of callbacks to know deep inside the 'beans' tree so you can use some sort of 'stack' approach to navigate through it.

    Comment

    Working...
    X