FeatureMapBeanDefinitionParser.java :  » Natural-Language-Processing » GATE » gate » util » spring » xml » Java Open Source

Java Open Source » Natural Language Processing » GATE 
GATE » gate » util » spring » xml » FeatureMapBeanDefinitionParser.java
/*
 *  FeatureMapBeanDefinitionParser.java
 *
 *  Copyright (c) 1995-2010, The University of Sheffield. See the file
 *  COPYRIGHT.txt in the software or at http://gate.ac.uk/gate/COPYRIGHT.txt
 *
 *  This file is part of GATE (see http://gate.ac.uk/), and is free
 *  software, licenced under the GNU Library General Public License,
 *  Version 2, June 1991 (in the distribution as file licence.html,
 *  and also available at http://gate.ac.uk/gate/licence.html).
 *
 *  Ian Roberts, 22/Jan/2008
 *
 *  $Id: FeatureMapBeanDefinitionParser.java 12006 2009-12-01 17:24:28Z thomas_heitz $
 */

package gate.util.spring.xml;

import gate.util.spring.FeatureMapFactoryBean;

import java.util.Map;

import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser;
import org.springframework.beans.factory.xml.ParserContext;
import org.w3c.dom.Element;

/**
 * Bean definition parser for <code>&lt;gate:feature-map&gt;</code>
 * elements, producing a definition for a {@link FeatureMapFactoryBean}.
 */
public class FeatureMapBeanDefinitionParser
                                           extends
                                             AbstractSingleBeanDefinitionParser {

  @Override
  protected void doParse(Element element, ParserContext parserContext,
          BeanDefinitionBuilder builder) {
    Map sourceMap = parserContext.getDelegate().parseMapElement(element,
            builder.getRawBeanDefinition());
    builder.addPropertyValue("sourceMap", sourceMap);
    if(element.hasAttribute("scope")) {
      builder.setScope(element.getAttribute("scope"));
    }
  }

  @Override
  protected Class getBeanClass(Element element) {
    return FeatureMapFactoryBean.class;
  }

}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.