/*
* Copyright (C) 2014 Vinu K.N
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.domainmath.gui.etc;
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
import org.domainmath.gui.MainFrame;
/**
*
* @author Vinu K.N
*/
public class ModuleLoader {
private URLClassLoader moduleLoader;
private final File moduleFile = new File(System.getProperty("user.dir")+File.separator+"etc"+File.separator+"UpdateChecker.jar");
public ModuleInterface load(MainFrame frame,boolean displayError){
ModuleInterface module = null;
try {
moduleLoader = URLClassLoader.newInstance(new URL[] { moduleFile.toURI().toURL() });
module = (ModuleInterface) moduleLoader.loadClass("org.domainmath.gui.etc.Module").newInstance();
module.connect(frame,displayError);
return module;
} catch (ClassNotFoundException | MalformedURLException | InstantiationException | IllegalAccessException ex) {
}
return module;
}
}