db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject svn commit: r473387 - /db/derby/code/trunk/java/engine/org/apache/derby/impl/services/reflect/UpdateLoader.java
Date Fri, 10 Nov 2006 16:39:21 GMT
Author: djd
Date: Fri Nov 10 08:39:20 2006
New Revision: 473387

URL: http://svn.apache.org/viewvc?view=rev&rev=473387
Log:
DERBY-2040 (partial) Create the class loaders (JarLoader instances) for database class loading
within a privileged block.

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/impl/services/reflect/UpdateLoader.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/services/reflect/UpdateLoader.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/services/reflect/UpdateLoader.java?view=diff&rev=473387&r1=473386&r2=473387
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/services/reflect/UpdateLoader.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/services/reflect/UpdateLoader.java
Fri Nov 10 08:39:20 2006
@@ -40,12 +40,13 @@
 import org.apache.derby.iapi.reference.Property;
 
 import java.io.InputStream;
+import java.security.AccessController;
 
 import org.apache.derby.iapi.reference.MessageId;
 import org.apache.derby.iapi.reference.Module;
 import org.apache.derby.iapi.services.i18n.MessageService;
 
-public class UpdateLoader {
+class UpdateLoader {
 
 	private JarLoader[] jarList;
 	private HeaderPrintWriter vs;
@@ -61,7 +62,7 @@
 	private boolean needReload;
 	private JarReader jarReader;
 
-	public UpdateLoader(String classpath, DatabaseClasses parent, boolean verbose, boolean normalizeToUpper)

+	UpdateLoader(String classpath, DatabaseClasses parent, boolean verbose, boolean normalizeToUpper)

 		throws StandardException {
 
         this.normalizeToUpper = normalizeToUpper;
@@ -81,15 +82,25 @@
 
 	private void initializeFromClassPath(String classpath) throws StandardException {
 
-		String[][] elements = IdUtil.parseDbClassPath(classpath, normalizeToUpper);
+		final String[][] elements = IdUtil.parseDbClassPath(classpath, normalizeToUpper);
 		
-		int jarCount = elements.length;
+		final int jarCount = elements.length;
 		jarList = new JarLoader[jarCount];
 			
-		for (int i = 0; i < jarCount; i++) {
-			jarList[i] = new JarLoader(this, elements[i], vs);
-		}
-
+        if (jarCount != 0) {
+            // Creating class loaders is a restricted operation
+            // so we need to use a privileged block.
+            AccessController.doPrivileged
+            (new java.security.PrivilegedAction(){
+                
+                public Object run(){    
+    		      for (int i = 0; i < jarCount; i++) {
+    			     jarList[i] = new JarLoader(UpdateLoader.this, elements[i], vs);
+    		      }
+                  return null;
+                }
+            });
+        }
 		if (vs != null) {
 			vs.println(MessageService.getTextMessage(MessageId.CM_CLASS_LOADER_START, classpath));
 		}
@@ -103,7 +114,7 @@
 
 		@exception ClassNotFoundException Class can not be found
 	*/
-	public Class loadClass(String className, boolean resolve) 
+	Class loadClass(String className, boolean resolve) 
 		throws ClassNotFoundException {
 
 
@@ -154,7 +165,7 @@
 		}
 	}
 
-	public InputStream getResourceAsStream(String name) {
+	InputStream getResourceAsStream(String name) {
 
 		InputStream is = (myLoader == null) ?
 			ClassLoader.getSystemResourceAsStream(name) :
@@ -201,7 +212,7 @@
 		}
 	}
 
-	public synchronized void modifyClasspath(String classpath)
+	synchronized void modifyClasspath(String classpath)
 		throws StandardException {
 
 		// lock transaction classloader exclusively
@@ -214,7 +225,7 @@
 	}
 
 
-	public synchronized void modifyJar(boolean reload) throws StandardException {
+	synchronized void modifyJar(boolean reload) throws StandardException {
 
 		// lock transaction classloader exclusively
 		lockClassLoader(ShExQual.EX);
@@ -278,7 +289,7 @@
 		return null;
 	}
 
-	public void close() {
+	void close() {
 
 		for (int i = 0; i < jarList.length; i++) {
 			jarList[i].setInvalid(false);
@@ -297,7 +308,7 @@
 		initDone = true;
 	}
 
-	public int getClassLoaderVersion() {
+	int getClassLoaderVersion() {
 		return version;
 	}
 



Mime
View raw message