urls = new URL[] { new File(PLUGIN_DIRECTORY, jarFile.getName()).toURI().toURL() };
classLoader2 = URLClassLoader.newInstance(urls, ClassLoader.getSystemClassLoader());
}
} catch (MalformedURLException exc) {}
} catch (MalformedURLException exc) {
throw new TvBrowserException(getClass(), "error.1",
"Loading Jar file of a plugin failed: {0}.",
jarFile.getAbsolutePath(), exc);
}
// Get the plugin name
String pluginName = jarFile.getName();
if (pluginName.endsWith(".jar")) {
pluginName = pluginName.substring(0, pluginName.length() - 4);
}
boolean isBlockedDataService = false;
// Create a plugin instance
try {
Class pluginClass = classLoader.loadClass(pluginName.toLowerCase() + "." + pluginName);
Method getVersion = pluginClass.getMethod("getVersion",new Class[0]);
Version version1 = null;
try {
version1 = (Version)getVersion.invoke(pluginClass, new Object[0]);
} catch (Exception e) {
}
if (version1 == null || version1.toString().equals("0.0.0.0")) {
mLog.warning("Did not load plugin " + pluginName + ", version is too old.");
return null;
}
if(pluginClass.getSuperclass().equals(devplugin.AbstractTvDataService.class) || classLoader2 != null) {
getVersion = pluginClass.getMethod("getVersion",new Class[0]);
version1 = (Version)getVersion.invoke(pluginClass, new Object[0]);
if(pluginClass.getSuperclass().equals(devplugin.AbstractTvDataService.class)) {
isBlockedDataService = Settings.propBlockedPluginArray.isBlocked(pluginName.toLowerCase() + "." + pluginName, version1);
}
}
if(classLoader2 != null) {
try {
Class pluginClass2 = classLoader2.loadClass(pluginName.toLowerCase() + "." + pluginName);
Method getVersion2 = pluginClass2.getMethod("getVersion",new Class[0]);
Version version2 = (Version)getVersion2.invoke(pluginClass2, new Object[0]);
if(version2.compareTo(version1) > 0) {
return null;
}
}catch(Throwable t) {}
}
try {
Method preInstancing = pluginClass.getMethod("preInstancing",new Class[0]);
preInstancing.invoke(pluginClass,new Object[0]);
}catch(Throwable ti) {}
if(!isBlockedDataService) {
plugin = pluginClass.newInstance();
}
}
catch (Throwable thr) {
throw new TvBrowserException(getClass(), "error.2",
"Could not load plugin {0}.", jarFile.getAbsolutePath(), thr);
}
return plugin;
}