-ProjectClassLoader

package org.seasar.kijimuna.core.loader;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.jdt.core.IClasspathEntry;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.JavaModelException;
/**
 * @author Masataka Kurihara (Gluegent, Inc.)
 */
public class ProjectClassLoader extends URLClassLoader {
    private String errorURL;
    public ProjectClassLoader(IJavaProject project) {
        super(new URL[0]);
        getClassPaths(project);
    }
    private void getClassPaths(IJavaProject project) {
         if(project == null) {
            throw new NullPointerException();
        }
        List errorList = new ArrayList(); 
        try {
            IClasspathEntry entries = project.getResolvedClasspath(true);
            for(int i = 0; i < entries.length; i++) {
                int kind = entries[i].getEntryKind();
                String url = null;
                if(kind == IClasspathEntry.CPE_SOURCE) {
                    try {
                        url = "file:///" + entries[i].getOutputLocation().toString();
                    } catch (RuntimeException e1) {
                        continue;
                    }
                } else {
                    url = "jar:file:///" + entries[i].getPath().toString() + "!/";
                }
                try {
                    addURL(new URL(url));
                } catch (MalformedURLException e) {
                    errorList.add(url);
                }
            }
        } catch (JavaModelException e) {
            throw new RuntimeException(e);
        }
    }
    public String[] getErrorPath() {
        if(errorURL == null) {
            return new String[0];
        } else {
            return errorURL;
        }
    }
}