All Downloads are FREE. Search and download functionalities are using the official Maven repository.

utils.sacha.classloader.factory.ClassloaderFactory Maven / Gradle / Ivy

The newest version!
package utils.sacha.classloader.factory;

import utils.sacha.classloader.enrich.EnrichableClassloader;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class ClassloaderFactory {

	public static EnrichableClassloader getEnrichableClassloader(){
		String classPath = System.getProperty("java.class.path");
		List urls = new ArrayList<>();
		for (String classpathElement : splitClassPath(classPath)) {
			try {
				urls.add(new URL("file://"+classpathElement));
			} catch (MalformedURLException e) {
				e.printStackTrace();
			}
		}
		return new EnrichableClassloader(urls.toArray(new URL[0]));
	}

	private static List splitClassPath(String classPath) {
		final String separator = System.getProperty("path.separator");
		return Arrays.asList(classPath.split(separator));
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy