01 package gate.util.spring.xml;
02
03 import gate.util.spring.ExtraGatePlugin;
04 import gate.util.spring.Init;
05
06 import org.springframework.beans.factory.support.BeanDefinitionBuilder;
07 import org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser;
08 import org.springframework.util.xml.DomUtils;
09 import org.w3c.dom.Element;
10
11 /**
12 * Bean definition parser for
13 * <code><gate:extra-plugin>path</gate:extra-plugin></code>
14 * producing the equivalent of
15 *
16 * <pre>
17 * <bean class="gate.util.spring.ExtraGatePlugin">
18 * <property name="location" value="path" />
19 * </bean>
20 * </pre>
21 *
22 * While the element can take an <code>id</code> it is not normally
23 * necessary to provide one as the {@link Init} bean enumerates all
24 * {@link ExtraGatePlugin} beans by type, ignoring their IDs.
25 */
26 public class ExtraGatePluginBeanDefinitionParser
27 extends
28 AbstractSingleBeanDefinitionParser {
29
30 @Override
31 protected void doParse(Element element, BeanDefinitionBuilder builder) {
32 builder.addPropertyValue("location", DomUtils.getTextValue(element));
33 }
34
35 @Override
36 protected Class getBeanClass(Element element) {
37 return ExtraGatePlugin.class;
38 }
39
40 @Override
41 protected boolean shouldGenerateIdAsFallback() {
42 return true;
43 }
44 }
|