Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (c) 2003, 2007 s IT Solutions AT Spardat GmbH . All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at http://www.eclipse.org/legal/epl-v10.html Contributors: s IT Solutions AT Spardat GmbH - initial API and implementation /
 
 
 /*
  * Created on : 04.2003
  * Created by : s3595
  */
 
 package at.spardat.xma.boot.comp;
 
 import java.io.File;
 import java.net.URL;
 
custom classloader, created for each xma-application ! lazy loading is not supported until now !

Author(s):
s3595 Chris Sch�fer (CGS)
Version:
$Id: CCLoader.java 2115 2007-11-29 16:54:19Z s3460 $
 
 public class CCLoader extends URLClassLoader {
     ArrayList libs;
     ArrayList libPaths;

    
Contructs a CCLoader

Parameters:
classpath containing one URL for each directory or jar-file to search for classes
 
     public CCLoader(URL[] classpath ) {
         super(classpath);
     }

    
Contructs a CCLoader

Parameters:
classpath containing one URL for each directory or jar-file to search for classes
parent the parent class loader to use
 
     public CCLoader(URL[] classpathClassLoader parent ) {
         super(classpathparent );
     }

    
Appends the specified URL to the list of URLs to search for classes and resources.

Parameters:
url the URL to be added to the class path of URLs
 
     public void addURL(URL url) {
         super.addURL(url);
     }

    
Appends the specified URL representing a native library to the list of URLs to search for native libraries.

Parameters:
url the URL to be added to the library path of URLs
 
     public void addNativeLib(URL url) {
         if(==null = new ArrayList();
         .add(url);
     }

    
Appends the specified URL to the list of URLs representing paths to search for native libraries.

Parameters:
url
Author(s):
s3460
Since:
version_number
 
     public void addNativeLibPath(URL url) {
         if(==null = new ArrayList();
         .add(url);
     }

    
Appends the URLs in the specified Collection to the list of URLs to search for native libraries. The collection must contain only valid URLs.

Parameters:
list of URLs to be added to the library path of URLs
 
     public void addNativeLibs(Collection list) {
         if(==null = new ArrayList();
        .addAll(list);
    }

    
Appends the URLs in the specified Collection to the list of URLs reprsenting paths to search for native libraries. The collection must contain only valid URLs.

Parameters:
list of URLs to be added to the library path of URLs
    public void addNativeLibPaths(Collection list) {
        if(==null = new ArrayList();
        .addAll(list);
    }

    
Returns the absolute path name of a native library. The library is searched for in the urls given with addNativeLib(java.net.URL) and addNativeLibs(java.util.Collection). The VM invokes this method to locate the native libraries that belong to classes loaded with this class loader.

Parameters:
libname The library name
Returns:
The absolute path of the native library
    public String findLibrary(String libname) {
        String found = super.findLibrary(libname);
        if(found!=nullreturn found;
        final String libnameFull = System.mapLibraryName(libname);
        //look in full file paths for matching file - return absolute path
        if(!=null) {
            for(Iterator it=.iterator();it.hasNext();) {
                URL url = (URL)it.next();
                String path = url.getPath();
                String filename;
                int last = path.lastIndexOf("/");
                if(last>=0) {
                    if(last<path.length()) filename = path.substring(last+1,path.length());
                    else filename = "";
                } else {
                    filename = path;
                }
                if(VersionNumber.matchWithoutHashPattern(filename).matcher(libnameFull).find()) {
                    return path;
                }
            }
        }
        //look in directory paths for matching file - return absolute path
        if(!=null) {
            for(Iterator it=.iterator();it.hasNext();) {
                URL url = (URL)it.next();
                String path = url.getPath();
                File dir = new File(path);
                File[] files = dir.listFiles(new FilenameFilter(){
                    public boolean accept(File dirString name) {
                        return name.equals(libnameFull);
                    }});
                if(files != null && files.length>0){
                    return files[0].getAbsolutePath();
                }
            }
        }
        return null;
    }
New to GrepCode? Check out our FAQ X