KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jonas > ant > cluster > JdbcRaCluster


1 /**
2  * JOnAS: Java(TM) Open Application Server
3  * Copyright (C) 2005 Bull S.A.
4  * Contact: jonas-team@objectweb.org
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19  * USA
20  *
21  * Initial developer: Benoit Pelletier
22  * --------------------------------------------------------------------------
23  * $Id: JdbcRaCluster.java,v 1.1 2005/06/07 08:21:27 pelletib Exp $
24  * --------------------------------------------------------------------------
25  */

26
27 package org.objectweb.jonas.ant.cluster;
28
29 import java.io.File JavaDoc;
30 import org.objectweb.jonas.ant.jonasbase.JdbcRa;
31
32 /**
33  * Define JdbcRaCluster task
34  * @author Benoit Pelletier
35  */

36 public class JdbcRaCluster extends ClusterTasks {
37
38     /**
39      * Info for the logger
40      */

41     private static final String JavaDoc INFO = "[JdbcRaCluster] ";
42
43     /**
44      * Name of this JDBC Resource Adaptor
45      */

46     private String JavaDoc name = null;
47
48     /**
49      * Mapper Name of this JDBC Resource Adaptor
50      */

51     private String JavaDoc mapperName = null;
52
53     /**
54      * username of this JDBC Resource Adaptor
55      */

56     private String JavaDoc user = null;
57
58     /**
59      * Password of this JDBC Resource Adaptor
60      */

61     private String JavaDoc password = null;
62
63     /**
64      * URL of this JDBC Resource Adaptor
65      */

66     private String JavaDoc url = null;
67
68     /**
69      * Driver Name of this JDBC Resource Adaptor (may be set to the P6Spy driver name)
70      */

71     private String JavaDoc driverName = null;
72
73     /**
74      * Driver Name of this JDBC Resource Adaptor
75      */

76     private String JavaDoc realDriverName = null;
77
78     /**
79      * Max Pool Size
80      */

81     private String JavaDoc maxPoolSize = "100";
82
83     /**
84      * JNDI Name of this JDBC Resource Adaptor
85      */

86     private String JavaDoc jndiName = null;
87
88     /**
89      * Copy to autoload dir or not
90      */

91     private boolean autoload = true;
92
93     /**
94      * Using of the P6Spy tool or not
95      */

96     private boolean p6spy = false;
97     /**
98      * Default constructor
99      */

100     public JdbcRaCluster() {
101         super();
102     }
103
104     /**
105      * Set the name of this JDBC Resource Adaptor
106      * @param name the name of this JDBC Resource Adaptor
107      */

108     public void setName(String JavaDoc name) {
109         this.name = name;
110     }
111
112     /**
113      * Set the mapper name of this JDBC Resource Adaptor
114      * @param mapperName the mappername of this JDBC Resource Adaptor
115      */

116     public void setMapperName(String JavaDoc mapperName) {
117         this.mapperName = mapperName;
118     }
119
120     /**
121      * Set the user of this JDBC Resource Adaptor
122      * @param user the user of this JDBC Resource Adaptor
123      */

124     public void setUser(String JavaDoc user) {
125         this.user = user;
126     }
127
128     /**
129      * Set the password of this JDBC Resource Adaptor
130      * @param password the name of this JDBC Resource Adaptor
131      */

132     public void setPassword(String JavaDoc password) {
133         this.password = password;
134     }
135
136     /**
137      * Set the url of this JDBC Resource Adaptor
138      * @param url the name of this JDBC Resource Adaptor
139      */

140     public void setUrl(String JavaDoc url) {
141         this.url = url;
142     }
143
144     /**
145      * Set the max pool size of this JDBC Resource Adaptor Connection Pool
146      * @param maxPoolSize max pool size of connection
147      */

148     public void setMaxPoolSize(String JavaDoc maxPoolSize) {
149         this.maxPoolSize = maxPoolSize;
150     }
151
152     /**
153      * Set the name of the driver of this JDBC Resource Adaptor
154      * @param driverName the name of the driver of this JDBC Resource Adaptor
155      */

156     public void setDriverName(String JavaDoc driverName) {
157         this.driverName = driverName;
158         this.realDriverName = driverName;
159     }
160
161     /**
162      * Set the jndiName of this JDBC Resource Adaptor
163      * @param jndiName the jndiName of this JDBC Resource Adaptor
164      */

165     public void setJndiName(String JavaDoc jndiName) {
166         this.jndiName = jndiName;
167     }
168
169     /**
170      * opy rar to autoload or only in rars/ ?
171      * @param autoload true of false
172      */

173     public void setAutoload(boolean autoload) {
174         this.autoload = autoload;
175     }
176
177     /**
178      * Configure the using of the P6Spy tool or not ?
179      * @param p6spy true or false
180      */

181     public void setP6spy(boolean p6spy) {
182         this.p6spy = p6spy;
183     }
184
185     /**
186      * Generates the JdbcRa tasks for each JOnAS's instances
187      */

188     public void generatesTasks() {
189
190         int portInd = 0;
191
192         for (int i = getDestDirSuffixIndFirst(); i <= getDestDirSuffixIndLast(); i++) {
193
194             String JavaDoc destDir = getDestDir(getDestDirPrefix(), i);
195             log(INFO + "tasks generation for " + destDir);
196             // creation of the JdbcRa task
197
JdbcRa jdbcRa = new JdbcRa();
198
199             jdbcRa.setAutoload(autoload);
200             jdbcRa.setDriverName(driverName);
201             jdbcRa.setJndiName(jndiName);
202             jdbcRa.setMapperName(mapperName);
203             jdbcRa.setMaxPoolSize(maxPoolSize);
204             jdbcRa.setName(name);
205             jdbcRa.setP6spy(p6spy);
206             jdbcRa.setPassword(password);
207             jdbcRa.setUrl(url);
208             jdbcRa.setUser(user);
209
210             jdbcRa.setDestDir(new File JavaDoc(destDir));
211
212             addTask(jdbcRa);
213
214             portInd++;
215
216         }
217     }
218 }
Popular Tags