KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > cjdbc > common > shared > BackendInfo


1 /**
2  * C-JDBC: Clustered JDBC.
3  * Copyright (C) 2002-2005 French National Institute For Research In Computer
4  * Science And Control (INRIA).
5  * Contact: c-jdbc@objectweb.org
6  *
7  * This library is free software; you can redistribute it and/or modify it
8  * under the terms of the GNU Lesser General Public License as published by the
9  * Free Software Foundation; either version 2.1 of the License, or any later
10  * version.
11  *
12  * This library is distributed in the hope that it will be useful, but WITHOUT
13  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
15  * for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public License
18  * along with this library; if not, write to the Free Software Foundation,
19  * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
20  *
21  * Initial developer(s): Nicolas Modrzyk.
22  * Contributor(s): Emmanuel Cecchet.
23  */

24
25 package org.objectweb.cjdbc.common.shared;
26
27 import java.io.Serializable JavaDoc;
28
29 import javax.management.NotCompliantMBeanException JavaDoc;
30
31 import org.objectweb.cjdbc.controller.backend.DatabaseBackend;
32
33 /**
34  * This class defines a BackendInfo. We cannot use DatabaseBackend as a
35  * serializable object because it is used as an MBean interface. We use this
36  * class to share configuration information on backends between distributed
37  * virtual database.
38  *
39  * @author <a HREF="mailto:Nicolas.Modrzyk@inrialpes.fr">Nicolas Modrzyk </a>
40  * @author <a HREF="mailto:Emmanuel.Cecchet@inria.fr">Emmanuel Cecchet </a>
41  * @version 1.0
42  */

43 public class BackendInfo implements Serializable JavaDoc
44 {
45   private static final long serialVersionUID = 235252034979233679L;
46
47   private String JavaDoc name;
48   private String JavaDoc url;
49   private String JavaDoc driverPath;
50   private String JavaDoc driverClassName;
51   private String JavaDoc virtualDatabaseName;
52   private String JavaDoc connectionTestStatement;
53   private int dynamicPrecision;
54   private boolean gatherSystemTables = false;
55   private String JavaDoc schemaName;
56   private String JavaDoc xml;
57
58   /**
59    * Creates a new <code>BackendInfo</code> object. Extract configuration
60    * information from the original backend object
61    *
62    * @param backend DatabaseBackend to extract information from
63    */

64   public BackendInfo(DatabaseBackend backend)
65   {
66     this.url = backend.getURL();
67     this.name = backend.getName();
68     this.driverPath = backend.getDriverPath();
69     this.driverClassName = backend.getDriverClassName();
70     this.virtualDatabaseName = backend.getVirtualDatabaseName();
71     this.connectionTestStatement = backend.getConnectionTestStatement();
72     this.dynamicPrecision = backend.getDynamicPrecision();
73     this.gatherSystemTables = backend.isGatherSystemTables();
74     this.schemaName = backend.getSchemaName();
75     this.xml = backend.getXml();
76   }
77
78   /**
79    * Create a corresponding DatabaseBackend object from the information stored
80    * in this object.
81    *
82    * @return a <code>DatabaseBackend</code>
83    */

84   public DatabaseBackend getDatabaseBackend()
85   {
86     try
87     {
88       return new DatabaseBackend(name, driverPath, driverClassName, url,
89           virtualDatabaseName, true, connectionTestStatement);
90     }
91     catch (NotCompliantMBeanException JavaDoc e)
92     {
93       throw new RuntimeException JavaDoc(
94           "Unable to recreate backend from BackendInfo object", e);
95     }
96   }
97
98   /**
99    * Returns the xml value.
100    *
101    * @return Returns the xml.
102    */

103   public String JavaDoc getXml()
104   {
105     return xml;
106   }
107
108   /**
109    * Returns the connectionTestStatement value.
110    *
111    * @return Returns the connectionTestStatement.
112    */

113   public String JavaDoc getConnectionTestStatement()
114   {
115     return connectionTestStatement;
116   }
117
118   /**
119    * Returns the driverClassName value.
120    *
121    * @return Returns the driverClassName.
122    */

123   public String JavaDoc getDriverClassName()
124   {
125     return driverClassName;
126   }
127
128   /**
129    * Returns the driverPath value.
130    *
131    * @return Returns the driverPath.
132    */

133   public String JavaDoc getDriverPath()
134   {
135     return driverPath;
136   }
137
138   /**
139    * Returns the dynamicPrecision value.
140    *
141    * @return Returns the dynamicPrecision.
142    */

143   public int getDynamicPrecision()
144   {
145     return dynamicPrecision;
146   }
147
148   /**
149    * Returns the name value.
150    *
151    * @return Returns the name.
152    */

153   public String JavaDoc getName()
154   {
155     return name;
156   }
157
158   /**
159    * Returns the schemaName value.
160    *
161    * @return Returns the schemaName.
162    */

163   public String JavaDoc getSchemaName()
164   {
165     return schemaName;
166   }
167
168   /**
169    * Returns the url value.
170    *
171    * @return Returns the url.
172    */

173   public String JavaDoc getUrl()
174   {
175     return url;
176   }
177
178   /**
179    * Returns the virtualDatabaseName value.
180    *
181    * @return Returns the virtualDatabaseName.
182    */

183   public String JavaDoc getVirtualDatabaseName()
184   {
185     return virtualDatabaseName;
186   }
187
188   /**
189    * Returns the gatherSystemTables value.
190    *
191    * @return Returns the gatherSystemTables.
192    */

193   public boolean isGatherSystemTables()
194   {
195     return gatherSystemTables;
196   }
197
198   /**
199    * Set the xml information on that BackendInfo object
200    *
201    * @param xml new XML to set
202    */

203   public void setXml(String JavaDoc xml)
204   {
205     this.xml = null;
206   }
207
208 }
Popular Tags