01: /*
02: * $Id: OGNLNamespaceHandler.java 11195 2008-03-06 04:13:01Z tcarlson $
03: * --------------------------------------------------------------------------------------
04: * Copyright (c) MuleSource, Inc. All rights reserved. http://www.mulesource.com
05: *
06: * The software in this package is published under the terms of the CPAL v1.0
07: * license, a copy of which has been included with this distribution in the
08: * LICENSE.txt file.
09: */
10: package org.mule.module.ognl.config;
11:
12: import org.mule.config.spring.parsers.assembly.BeanAssembler;
13: import org.mule.config.spring.parsers.generic.ChildDefinitionParser;
14: import org.mule.module.ognl.filters.OGNLFilter;
15:
16: import org.springframework.beans.factory.xml.NamespaceHandlerSupport;
17: import org.springframework.beans.factory.xml.ParserContext;
18: import org.w3c.dom.Element;
19:
20: /**
21: * Registers Bean Definition Parsers for the "ognl" namespace.
22: */
23: public class OGNLNamespaceHandler extends NamespaceHandlerSupport {
24:
25: public void init() {
26: registerBeanDefinitionParser("filter",
27: new ChildDefinitionParser("filter", OGNLFilter.class));
28: registerBeanDefinitionParser("expression",
29: new CDATABeanDefinitionParser("expression",
30: String.class));
31: }
32:
33: private static class CDATABeanDefinitionParser extends
34: ChildDefinitionParser {
35: private CDATABeanDefinitionParser(String setterMethod,
36: Class clazz) {
37: super (setterMethod, clazz);
38: }
39:
40: protected void postProcess(ParserContext context,
41: BeanAssembler assembler, Element element) {
42: assembler.extendTarget(setterMethod, element
43: .getFirstChild().getNodeValue(), false);
44: }
45: }
46: }
|