Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
PETALS - PETALS Services Platform. Copyright (c) 2005 EBM Websourcing, http://www.ebmwebsourcing.com/ This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ------------------------------------------------------------------------- $Id: ClassLoaderUtil.java 3:03:53 PM alouis $ -------------------------------------------------------------------------
package org.ow2.petals.component.framework.util;
This class is used to create classloader for JBI components.

Author(s):
alouis - EBM Websourcing
Since:
1.0
public final class ClassLoaderUtil {

    
As all methods of this class are static, no constructor is available.
    private ClassLoaderUtil() {
        // NOP
    }

    
Returns an URL[] table, with all Jar contained in the given directory path.

Parameters:
directoryName directory containing the Jars
Returns:
an URL[] table
    public static URL[] getUrls(final String directoryName) {
        final File path = new File(directoryName);
        final FileFilter jarFileFilter = new FileFilter() {
            public boolean accept(final File pathname) {
                return pathname.getName().toLowerCase().endsWith(".jar");
            }
        };
        final File[] files = path.listFiles(jarFileFilter);
        final ArrayList<URLurls = new ArrayList<URL>();
        if (files != null && files.length > 0) {
            for (File file : files) {
                try {
                    urls.add(file.toURI().toURL());
                } catch (final MalformedURLException e) {
                    // nothing
                }
            }
        }
        return urls.toArray(new URL[] {});
    }

    
Return an URLClassLoader object, with all Jar contained in the given directory path.

Parameters:
rootPath directory containing the Jars
parent the parent classloader to use
Returns:
a classLoader
    public static URLClassLoader createClassLoader(final String rootPathfinal ClassLoader parent) {
        return new URLClassLoader(getUrls(rootPath), parent);
    }
New to GrepCode? Check out our FAQ X