01 /*
02 * InitBeanDefinitionParser.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: InitBeanDefinitionParser.java 12006 2009-12-01 17:24:28Z thomas_heitz $
15 */
16
17 package gate.util.spring.xml;
18
19 import gate.util.spring.Init;
20
21 import java.util.List;
22
23 import org.springframework.beans.factory.support.BeanDefinitionBuilder;
24 import org.springframework.beans.factory.xml.AbstractSimpleBeanDefinitionParser;
25 import org.springframework.beans.factory.xml.ParserContext;
26 import org.springframework.util.xml.DomUtils;
27 import org.w3c.dom.Element;
28
29 /**
30 * BeanDefinitionParser for <code><gate:init></code> elements,
31 * producing a definition for an {@link Init} object.
32 */
33 public class InitBeanDefinitionParser
34 extends
35 AbstractSimpleBeanDefinitionParser {
36
37 @Override
38 protected void doParse(Element element, ParserContext ctx,
39 BeanDefinitionBuilder builder) {
40 super.doParse(element, ctx, builder);
41 Element preloadElt = DomUtils.getChildElementByTagName(element,
42 "preload-plugins");
43 if(preloadElt != null) {
44 List preloadPluginsList = ctx.getDelegate().parseListElement(preloadElt,
45 builder.getBeanDefinition());
46 builder.addPropertyValue("preloadPlugins", preloadPluginsList);
47 }
48 builder.setInitMethodName("init");
49 }
50
51 @Override
52 protected Class getBeanClass(Element element) {
53 return Init.class;
54 }
55
56 @Override
57 protected boolean shouldGenerateIdAsFallback() {
58 return true;
59 }
60
61 }
|