You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by bu...@apache.org on 2005/11/08 08:24:16 UTC

DO NOT REPLY [Bug 37390] New: - [jci] implement removeResourceStore

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=37390>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=37390

           Summary: [jci] implement removeResourceStore
           Product: Commons
           Version: unspecified
          Platform: Other
        OS/Version: other
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Sandbox
        AssignedTo: commons-dev@jakarta.apache.org
        ReportedBy: mproctor@codehaus.org


private boolean addResourceStore(final ResourceStore pStore) {
        boolean success = true;
        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);
        } catch ( Exception e ) {
            success = false;  
        }
        return success;
    }

    private boolean removeResourceStore(final ResourceStore pStore) {
        boolean success = true;
        
        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];
            }
            
        } catch ( Exception e ) {
            success = false;
        }
                
        return success;
    }

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

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