| 1 24 package org.riotfamily.components.config; 25 26 import org.riotfamily.common.beans.xml.AbstractGenericBeanDefinitionParser; 27 import org.riotfamily.common.beans.xml.GenericNamespaceHandlerSupport; 28 import org.riotfamily.common.beans.xml.NestedListDecorator; 29 import org.riotfamily.components.component.IncludeComponent; 30 import org.riotfamily.components.component.StaticComponent; 31 import org.riotfamily.components.component.ViewComponent; 32 import org.riotfamily.components.property.DefaultValuePropertyProcessor; 33 import org.springframework.beans.factory.support.BeanDefinitionBuilder; 34 import org.springframework.beans.factory.xml.BeanDefinitionDecorator; 35 import org.springframework.beans.factory.xml.ParserContext; 36 import org.w3c.dom.Element ; 37 38 43 public class ComponentNamespaceHandler extends GenericNamespaceHandlerSupport { 44 45 public void init() { 46 register("static-component", StaticComponent.class); 47 register("view-component", ViewComponent.class); 48 register("include-component", IncludeComponent.class); 49 50 BeanDefinitionDecorator addPropertyProcessor = 51 new NestedListDecorator("propertyProcessors"); 52 53 registerSpringBeanDefinitionParser("property-processor", 54 addPropertyProcessor); 55 56 register("defaults", new DefaultValueParser(), addPropertyProcessor); 57 } 58 59 private static class DefaultValueParser extends 60 AbstractGenericBeanDefinitionParser { 61 62 public DefaultValueParser() { 63 super(DefaultValuePropertyProcessor.class); 64 } 65 66 protected void doParse(Element element, ParserContext parserContext, 67 BeanDefinitionBuilder builder) { 68 69 builder.addPropertyValue("values", parserContext.getDelegate() 70 .parsePropsElement(element)); 71 } 72 73 } 74 } 75 | Popular Tags |