KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > xdoclet > modules > spring > SpringXmlSubTask


1 /*
2  * Copyright (c) 2001, 2002 The XDoclet team
3  * All rights reserved.
4  */

5 package xdoclet.modules.spring;
6
7 import xdoclet.XDocletException;
8 import xdoclet.XDocletMessages;
9 import xdoclet.XmlSubTask;
10 import xdoclet.util.Translator;
11
12 /**
13  * Generates XML file to wire beans in the Spring framework.
14  *
15  * @author Craig Walls (xdoclet@habuma.com)
16  * @created March 5, 2004
17  * @ant.element display-name="spring.xml" name="springxml" parent="xdoclet.modules.spring.SpringDocletTask"
18  * @xdoclet.merge-file file="spring-beans.xml" relates-to="spring.xml" description="An XML unparsed entity containing
19  * bean declarations to be included in a generated Spring bean XML file."
20  */

21 public class SpringXmlSubTask extends XmlSubTask
22 {
23     private final static String JavaDoc SPRING_PUBLIC_ID = "-//SPRING//DTD BEAN//EN";
24
25     private final static String JavaDoc SPRING_SYSTEM_ID = "http://www.springframework.org/dtd/spring-beans.dtd";
26
27     private final static String JavaDoc SPRING_DTD = "resources/spring-beans.dtd";
28
29     private final static String JavaDoc DEFAULT_TEMPLATE_FILE = "resources/spring_xml.xdt";
30
31     private final static String JavaDoc GENERATED_FILE_NAME = "spring.xml";
32
33     private String JavaDoc defaultAutowire = "no";
34     private String JavaDoc defaultLazyInit = "false";
35     private String JavaDoc defaultDependencyCheck = "none";
36
37     public SpringXmlSubTask()
38     {
39         setPublicId(SPRING_PUBLIC_ID);
40         setSystemId(SPRING_SYSTEM_ID);
41         setDtdURL(getClass().getResource(SPRING_DTD));
42         setTemplateURL(getClass().getResource(DEFAULT_TEMPLATE_FILE));
43         setDestinationFile(GENERATED_FILE_NAME);
44     }
45
46     public String JavaDoc getDefaultAutowire()
47     {
48         return defaultAutowire;
49     }
50
51     public String JavaDoc getDefaultDependencyCheck()
52     {
53         return defaultDependencyCheck;
54     }
55
56     public String JavaDoc getDefaultLazyInit()
57     {
58         return defaultLazyInit;
59     }
60
61     /**
62      * Sets the name of the generated bean XML file. Defaults to "spring.xml".
63      *
64      * @param destinationFile
65      */

66     public void setDestinationFile(String JavaDoc destinationFile)
67     {
68         super.setDestinationFile(destinationFile);
69     }
70
71     /**
72      * Sets the default autowiring mode to apply to all beans in the generated file. Each bean can override this default
73      * by setting the autowire attribute of \@spring.bean. Defaults to "no".
74      *
75      * @param autowire
76      */

77     public void setDefaultAutowire(String JavaDoc autowire)
78     {
79         defaultAutowire = autowire;
80     }
81
82     /**
83      * Sets the default dependency checking mode for all beans in the generated file. Each bean can override this
84      * default setting the dependency-check attribute of \@spring.bean. Defaults to "none".
85      *
86      * @param dependencyCheck
87      */

88     public void setDefaultDependencyCheck(String JavaDoc dependencyCheck)
89     {
90         defaultDependencyCheck = dependencyCheck;
91     }
92
93     /**
94      * Sets the default lazy initialization mode for all beans in the generated file. Each bean can override this
95      * default by setting the lazy-init attribute of \@spring.bean. Defaults to "false".
96      *
97      * @param lazyInit
98      */

99     public void setDefaultLazyInit(String JavaDoc lazyInit)
100     {
101         defaultLazyInit = lazyInit;
102     }
103
104     /**
105      * Describe what the method does
106      *
107      * @exception XDocletException
108      */

109     public void execute() throws XDocletException
110     {
111         startProcess();
112     }
113
114     protected void engineStarted() throws XDocletException
115     {
116         System.out.println(Translator.getString(XDocletMessages.class, XDocletMessages.GENERATING_SOMETHING, new String JavaDoc[]{getDestinationFile()}));
117     }
118 }
119
Popular Tags