Main Page | Packages | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | Related Pages

VirtualDatabaseStaticMetaData.java

00001 /**
00002  * C-JDBC: Clustered JDBC.
00003  * Copyright (C) 2002-2005 French National Institute For Research In Computer
00004  * Science And Control (INRIA).
00005  * Contact: c-jdbc@objectweb.org
00006  * 
00007  * This library is free software; you can redistribute it and/or modify it
00008  * under the terms of the GNU Lesser General Public License as published by the
00009  * Free Software Foundation; either version 2.1 of the License, or any later
00010  * version.
00011  * 
00012  * This library is distributed in the hope that it will be useful, but WITHOUT
00013  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00014  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
00015  * for more details.
00016  * 
00017  * You should have received a copy of the GNU Lesser General Public License
00018  * along with this library; if not, write to the Free Software Foundation,
00019  * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
00020  *
00021  * Initial developer(s): Nicolas Modrzyk.
00022  * Contributor(s): Emmanuel Cecchet.
00023  */
00024 
00025 package org.objectweb.cjdbc.controller.virtualdatabase;
00026 
00027 import org.objectweb.cjdbc.common.log.Trace;
00028 import org.objectweb.cjdbc.common.sql.metadata.MetadataContainer;
00029 import org.objectweb.cjdbc.controller.backend.DatabaseBackend;
00030 
00031 /**
00032  * Class gathering the static metadata related to the database. We collect
00033  * information from the underlying driver and keep this object for further
00034  * usage.
00035  * 
00036  * @author <a href="mailto:Nicolas.Modrzyk@inria.fr">Nicolas Modrzyk </a>
00037  * @author <a href="mailto:Emmanuel.Cecchet@inria.fr">Emmanuel Cecchet </a>
00038  * @version 1.0
00039  */
00040 public class VirtualDatabaseStaticMetaData
00041 {
00042   private String            vdbName;
00043   private Trace             logger;
00044   private MetadataContainer metadataContainer = null;
00045 
00046   /**
00047    * Reference the database for this metadata. Do not fetch any data at this
00048    * time
00049    * 
00050    * @param database to link this metadata to
00051    */
00052   public VirtualDatabaseStaticMetaData(VirtualDatabase database)
00053   {
00054     this.vdbName = database.getVirtualDatabaseName();
00055     this.logger = Trace
00056         .getLogger("org.objectweb.cjdbc.controller.virtualdatabase.VirtualDatabaseWorkerThread."
00057             + vdbName + ".metadata");
00058   }
00059 
00060   /**
00061    * Save the driver metadata of the backend if this is the first one to be
00062    * collected. If not display a warning for each incompatible value.
00063    * 
00064    * @param backend the new backend to get metadata from
00065    */
00066   public void gatherStaticMetadata(DatabaseBackend backend)
00067   {
00068     MetadataContainer newContainer = backend.getDatabaseStaticMetadata();
00069     if (logger.isDebugEnabled())
00070       logger.debug("fetching static metadata for backend:" + backend.getName());
00071     if (metadataContainer == null)
00072       metadataContainer = newContainer;
00073     else
00074     {
00075       boolean isCompatible = metadataContainer.isCompatible(newContainer,
00076           logger);
00077       if (logger.isDebugEnabled())
00078         logger.debug("Backend static metadata is compatible with current ones:"
00079             + isCompatible);
00080     }
00081   }
00082 
00083   /**
00084    * Returns the metadataContainer value.
00085    * 
00086    * @return Returns the metadataContainer.
00087    */
00088   public MetadataContainer getMetadataContainer()
00089   {
00090     return metadataContainer;
00091   }
00092 }

Generated on Mon Apr 11 22:01:35 2005 for C-JDBC by  doxygen 1.3.9.1