db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject svn commit: r484841 - in /db/derby/code/trunk/java/engine/org/apache/derby: iapi/db/ iapi/store/access/ impl/db/ impl/sql/catalog/ impl/sql/conn/ impl/sql/depend/
Date Fri, 08 Dec 2006 23:23:50 GMT
Author: djd
Date: Fri Dec  8 15:23:46 2006
New Revision: 484841

URL: http://svn.apache.org/viewvc?view=rev&rev=484841
Log:
DERBY-2138 (partial) Move the booting of the DataDictionary to BasicDatabase from LanguageConnectionFactory
wihc makes more sense once there is a single dictionary per database. Change some calls to
obtain a reference
to the DataDictionary from Database instead of looking for the pushed DataDictionaryContext.
DataDictionaryContext context is still pushed, this is an incremental step to removing it.

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/db/Database.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/store/access/FileResource.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/db/BasicDatabase.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/DataDictionaryImpl.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/conn/GenericLanguageConnectionContext.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/conn/GenericLanguageConnectionFactory.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/depend/BasicDependencyManager.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/db/Database.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/db/Database.java?view=diff&rev=484841&r1=484840&r2=484841
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/db/Database.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/db/Database.java Fri Dec  8 15:23:46
2006
@@ -25,6 +25,7 @@
 import org.apache.derby.iapi.error.StandardException;
 import org.apache.derby.iapi.sql.ResultSet;
 import org.apache.derby.iapi.sql.conn.LanguageConnectionContext;
+import org.apache.derby.iapi.sql.dictionary.DataDictionary;
 import org.apache.derby.iapi.jdbc.AuthenticationService;
 import org.apache.derby.iapi.services.i18n.LocaleFinder;
 import java.io.InputStream;
@@ -119,4 +120,10 @@
 
 	/** Set the Locale that is returned by this LocaleFinder */
 	public	void	setLocale(Locale locale);
+    
+    /**
+     * Return the DataDictionary for this database, set up at boot time.
+     */
+    public DataDictionary getDataDictionary();
+
 }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/store/access/FileResource.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/store/access/FileResource.java?view=diff&rev=484841&r1=484840&r2=484841
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/store/access/FileResource.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/store/access/FileResource.java Fri
Dec  8 15:23:46 2006
@@ -24,8 +24,6 @@
 import org.apache.derby.iapi.error.StandardException;
 import org.apache.derby.io.StorageFile;
 
-import java.io.FileNotFoundException;
-import java.io.IOException;
 import java.io.InputStream;
 
 /**

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/db/BasicDatabase.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/db/BasicDatabase.java?view=diff&rev=484841&r1=484840&r2=484841
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/db/BasicDatabase.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/db/BasicDatabase.java Fri Dec  8
15:23:46 2006
@@ -115,6 +115,11 @@
 	protected AccessFactory af;
 	protected PropertyFactory pf;
 	protected ClassFactory cfDB; // classFactory but only set when per-database
+    /**
+     * DataDictionary for this database.
+     */
+    private DataDictionary dd;
+    
 	protected LanguageConnectionFactory lcf;
 	protected LanguageFactory lf;
 	// hold resourceAdapter in an Object instead of a ResourceAdapter
@@ -191,6 +196,10 @@
 			// Boot the ClassFactory, will be per-database or per-system.
 			// reget the tc in case someone inadverdently destroyed it 
 		bootClassFactory(create, allParams);
+        
+        dd = (DataDictionary)
+            Monitor.bootServiceModule(create, this,
+                    DataDictionary.MODULE, startParams);
 
 		lcf = (LanguageConnectionFactory) Monitor.bootServiceModule(create, this, LanguageConnectionFactory.MODULE,
allParams);
 		lf = (LanguageFactory) Monitor.bootServiceModule(create, this, LanguageFactory.MODULE,
allParams);
@@ -287,6 +296,14 @@
 		return lctx;
 
 	}
+    
+    /**
+     * Return the DataDictionary for this database, set up at boot time.
+     */
+    public final DataDictionary getDataDictionary()
+    {
+        return dd;
+    }
 
 	public void pushDbContext(ContextManager cm)
 	{
@@ -615,12 +632,6 @@
 			dbcp = IdUtil.parseDbClassPath(newClasspath, normalizeToUpper);
 		}
 
-		DataDictionaryContext ddc =
-			(DataDictionaryContext)ContextService.getContext(DataDictionaryContext.CONTEXT_ID);
-		if (SanityManager.DEBUG)
-			if (ddc == null) SanityManager.THROWASSERT("Class path change with no connection");
-		DataDictionary dd = ddc.getDataDictionary();
-
 		//
 		//Verify that all jar files on the database classpath are in the data dictionary.
 		if (dbcp != null)
