KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > cjdbc > controller > virtualdatabase > VirtualDatabaseStaticMetaData


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.controller.virtualdatabase;
26
27 import org.objectweb.cjdbc.common.log.Trace;
28 import org.objectweb.cjdbc.common.sql.metadata.MetadataContainer;
29 import org.objectweb.cjdbc.controller.backend.DatabaseBackend;
30
31 /**
32  * Class gathering the static metadata related to the database. We collect
33  * information from the underlying driver and keep this object for further
34  * usage.
35  *
36  * @author <a HREF="mailto:Nicolas.Modrzyk@inria.fr">Nicolas Modrzyk </a>
37  * @author <a HREF="mailto:Emmanuel.Cecchet@inria.fr">Emmanuel Cecchet </a>
38  * @version 1.0
39  */

40 public class VirtualDatabaseStaticMetaData
41 {
42   private String JavaDoc vdbName;
43   private Trace logger;
44   private MetadataContainer metadataContainer = null;
45
46   /**
47    * Reference the database for this metadata. Do not fetch any data at this
48    * time
49    *
50    * @param database to link this metadata to
51    */

52   public VirtualDatabaseStaticMetaData(VirtualDatabase database)
53   {
54     this.vdbName = database.getVirtualDatabaseName();
55     this.logger = Trace
56         .getLogger("org.objectweb.cjdbc.controller.virtualdatabase.VirtualDatabaseWorkerThread."
57             + vdbName + ".metadata");
58   }
59
60   /**
61    * Save the driver metadata of the backend if this is the first one to be
62    * collected. If not display a warning for each incompatible value.
63    *
64    * @param backend the new backend to get metadata from
65    */

66   public void gatherStaticMetadata(DatabaseBackend backend)
67   {
68     MetadataContainer newContainer = backend.getDatabaseStaticMetadata();
69     if (logger.isDebugEnabled())
70       logger.debug("fetching static metadata for backend:" + backend.getName());
71     if (metadataContainer == null)
72       metadataContainer = newContainer;
73     else
74     {
75       boolean isCompatible = metadataContainer.isCompatible(newContainer,
76           logger);
77       if (logger.isDebugEnabled())
78         logger.debug("Backend static metadata is compatible with current ones:"
79             + isCompatible);
80     }
81   }
82
83   /**
84    * Returns the ("getXXX(Y,Z,...)", value) hash table holding metadata queries.
85    *
86    * @return Returns the metadataContainer.
87    */

88   public MetadataContainer getMetadataContainer()
89   {
90     return metadataContainer;
91   }
92 }
Popular Tags