title: How to combine custom BeanDefinitionParser with BeanDefinitionDecorator in Spring
body: <p>I use custom namespace to simplify some framework component deployment.</p>
  
  <p>Our config look more or less like:</p>
  
  <pre><code>&lt;rf:container attribute1="id"&gt;
    &lt;property name="processors" value="5" /&gt;
  &lt;/rf:container&gt;
  </code></pre>
  
  <p>With number of custom mandatory attributes and set of optional properties. It is parsed into a bean definition.
  It should be extended now to accept property which is represented as a bean which could either be shared or declared only for this bean.</p>
  
  <p>Configuration bean definition when defined as a standalone bean is created as:</p>
  
  <pre><code>&lt;rf:config id="queue" size="100" bytes="1M"/&gt;
  </code></pre>
  
  <p>Then it can be set as a property or embedded directly inside &lt;property&gt; tag.</p>
  
  <p>But i would like to simplify that and provide a shortcut like:</p>
  
  <pre><code>&lt;rf:container attribute1="id"&gt;
    &lt;property name="processors" value="5" /&gt;
    &lt;rf:config size="100" bytes="1M"/&gt;
  &lt;/rf:container&gt;
  </code></pre>
  
  <p>which would make configuration more expressive in many cases for me.</p>
  
  <p>At the moment both tags are parsed by BeanDefinitionParser implementations. I tried to use BeanDefinitionDecorator for the same name, but it looks like I don't fully understand how to use either one or both of them.</p>
  
  <p>Decorators are applied when beans are parsed standard way by DefaultBeanDefinitionDocumentReader (i.e. &lt;bean&gt; tag) inside, but this code is not executed when custom parser is used. In our parser implementation plain properties are parsed by manually calling parsePropertyElements() inside parse method, but invoking decorator parsing is harder because BeanDefinitionHolder is not ready at that time.</p>
  
  <p>What would be the right way to ensure decorators are parsed for custom bean parsers?</p>
  
  <p>Current solution explicitly searches our own tags inside and handles them, but it does look wrong to me.</p>