@@ -654,15 +665,10 @@
 		// only do the change dynamically if we are already
 		// a per-database classapath.
 		if (cfDB != null) {
-			DataDictionaryContext ddc =
-				(DataDictionaryContext)ContextService.getContext(DataDictionaryContext.CONTEXT_ID);
-			if (SanityManager.DEBUG)
-				if (ddc == null) SanityManager.THROWASSERT("Class path change with no connection");
-			DataDictionary dd = ddc.getDataDictionary();
 
 			//
 			// Invalidate stored plans.
-			dd.invalidateAllSPSPlans();
+            getDataDictionary().invalidateAllSPSPlans();
 		
 			String newClasspath = (String) value;
 			if (newClasspath == null) newClasspath = "";
@@ -789,7 +795,7 @@
 
 		DataDictionaryContext ddc =
 			(DataDictionaryContext) ContextService.getContext(DataDictionaryContext.CONTEXT_ID);
-		DataDictionary dd = ddc.getDataDictionary();
+		DataDictionary dd = getDataDictionary();
 
 		SchemaDescriptor sd = dd.getSchemaDescriptor(schemaName, null, true);
 		FileInfoDescriptor fid = dd.getFileInfoDescriptor(sd,sqlName);

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/DataDictionaryImpl.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/DataDictionaryImpl.java?view=diff&rev=484841&r1=484840&r2=484841
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/DataDictionaryImpl.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/DataDictionaryImpl.java
Fri Dec  8 15:23:46 2006
@@ -757,7 +757,7 @@
 	 */
 	protected void setDependencyManager()
 	{
-		dmgr = new BasicDependencyManager();
+		dmgr = new BasicDependencyManager(this);
 	}
 
 	/**

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/conn/GenericLanguageConnectionContext.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/conn/GenericLanguageConnectionContext.java?view=diff&rev=484841&r1=484840&r2=484841
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/conn/GenericLanguageConnectionContext.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/conn/GenericLanguageConnectionContext.java
Fri Dec  8 15:23:46 2006
@@ -52,7 +52,6 @@
 import org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptor;
 import org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptorList;
 import org.apache.derby.iapi.sql.dictionary.DataDictionary;
-import org.apache.derby.iapi.sql.dictionary.DataDictionaryContext;
 import org.apache.derby.iapi.sql.dictionary.SchemaDescriptor;
 import	org.apache.derby.iapi.sql.dictionary.TableDescriptor;
 import org.apache.derby.iapi.types.DataValueFactory;
@@ -2843,17 +2842,7 @@
 
 	public DataDictionary getDataDictionary()
 	{
-		DataDictionaryContext ddc =
-			(DataDictionaryContext) getContextManager().getContext(DataDictionaryContext.CONTEXT_ID);
-
-		if (ddc != null)
-		{
-			return ddc.getDataDictionary();
-		}
-		else 
-		{
-			return null;
-		}
+        return getDatabase().getDataDictionary();
 	}
 
 	/**

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/conn/GenericLanguageConnectionFactory.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/conn/GenericLanguageConnectionFactory.java?view=diff&rev=484841&r1=484840&r2=484841
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/conn/GenericLanguageConnectionFactory.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/conn/GenericLanguageConnectionFactory.java
Fri Dec  8 15:23:46 2006
@@ -102,7 +102,6 @@
 	/*
 		fields
 	 */
-	protected 	DataDictionary	dd;
 	private 	ExecutionFactory		ef;
 	private 	OptimizerFactory		of;
 	private		TypeCompilerFactory		tcf;
@@ -170,7 +169,7 @@
 		String drdaID,
 		String dbname) throws StandardException {
 		
-		pushDataDictionaryContext(cm);
+		db.getDataDictionary().pushDataDictionaryContext(cm);
 
 		return new GenericLanguageConnectionContext(cm,
 													tc,
@@ -263,11 +262,6 @@
 		return dvf;
 	}
 
-	protected void pushDataDictionaryContext(ContextManager cm) {
-		// we make sure there is a data dictionary context in place.
-		dd.pushDataDictionaryContext(cm);
-	}
-
 	/*
 		ModuleControl interface
 	 */
@@ -319,8 +313,6 @@
 		if (classFactory == null)
  			classFactory = (ClassFactory) Monitor.findSystemModule(org.apache.derby.iapi.reference.Module.ClassFactory);
 
-		bootDataDictionary(create, startParams);
-
 		//set the property validation module needed to do propertySetCallBack
 		//register and property validation
 		setValidation();
@@ -341,10 +333,6 @@
 												cacheSize);
 		}
 
