it'd be nice if it's something like this
To do that we need to create a custom namespace for spring and we can have our bean definition under beans. I found this blog by carlo scarioni detailing how to do that. Following it, I was able to create my namespace and put in under beans. However, it is not added to the application context.
For that, I followed Spring's doc, all i have to do is
- the xsd needs to import spring beans and the element needs to extend beans:identifiedType.
- the bean definition parser should extends AbstractSingleBeanDefinitionParser instead.
Another cool thing we can use is to use spring tool so you can verify the bean ref is of a certain class. Import the following namespace and add the annotation to your attribute.
<xs:import namespace="http://www.springframework.org/schema/tool" />
below is the gist we used to parse our custom tag. note that it set the scope to prototype at the end and it also shows you how to pass an array of beans.
Post a Comment