1
package org.herac.tuxguitar.util;
4
import java.net.MalformedURLException;
6
import java.net.URLClassLoader;
8
public class TGClassLoader{
10
private static TGClassLoader instance;
12
private URLClassLoaderImpl classLoader;
14
private TGClassLoader(){
15
this.classLoader = new URLClassLoaderImpl();
18
public static TGClassLoader instance(){
20
instance = new TGClassLoader();
25
public ClassLoader getClassLoader(){
26
return this.classLoader;
29
public Object newInstance(String loadClassName){
32
object = getClassLoader().loadClass(loadClassName).newInstance();
33
} catch (InstantiationException e) {
35
} catch (IllegalAccessException e) {
37
} catch (ClassNotFoundException e) {
43
public void addPath(String path){
45
this.classLoader.addURL(new File(path).toURI().toURL());
46
} catch (MalformedURLException e) {
51
public void addPaths(File folder){
52
if(folder != null && folder.exists() && folder.isDirectory()){
53
String[] files = folder.list();
54
for(int i = 0;i < files.length;i++){
56
this.addPath( (folder.getAbsolutePath() + File.separator + files[i]) );
57
} catch (Throwable throwable) {
58
throwable.printStackTrace();
64
private class URLClassLoaderImpl extends URLClassLoader{
66
public URLClassLoaderImpl(){
67
super(new URL[]{},TGClassLoader.class.getClassLoader());
70
public void addURL(URL url){
b'\\ No newline at end of file'