-	}
-
-	protected void bootDataDictionary(boolean create, Properties startParams) throws StandardException
{
-		dd = (DataDictionary) Monitor.bootServiceModule(create, this, DataDictionary.MODULE, startParams);
 	}
 
 	/**

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/depend/BasicDependencyManager.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/depend/BasicDependencyManager.java?view=diff&rev=484841&r1=484840&r2=484841
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/depend/BasicDependencyManager.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/depend/BasicDependencyManager.java
Fri Dec  8 15:23:46 2006
@@ -48,7 +48,6 @@
 
 import org.apache.derby.iapi.sql.dictionary.DataDescriptorGenerator;
 import org.apache.derby.iapi.sql.dictionary.DataDictionary;
-import org.apache.derby.iapi.sql.dictionary.DataDictionaryContext;
 import org.apache.derby.iapi.sql.dictionary.DependencyDescriptor;
 import org.apache.derby.iapi.sql.dictionary.TableDescriptor;
 import org.apache.derby.iapi.sql.dictionary.ViewDescriptor;
@@ -75,6 +74,11 @@
  */
 
 public class BasicDependencyManager implements DependencyManager {
+  
+    /**
+     * DataDictionary for this database.
+     */
+    private final DataDictionary dd;
 
 	//
 	// DependencyManager interface
@@ -149,7 +153,6 @@
 			{
 				/* Add a stored dependency */
 				LanguageConnectionContext	lcc = getLanguageConnectionContext(cm);
-				DataDictionary				dd = getDataDictionary();
 				DependencyDescriptor		dependencyDescriptor;
 				boolean wait = (tc == null);
 			
@@ -181,8 +184,6 @@
 			}
 		}
 
-		DataDictionary				dd = getDataDictionary();
-		
 		DependencyDescriptor dependencyDescriptor = new DependencyDescriptor(d, p);
 
 		dd.dropStoredDependency( dependencyDescriptor, 
@@ -300,7 +301,6 @@
 						if (dep instanceof ViewDescriptor)
 						{
 							ViewDescriptor vd = (ViewDescriptor) dep;
-							DataDictionary dd = getDataDictionary();
 							SchemaDescriptor compSchema;
 							compSchema = dd.getSchemaDescriptor(vd.getCompSchemaId(), null);
 							CompilerContext newCC = lcc.pushCompilerContext(compSchema);
@@ -443,7 +443,6 @@
 			/* Remove all the stored dependencies */
 			if (d.isPersistent())
 			{
-				DataDictionary			  dd = getDataDictionary();
 				boolean wait = (tc == null);
 				
 				dd.dropDependentsStoredDependencies(d.getObjectID(),
@@ -900,8 +899,7 @@
 			int numDependencies = 0;
 			Enumeration deps = dependents.elements();
 			Enumeration provs = providers.elements();
-			List storedDeps = getDataDictionary().
-									getAllDependencyDescriptorsList();
+			List storedDeps = dd.getAllDependencyDescriptorsList();
 
 			/* Count the in memory dependencies */
 			while (deps.hasMoreElements())
@@ -1038,8 +1036,7 @@
 				   ordering problems in canons. Also the dependencyDescriptor.getUUID()
 				   in this list is not unique, hence the sort on the output string values instead
 				*/
-				List storedDeps =
-							getDataDictionary().getAllDependencyDescriptorsList();
+				List storedDeps = dd.getAllDependencyDescriptorsList();
 
 				String[] dependStr = new String[storedDeps.size()];
 
@@ -1095,7 +1092,8 @@
 	//
 	// class interface
 	//
-	public BasicDependencyManager() {
+	public BasicDependencyManager(DataDictionary dd) {
+        this.dd = dd;
 	}
 
 	//
@@ -1237,39 +1235,6 @@
 	}
 
 	/**
-	 * Returns the DataDictionary to use.
-	 *
-	 * @return DataDictionary	The DataDictionary to use.
-	 */
-	private DataDictionary getDataDictionary()
-	{
-		if (dataDictionary == null)
-		{
-			DataDictionaryContext	  ddc;
-			
-			ddc = (DataDictionaryContext)
-						(ContextService.getContext(DataDictionaryContext.CONTEXT_ID));
-
-
-			dataDictionary = ddc.getDataDictionary();
-		}
-
-		return dataDictionary;
-	}
-
-	/**
-	 * Returns the LanguageConnectionContext to use.
-	 *
-	 * @return LanguageConnectionContext	The LanguageConnectionContext to use.
-	 */
-	private LanguageConnectionContext getLanguageConnectionContext()
-	{
-		// find the language context.
-		return (LanguageConnectionContext) 
-				ContextService.getContext(LanguageConnectionContext.CONTEXT_ID);
-	}
-
-	/**
 	 * Returns the LanguageConnectionContext to use.
 	 *
 	 * @param cm	Current ContextManager
@@ -1347,8 +1312,7 @@
 		 	* list before returning
 		 	*/
 			List storedList = getDependencyDescriptorList(
-							getDataDictionary().
-								getDependentsDescriptorList(
+								dd.getDependentsDescriptorList(
 												d.getObjectID().toString()
 															),
 								(Provider) null
@@ -1400,8 +1364,7 @@
 		 	* list before returning
 		 	*/
 			List storedList = getDependencyDescriptorList(
-							getDataDictionary().
-								getProvidersDescriptorList(
+								dd.getProvidersDescriptorList(
 												p.getObjectID().toString()
 															),
 							p



Mime
View raw message