01 /*
02 * FeatureMapBeanDefinitionParser.java
03 *
04 * Copyright (c) 1995-2010, The University of Sheffield. See the file
05 * COPYRIGHT.txt in the software or at http://gate.ac.uk/gate/COPYRIGHT.txt
06 *
07 * This file is part of GATE (see http://gate.ac.uk/), and is free
08 * software, licenced under the GNU Library General Public License,
09 * Version 2, June 1991 (in the distribution as file licence.html,
10 * and also available at http://gate.ac.uk/gate/licence.html).
11 *
12 * Ian Roberts, 22/Jan/2008
13 *
14 * $Id: FeatureMapBeanDefinitionParser.java 12006 2009-12-01 17:24:28Z thomas_heitz $
15 */
16
17 package gate.util.spring.xml;
18
19 import gate.util.spring.FeatureMapFactoryBean;
20
21 import java.util.Map;
22
23 import org.springframework.beans.factory.support.BeanDefinitionBuilder;
24 import org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser;
25 import org.springframework.beans.factory.xml.ParserContext;
26 import org.w3c.dom.Element;
27
28 /**
29 * Bean definition parser for <code><gate:feature-map></code>
30 * elements, producing a definition for a {@link FeatureMapFactoryBean}.
31 */
32 public class FeatureMapBeanDefinitionParser
33 extends
34 AbstractSingleBeanDefinitionParser {
35
36 @Override
37 protected void doParse(Element element, ParserContext parserContext,
38 BeanDefinitionBuilder builder) {
39 Map sourceMap = parserContext.getDelegate().parseMapElement(element,
40 builder.getRawBeanDefinition());
41 builder.addPropertyValue("sourceMap", sourceMap);
42 if(element.hasAttribute("scope")) {
43 builder.setScope(element.getAttribute("scope"));
44 }
45 }
46
47 @Override
48 protected Class getBeanClass(Element element) {
49 return FeatureMapFactoryBean.class;
50 }
51
52 }
|