commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tcu...@apache.org
Subject svn commit: r331842 - /jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/ReloadingClassLoader.java
Date Tue, 08 Nov 2005 16:55:02 GMT
Author: tcurdt
Date: Tue Nov  8 08:54:51 2005
New Revision: 331842

URL: http://svn.apache.org/viewcvs?rev=331842&view=rev
Log:
implemented method (thanks to Mark Proctor)

Modified:
    jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/ReloadingClassLoader.java

Modified: jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/ReloadingClassLoader.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/ReloadingClassLoader.java?rev=331842&r1=331841&r2=331842&view=diff
==============================================================================
--- jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/ReloadingClassLoader.java
(original)
+++ jakarta/commons/sandbox/jci/trunk/src/java/org/apache/commons/jci/ReloadingClassLoader.java
Tue Nov  8 08:54:51 2005
@@ -55,17 +55,56 @@
         pListener.setNotificationListener(null);
     }
     
-    private void addResourceStore(final ResourceStore pStore) {
-        final int n = stores.length;
-        final ResourceStore[] newStores = new ResourceStore[n + 1];
-        System.arraycopy(stores, 0, newStores, 0, n);
-        newStores[n] = pStore;
-        stores = newStores;
-        delegate = new ResourceStoreClassLoader(parent, stores);
+    private boolean addResourceStore(final ResourceStore pStore) {
+        try {        
+            final int n = stores.length;
+            final ResourceStore[] newStores = new ResourceStore[n + 1];
+            System.arraycopy(stores, 0, newStores, 0, n);
+            newStores[n] = pStore;
+            stores = newStores;
+            delegate = new ResourceStoreClassLoader(parent, stores);
+            return true;
+        } catch ( final Exception e ) {
+            // FIXME: rethrow?
+        }
+        return false;
     }
 
-    private void removeResourceStore(final ResourceStore pStore) {
-        //FIXME
+    private boolean removeResourceStore(final ResourceStore pStore) {
+        try {
+            final int n = stores.length;
+            int i = 0;
+                        
+            //find the pStore and index position with var i
+            while ( ( i <= n )  && ( stores[i] != pStore ) ) {
+                i++;
+            }
+            
+            
+            //pStore was not found
+            if ( i == n ) {
+                throw new Exception( "pStore was not found" );
+            }
+            
+            // if stores length > 1 then array copy old values, else create new empty
store 
+            if (n > 1) {            
+                final ResourceStore[] newStores = new ResourceStore[n - 1];
+                
+                System.arraycopy(stores, 0, newStores, 0, i-1);
+                System.arraycopy(stores, i, newStores, i, newStores.length - 1);
+                
+                stores = newStores;
+                delegate = new ResourceStoreClassLoader(parent, stores);
+            } else {
+                stores = new ResourceStore[0];
+            }
+            return true;
+            
+        } catch ( final Exception e ) {
+            // FIXME: re-throw?
+        }
+                
+        return false;
     }
     
     /*



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message