<commit_before>package com.github.davidcarboni.restolino.reload.classes;

import java.io.IOException;
import java.net.URL;
import java.net.URLClassLoader;
import java.nio.file.FileSystems;
import java.nio.file.Path;

import org.apache.commons.lang3.StringUtils;

import com.github.davidcarboni.restolino.servlet.ApiServlet;

public class ClassMonitor {

	public static URL url;
	public static URL[] urls;
	static Path path;
	static ClassLoader parent;
	public static volatile ClassLoader classLoader;

	public static void start(String path, ClassLoader parent)
			throws IOException {

		if (StringUtils.isNotBlank(path)) {
			ClassMonitor.parent = parent;
			ClassMonitor.path = FileSystems.getDefault().getPath(path);
			ClassMonitor.url = ClassMonitor.path.toUri().toURL();
			ClassMonitor.urls = new URL[] { url };
			Scanner.start(ClassMonitor.path);
		}
	}

	public static void reload() {
		ClassLoader classLoader;
		try {
			classLoader = new URLClassLoader(urls, parent);
			if (classLoader != null) {
				System.out.println("New class loader created for path " + path);
				ClassMonitor.classLoader = classLoader;
				ApiServlet.setup(classLoader);
			} else
				System.out.println("Class loader not created for path " + path);
		} catch (Exception e) {
			System.out.println("Error reloading classes.");
			e.printStackTrace();
		}
	}

	// public static void main(String[] args) throws IOException,
	// InterruptedException, ClassNotFoundException,
	// IllegalAccessException, IllegalArgumentException,
	// InvocationTargetException, NoSuchMethodException,
	// SecurityException, InstantiationException {
	//
	// // The path:
	// Path folder = Paths.get("./target/classes");
	// System.out.println(folder.toUri().normalize().toURL());
	//
	// start(folder.toString(), ClassMonitor.class.getClassLoader());
	//
	// ClassLoader previous = null;
	// while (true) {
	// Thread.sleep(1000);
	// if (classLoader != previous) {
	// previous = classLoader;
	// System.out
	// .println(" --- Attempting to access reloaded classes...");
	// Class<?> type = Class.forName(
	// "com.github.davidcarboni.jload.ClassMonitor", true,
	// classLoader);
	// System.out.println(" --- ");
	// type.getMethod("thing").invoke(type.newInstance());
	// }
	// }
	// }

}
<commit_msg>Cleanup.<commit_after>package com.github.davidcarboni.restolino.reload.classes;

import java.io.IOException;
import java.net.URL;
import java.nio.file.FileSystems;
import java.nio.file.Path;

import javax.servlet.ServletException;

import org.apache.commons.lang3.StringUtils;

import com.github.davidcarboni.restolino.servlet.ApiServlet;

public class ClassMonitor {

	public static URL url;
	public static URL[] urls;
	static Path path;

	public static void start(String path, ClassLoader parent)
			throws IOException {

		if (StringUtils.isNotBlank(path)) {
			ClassMonitor.path = FileSystems.getDefault().getPath(path);
			ClassMonitor.url = ClassMonitor.path.toUri().toURL();
			ClassMonitor.urls = new URL[] { url };
			Scanner.start(ClassMonitor.path);
		}
	}

	public static void reload() {
		ClassLoader classLoader;
		try {
			classLoader = new WinkyClassLoader(urls,
					ClassMonitor.class.getClassLoader());
			System.out.println("New class loader created for path " + path);
			ApiServlet.setup(classLoader);
		} catch (ServletException e) {
			System.out.println("Error reloading classes.");
			e.printStackTrace();
		}
	}

	// public static void main(String[] args) throws IOException,
	// InterruptedException, ClassNotFoundException,
	// IllegalAccessException, IllegalArgumentException,
	// InvocationTargetException, NoSuchMethodException,
	// SecurityException, InstantiationException {
	//
	// // The path:
	// Path folder = Paths.get("./target/classes");
	// System.out.println(folder.toUri().normalize().toURL());
	//
	// start(folder.toString(), ClassMonitor.class.getClassLoader());
	//
	// ClassLoader previous = null;
	// while (true) {
	// Thread.sleep(1000);
	// if (classLoader != previous) {
	// previous = classLoader;
	// System.out
	// .println(" --- Attempting to access reloaded classes...");
	// Class<?> type = Class.forName(
	// "com.github.davidcarboni.jload.ClassMonitor", true,
	// classLoader);
	// System.out.println(" --- ");
	// type.getMethod("thing").invoke(type.newInstance());
	// }
	// }
	// }

}

{'fraction_non_alphanumeric': 0.14609863394304237, 'fraction_numerical': 0.0023153507756425097, 'mean_word_length': 3.9146757679180886, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3113150', 'n_tokens_mistral': 1408, 'n_tokens_neox': 1319, 'n_words': 273}