1 /*
2 * (C) 2002 David Carr david@carr.name
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 */
18
19 package net.sourceforge.mflow.impl;
20
21 import java.net.URL;
22 import java.net.URLClassLoader;
23
24 /***
25 * @author carrd
26 */
27 public class PluginClassLoader extends URLClassLoader {
28 /***
29 * Constructs a new empty classloader
30 */
31 PluginClassLoader() {
32 super(new URL[0]);
33 }
34
35 /***
36 * @param urls an array of {@link URL}s to add to the classloader
37 */
38 public final void addURLs(final URL[] urls) {
39 for (int i = 0; i < urls.length; i++) {
40 addURL(urls[i]);
41 }
42 }
43
44 /***
45 * Converts the path to a .class file to a class name
46 *
47 * @param classPath the path to a .class file
48 * @return a full class name, complete with package
49 */
50 public static String classPathToName(final String classPath) {
51 int newLen = classPath.length() - ".class".length();
52 String extensionRemoved = classPath.substring(0, newLen);
53 return extensionRemoved.replace('/', '.');
54 }
55 }
This page was automatically generated by Maven