1 /*
2 * PROJECT : DAR Runtime and Tools
3 * COPYRIGHT : Copyright (C) 1999-2004 tim.stephenson@enableit.org
4 * LICENSE : GNU LESSER GENERAL PUBLIC LICENSE
5 * Version 2.1, February 1999
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 */
21 package org.enableit.db.beans;
22
23
24 // Java imports
25 // Log4J Imports
26 import org.apache.log4j.Logger;
27
28
29 /***
30 * Convenience methods to enhance Castor's generated behaviour.
31 * @author Tim Stephenson
32 */
33 public abstract class AbstractProvider {
34 /*
35 * Properties
36 */
37
38 /***
39 * The Log4J <code>Logger</code> doing the logging.
40 */
41 private static Logger logger = Logger.getLogger(AbstractProvider.class);
42
43 /*
44 * Methods
45 */
46
47 /***
48 * @return ProviderChoice
49 */
50 public abstract ProviderChoice getProviderChoice();
51
52 /***
53 * @param ProviderChoice
54 */
55 public abstract void setProviderChoice(ProviderChoice pc);
56
57 /***
58 * Returns the value of field 'driver'.
59 *
60 * @return the value of field 'driver'.
61 */
62 public Driver getDriver() {
63 logger.info("METHOD_ENTRY: getDriver");
64
65 Driver driver = null;
66
67 try {
68 driver = getProviderChoice().getDriver();
69 } catch (NullPointerException e) {
70 logger.debug("Driver is null");
71
72 // ignore
73 }
74
75 logger.info("METHOD_EXIT: getDriver, driver:" + driver);
76
77 return driver;
78 }
79
80 //-- Driver getDriver()
81
82 /***
83 * Returns the value of field 'jdbc2-datasource-name'.
84 *
85 * @return the value of field 'jdbc2-datasource-name'.
86 */
87 public String getJdbc2DatasourceName() {
88 String jdbc2DatasourceName = null;
89
90 try {
91 jdbc2DatasourceName = getProviderChoice().getJdbc2DatasourceName();
92 } catch (NullPointerException e) {
93 // ignore
94 }
95
96 return jdbc2DatasourceName;
97 }
98
99 /***
100 * Returns the value of field 'product-name'.
101 *
102 * @return the value of field 'product-name'.
103 */
104
105 /*public String getProductName() {
106 String name = null ;
107 try {
108 name = getProviderChoice().getProductName();
109 } catch (NullPointerException e) {
110 // ignore
111 }
112 return name ;
113 } */
114
115 /***
116 * Returns the value of field 'password'.
117 *
118 * @return the value of field 'password'.
119 */
120 public String getPassword() {
121 String password = null;
122
123 try {
124 password = getProviderChoice().getDriver().getPassword();
125 } catch (NullPointerException e) {
126 // ignore
127 }
128
129 return password;
130 }
131
132 //-- String getPassword()
133
134 /***
135 * Returns the value of field 'url'.
136 *
137 * @return the value of field 'url'.
138 */
139 public String getUrl() {
140 String url = null;
141
142 try {
143 url = getProviderChoice().getDriver().getUrl();
144 } catch (NullPointerException e) {
145 // ignore
146 }
147
148 return url;
149 }
150
151 //-- String getUrl()
152
153 /***
154 * Returns the value of field 'username'.
155 *
156 * @return the value of field 'username'.
157 */
158 public String getUsername() {
159 String username = null;
160
161 try {
162 username = getProviderChoice().getDriver().getUsername();
163 } catch (NullPointerException e) {
164 // ignore
165 }
166
167 return username;
168 }
169
170 /***
171 * Returns the value of field 'version'.
172 *
173 * @return the value of field 'version'.
174 */
175
176 /*public String getVersion() {
177 String version = null ;
178 try {
179 version = getProviderChoice().getVersion();
180 } catch (NullPointerException e) {
181 // ignore
182 }
183 return version ;
184 } */
185
186 //-- String getVersion()
187
188 /***
189 * Sets the value of field 'driver'.
190 *
191 * @param driver the value of field 'driver'.
192 */
193 public void setDriver(Driver driver) {
194 logger.info("METHOD_ENTRY: setDriver, driver="
195 + ProviderExt.toString((Provider) this));
196
197 checkChoiceAndDriver();
198 getProviderChoice().setDriver(driver);
199
200 logger.info("METHOD_EXIT: setDriver, driver="
201 + ProviderExt.toString((Provider) this));
202 }
203
204 //-- void setDriver(Driver)
205 public void setJdbc2DatasourceName(String jdbc2DatasourceName) {
206 checkChoiceAndDriver();
207 setDriver(null);
208 getProviderChoice().setJdbc2DatasourceName(jdbc2DatasourceName);
209 }
210
211 /***
212 * Sets the value of field 'password'.
213 *
214 * @param password the value of field 'password'.
215 */
216 public void setPassword(String password) {
217 checkChoiceAndDriver();
218 getProviderChoice().getDriver().setPassword(password);
219 }
220
221 //-- void setPassword(String)
222
223 /***
224 * Sets the value of field 'url'.
225 *
226 * @param url the value of field 'url'.
227 */
228 public void setUrl(String url) {
229 checkChoiceAndDriver();
230 getProviderChoice().getDriver().setUrl(url);
231 }
232
233 //-- void setUrl(String)
234
235 /***
236 * Sets the value of field 'username'.
237 *
238 * @param username the value of field 'username'.
239 */
240 public void setUsername(String username) {
241 checkChoiceAndDriver();
242 getProviderChoice().getDriver().setUsername(username);
243 }
244
245 //-- void setUsername(String)
246 private void checkChoiceAndDriver() {
247 if (getProviderChoice() == null) {
248 logger.debug("Creating new provider choice");
249 setProviderChoice(new ProviderChoice());
250 }
251
252 if (getProviderChoice().getDriver() == null) {
253 logger.debug("Creating new driver");
254 getProviderChoice().setDriver(new Driver());
255 }
256 }
257 }
This page was automatically generated by Maven