KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > xdoclet > modules > ibm > websphere > ejb > WebSphereSubTask


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

5 package xdoclet.modules.ibm.websphere.ejb;
6
7 import xdoclet.XDocletException;
8
9 import xdoclet.modules.ejb.dd.AbstractEjbDeploymentDescriptorSubTask;
10
11 /**
12  * Generates WebSphere specific deployment descriptors for EJB modules. The following files are generated:
13  * ibm-ejb-jar-bnd.xmi, ibm-ejb-jar-ext.xmi and Schema.dbxmi. <p>
14  *
15  * NOTE: Since the WebSphere specific deployment descriptors depend on that id's are set in the ejb-jar.xml file you
16  * must genererate it with useIds set to true, e.g. <code>&lt;deploymentdescriptor useIds="true"/&gt;</code>. </p> <p>
17  *
18  * This Ant task defines the following attributes (the rest of the attributes in the list below comes from its
19  * baseclass):
20  * <ul>
21  * <li> datasource</li>
22  * <li> currentBackendId</li>
23  * </ul>
24  * </p>
25  *
26  * @author Minh Yie
27  * @author <a HREF="mailto:ml at callista.se">Magnus Larsson</a>
28  * @created 15 August 2001
29  * @ant.element display-name="WebSphere" name="websphere" parent="xdoclet.modules.ejb.EjbDocletTask"
30  * @version $Revision: 1.10 $
31  */

32 public class WebSphereSubTask extends AbstractEjbDeploymentDescriptorSubTask
33 {
34     private static String JavaDoc WEBSPHERE_DEFAULT_BND_TEMPLATE_FILE = "resources/ibm-ejb-jar-bnd_xmi.xdt";
35
36     private static String JavaDoc WEBSPHERE_DD_BND_FILE_NAME = "ibm-ejb-jar-bnd.xmi";
37
38     private static String JavaDoc WEBSPHERE_DEFAULT_EXT_TEMPLATE_FILE = "resources/ibm-ejb-jar-ext_xmi.xdt";
39
40     private static String JavaDoc WEBSPHERE_DD_EXT_FILE_NAME = "ibm-ejb-jar-ext.xmi";
41
42     private static String JavaDoc WEBSPHERE_SCHEMA_TEMPLATE_FILE = "resources/Schema_dbxmi.xdt";
43
44     private static String JavaDoc WEBSPHERE_DD_SCHEMA_FILE_NAME = "Schema.dbxmi";
45
46     /**
47      * A member for the default CMP DataSource
48      */

49     private String JavaDoc datasource;
50
51     /**
52      * A member for the current backend id
53      */

54     private String JavaDoc currentBackendId;
55
56     public WebSphereSubTask()
57     {
58         setUseIds(true);
59     }
60
61     /**
62      * Gets the default CMP Datasource
63      *
64      * @return The default CMP Datasource
65      */

66     public String JavaDoc getDatasource()
67     {
68         return datasource;
69     }
70
71     /**
72      * Gets the current backend id
73      *
74      * @return The current backend id
75      */

76     public String JavaDoc getCurrentBackendId()
77     {
78         return currentBackendId;
79     }
80
81     /**
82      * Sets the default CMP Datasource
83      *
84      * @param datasource The new default CMP Datasource
85      * @ant.not-required No.
86      */

87     public void setDatasource(String JavaDoc datasource)
88     {
89         this.datasource = datasource;
90     }
91
92     /**
93      * Sets the current backend id. This parameter is used to point out the id of the current CMP mapping.
94      *
95      * @param backendId The current backend id
96      * @ant.not-required No.
97      */

98     public void setCurrentBackendId(String JavaDoc backendId)
99     {
100         this.currentBackendId = backendId;
101     }
102
103     /**
104      * Called to validate configuration parameters.
105      *
106      * @exception XDocletException Description of Exception
107      */

108     public void validateOptions() throws XDocletException
109     {
110         // WebSphere does not require a template url or a destination file
111
//
112
// super.validateOptions();
113
}
114
115     /**
116      * Describe what the method does
117      *
118      * @exception XDocletException Describe the exception
119      */

120     public void execute() throws XDocletException
121     {
122         setTemplateURL(getClass().getResource(WEBSPHERE_DEFAULT_BND_TEMPLATE_FILE));
123         setDestinationFile(WEBSPHERE_DD_BND_FILE_NAME);
124         startProcess();
125
126         setTemplateURL(getClass().getResource(WEBSPHERE_DEFAULT_EXT_TEMPLATE_FILE));
127         setDestinationFile(WEBSPHERE_DD_EXT_FILE_NAME);
128         startProcess();
129
130         /*
131          * TODO: Conflicts with WSAD so we better simply rely on the CMP mapping capabilities in WSAD and WebSphere!
132          */

133         if (atLeastOneCmpEntityBeanExists()) {
134             setTemplateURL(getClass().getResource(WEBSPHERE_SCHEMA_TEMPLATE_FILE));
135             setDestinationFile(WEBSPHERE_DD_SCHEMA_FILE_NAME);
136             startProcess();
137         }
138     }
139
140     /**
141      * Describe what the method does
142      *
143      * @exception XDocletException Describe the exception
144      */

145     protected void engineStarted() throws XDocletException
146     {
147     }
148 }
149
Popular Tags