KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > continuent > sequoia > controller > virtualdatabase > VirtualDatabaseStaticMetaData


1 /**
2  * Sequoia: Database clustering technology.
3  * Copyright (C) 2002-2004 French National Institute For Research In Computer
4  * Science And Control (INRIA).
5  * Copyright (C) 2005 AmicoSoft, Inc. dba Emic Networks
6  * Contact: sequoia@continuent.org
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  *
20  * Initial developer(s): Nicolas Modrzyk.
21  * Contributor(s): Emmanuel Cecchet.
22  */

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

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

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

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

87   public MetadataContainer getMetadataContainer()
88   {
89     return metadataContainer;
90   }
91
92   /**
93    * Sets the ("getXXX(Y,Z,...)", value) hash table holding metadata queries.
94    *
95    * @param container the metadata container.
96    */

97   public void setMetadataContainer(MetadataContainer container)
98   {
99     this.metadataContainer = container;
100   }
101 }
Popular Tags