⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 plugininitializer.java

📁 java 文件下载器。可自定义
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://kpdus.tripod.com/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi space 
// Source File Name:   PluginInitializer.java

package org.gudy.azureus2.pluginsimpl.local;

import com.aelitis.azureus.core.*;
import java.io.*;
import java.lang.reflect.Method;
import java.net.*;
import java.util.*;
import org.gudy.azureus2.core3.download.DownloadManager;
import org.gudy.azureus2.core3.global.GlobalManager;
import org.gudy.azureus2.core3.global.GlobalManagerListener;
import org.gudy.azureus2.core3.internat.MessageText;
import org.gudy.azureus2.core3.logging.*;
import org.gudy.azureus2.core3.util.*;
import org.gudy.azureus2.plugins.*;
import org.gudy.azureus2.pluginsimpl.local.launch.PluginLauncherImpl;
import org.gudy.azureus2.pluginsimpl.local.ui.UIManagerImpl;
import org.gudy.azureus2.pluginsimpl.local.update.UpdateManagerImpl;
import org.gudy.azureus2.pluginsimpl.local.utils.UtilitiesImpl;
import org.gudy.azureus2.update.UpdaterUpdateChecker;
import org.gudy.azureus2.update.UpdaterUtils;

// Referenced classes of package org.gudy.azureus2.pluginsimpl.local:
//			FailedPlugin, PluginInterfaceImpl, PluginManagerImpl, PluginStateImpl

public class PluginInitializer
	implements GlobalManagerListener, AEDiagnosticsEvidenceGenerator
{

	private static final LogIDs LOGID;
	public static final String INTERNAL_PLUGIN_ID = "<internal>";
	private String builtin_plugins[][] = {
		{
			"Start/Stop Rules", "com.aelitis.azureus.plugins.startstoprules.defaultplugin.StartStopRulesDefaultPlugin", "azbpstartstoprules", "", "true", "true"
		}, {
			"Torrent Removal Rules", "com.aelitis.azureus.plugins.removerules.DownloadRemoveRulesPlugin", "azbpremovalrules", "", "true", "false"
		}, {
			"Share Hoster", "com.aelitis.azureus.plugins.sharing.hoster.ShareHosterPlugin", "azbpsharehoster", "ShareHoster", "true", "false"
		}, {
			"Plugin Update Checker", "org.gudy.azureus2.pluginsimpl.update.PluginUpdatePlugin", "azbppluginupdate", "PluginUpdate", "true", "true"
		}, {
			"UPnP", "com.aelitis.azureus.plugins.upnp.UPnPPlugin", "azbpupnp", "UPnP", "true", "false"
		}, {
			"DHT", "com.aelitis.azureus.plugins.dht.DHTPlugin", "azbpdht", "DHT", "true", "false"
		}, {
			"DHT Tracker", "com.aelitis.azureus.plugins.tracker.dht.DHTTrackerPlugin", "azbpdhdtracker", "DHT Tracker", "true", "false"
		}, {
			"Magnet URI Handler", "com.aelitis.azureus.plugins.magnet.MagnetPlugin", "azbpmagnet", "Magnet URI Handler", "true", "false"
		}, {
			"Core Update Checker", "org.gudy.azureus2.update.CoreUpdateChecker", "azbpcoreupdater", "CoreUpdater", "true", "true"
		}, {
			"Core Patch Checker", "org.gudy.azureus2.update.CorePatchChecker", "azbpcorepatcher", "CorePatcher", "true", "true"
		}, {
			"Platform Checker", "org.gudy.azureus2.platform.PlatformManagerPluginDelegate", "azplatform2", "azplatform2", "true", "false"
		}, {
			"External Seed", "com.aelitis.azureus.plugins.extseed.ExternalSeedPlugin", "azextseed", "azextseed", "true", "false"
		}, {
			"Local Tracker", "com.aelitis.azureus.plugins.tracker.local.LocalTrackerPlugin", "azlocaltracker", "azlocaltracker", "true", "false"
		}, {
			"Network Status", "com.aelitis.azureus.plugins.net.netstatus.NetStatusPlugin", "aznetstat", "aznetstat", "true", "false"
		}, {
			"Buddy", "com.aelitis.azureus.plugins.net.buddy.BuddyPlugin", "azbuddy", "azbuddy", "true", "false"
		}
	};
	private static String default_version_details[][] = {
		{
			"org.cneclipse.multiport.MultiPortPlugin", "multi-ports", "Mutli-Port Trackers", "1.0"
		}
	};
	private static PluginInitializer singleton;
	private static AEMonitor class_mon = new AEMonitor("PluginInitializer");
	private static List registration_queue = new ArrayList();
	private static List initThreads = new ArrayList(1);
	private AzureusCoreOperation core_operation;
	private AzureusCore azureus_core;
	private PluginInterfaceImpl default_plugin;
	private PluginManager plugin_manager;
	private ClassLoader root_class_loader;
	private List loaded_pi_list;
	private static boolean loading_builtin;
	private List s_plugins;
	private List s_plugin_interfaces;
	private boolean initialisation_complete;
	private volatile boolean plugins_initialised;

	public static PluginInitializer getSingleton(AzureusCore azureus_core, AzureusCoreOperation core_operation)
	{
		PluginInitializer plugininitializer;
		class_mon.enter();
		if (singleton == null)
			singleton = new PluginInitializer(azureus_core, core_operation);
		plugininitializer = singleton;
		class_mon.exit();
		return plugininitializer;
		Exception exception;
		exception;
		class_mon.exit();
		throw exception;
	}

	protected static void queueRegistration(Class _class)
	{
		class_mon.enter();
		if (singleton == null)
			registration_queue.add(_class);
		else
			try
			{
				singleton.initializePluginFromClass(_class, "<internal>", _class.getName(), false, false, true);
			}
			catch (PluginException e) { }
		class_mon.exit();
		break MISSING_BLOCK_LABEL_63;
		Exception exception;
		exception;
		class_mon.exit();
		throw exception;
	}

	protected static void queueRegistration(Plugin plugin, String id)
	{
		class_mon.enter();
		if (singleton == null)
			registration_queue.add(((Object) (new Object[] {
				plugin, id
			})));
		else
			try
			{
				singleton.initializePluginFromInstance(plugin, id, plugin.getClass().getName());
			}
			catch (Throwable e)
			{
				Debug.out(e);
			}
		class_mon.exit();
		break MISSING_BLOCK_LABEL_77;
		Exception exception;
		exception;
		class_mon.exit();
		throw exception;
	}

	protected static boolean isLoadingBuiltin()
	{
		return loading_builtin;
	}

	public static void checkAzureusVersion(String name, Properties props, boolean alert_on_fail)
		throws PluginException
	{
		String required_version = (String)props.get("plugin.azureus.min_version");
		if (required_version == null)
			return;
		if (Constants.compareVersions("4.2.0.0", required_version) < 0)
		{
			String plugin_name_bit = name.length() <= 0 ? "" : (new StringBuilder()).append(name).append(" ").toString();
			String msg = (new StringBuilder()).append("Plugin ").append(plugin_name_bit).append("requires ").append(Constants.APP_NAME).append(" version ").append(required_version).append(" or higher").toString();
			if (alert_on_fail)
				Logger.log(new LogAlert(true, 3, msg));
			throw new PluginException(msg);
		} else
		{
			return;
		}
	}

	public static void checkJDKVersion(String name, Properties props, boolean alert_on_fail)
		throws PluginException
	{
		String required_jdk = (String)props.get("plugin.jdk.min_version");
		if (required_jdk != null)
		{
			String actual_jdk = System.getProperty("java.version");
			required_jdk = normaliseJDK(required_jdk);
			actual_jdk = normaliseJDK(actual_jdk);
			if (required_jdk.length() == 0 || actual_jdk.length() == 0)
				return;
			if (Constants.compareVersions(actual_jdk, required_jdk) < 0)
			{
				String msg = (new StringBuilder()).append("Plugin ").append(name.length() <= 0 ? "" : (new StringBuilder()).append(name).append(" ").toString()).append("requires Java version ").append(required_jdk).append(" or higher").toString();
				if (alert_on_fail)
					Logger.log(new LogAlert(true, 3, msg));
				throw new PluginException(msg);
			}
		}
	}

	protected static String normaliseJDK(String jdk)
	{
		String str;
		str = "";
		int i = 0;
		do
		{
			if (i >= jdk.length())
				break;
			char c = jdk.charAt(i);
			if (c != '.' && !Character.isDigit(c))
				break;
			str = (new StringBuilder()).append(str).append(c).toString();
			i++;
		} while (true);
		if (Integer.parseInt((new StringBuilder()).append("").append(str.charAt(0)).toString()) > 1)
			str = (new StringBuilder()).append("1.").append(str).toString();
		return str;
		Throwable e;
		e;
		return "";
	}

	protected PluginInitializer(AzureusCore _azureus_core, AzureusCoreOperation _core_operation)
	{
		root_class_loader = getClass().getClassLoader();
		loaded_pi_list = new ArrayList();
		s_plugins = new ArrayList();
		s_plugin_interfaces = new ArrayList();
		azureus_core = _azureus_core;
		AEDiagnostics.addEvidenceGenerator(this);
		azureus_core.addLifecycleListener(new AzureusCoreLifecycleAdapter() {

			final PluginInitializer this$0;

			public void componentCreated(AzureusCore core, AzureusCoreComponent comp)
			{
				if (comp instanceof GlobalManager)
				{
					GlobalManager gm = (GlobalManager)comp;
					gm.addListener(PluginInitializer.this);
				}
			}

			
			{
				this$0 = PluginInitializer.this;
				super();
			}
		});
		core_operation = _core_operation;
		UpdateManagerImpl.getSingleton(azureus_core);
		plugin_manager = PluginManagerImpl.getSingleton(this);
		UpdaterUtils.checkBootstrapPlugins();
	}

	protected void fireCreated(PluginInterfaceImpl pi)
	{
		azureus_core.triggerLifeCycleComponentCreated(pi);
	}

	protected void fireOperational(PluginInterfaceImpl pi, boolean op)
	{
		fireEventSupport(op ? 8 : 9, pi);
	}

	public static void addInitThread()
	{
		synchronized (initThreads)
		{
			if (initThreads.contains(Thread.currentThread()))
				Debug.out("Already added");
			initThreads.add(Thread.currentThread());
		}
	}

	public static void removeInitThread()
	{
		synchronized (initThreads)
		{
			initThreads.remove(Thread.currentThread());
		}
	}

	protected boolean isInitialisationThread()
	{
		List list = initThreads;
		JVM INSTR monitorenter ;
		return initThreads.contains(Thread.currentThread());
		Exception exception;
		exception;
		throw exception;
	}

	public List loadPlugins(AzureusCore core, boolean bSkipAlreadyLoaded, boolean load_external_plugins, boolean loading_for_startup, boolean initialise_plugins)
	{
		List pluginLoaded;
		PluginManagerDefaults def;
		int i;
		if (bSkipAlreadyLoaded)
		{
			List pis;
			synchronized (s_plugin_interfaces)
			{
				pis = new ArrayList(s_plugin_interfaces);
			}
			for (int i = 0; i < pis.size(); i++)
			{
				PluginInterfaceImpl pi = (PluginInterfaceImpl)pis.get(i);
				Plugin p = pi.getPlugin();
				if (p instanceof FailedPlugin)
					unloadPlugin(pi);
			}

		}
		pluginLoaded = new ArrayList();
		PluginManagerImpl.setStartDetails(core);
		getRootClassLoader();
		File user_dir = FileUtil.getUserFile("plugins");
		File app_dir = FileUtil.getApplicationFile("plugins");
		int user_plugins = 0;
		int app_plugins = 0;
		if (user_dir.exists() && user_dir.isDirectory())
			user_plugins = user_dir.listFiles().length;
		if (app_dir.exists() && app_dir.isDirectory())
			app_plugins = app_dir.listFiles().length;
		if (load_external_plugins)
		{
			pluginLoaded.addAll(loadPluginsFromDir(user_dir, 0, user_plugins + app_plugins, bSkipAlreadyLoaded, loading_for_startup, initialise_plugins));
			if (!user_dir.equals(app_dir))
				pluginLoaded.addAll(loadPluginsFromDir(app_dir, user_plugins, user_plugins + app_plugins, bSkipAlreadyLoaded, loading_for_startup, initialise_plugins));
		} else
		if (Logger.isEnabled())
			Logger.log(new LogEvent(LOGID, "Loading of external plugins skipped"));
		if (Logger.isEnabled())
			Logger.log(new LogEvent(LOGID, "Loading built-in plugins"));
		def = PluginManager.getDefaults();
		i = 0;
_L3:
		if (i >= builtin_plugins.length) goto _L2; else goto _L1
_L1:
		if (!def.isDefaultPluginEnabled(builtin_plugins[i][0]))
			break MISSING_BLOCK_LABEL_582;
		if (core_operation != null)
			core_operation.reportCurrentTask((new StringBuilder()).append(MessageText.getString("splash.plugin")).append(builtin_plugins[i][0]).toString());
		loading_builtin = true;
		Class cla = root_class_loader.loadClass(builtin_plugins[i][1]);
		Method load_method = cla.getMethod("load", new Class[] {
			org/gudy/azureus2/plugins/PluginInterface
		});
		load_method.invoke(null, new Object[] {
			getDefaultInterfaceSupport()
		});
		Logger.log(new LogEvent(LOGID, 1, (new StringBuilder()).append("Built-in plugin '").append(builtin_plugins[i][0]).append("' ok").toString()));
		loading_builtin = false;
		continue; /* Loop/switch isn't completed */
		NoSuchMethodException e;
		e;
		loading_builtin = false;
		continue; /* Loop/switch isn't completed */
		e;
		if (builtin_plugins[i][4].equalsIgnoreCase("true"))
		{
			Debug.printStackTrace(e);
			Logger.log(new LogAlert(false, (new StringBuilder()).append("Load of built in plugin '").append(builtin_plugins[i][2]).append("' fails").toString(), e));
		}
		loading_builtin = false;
		continue; /* Loop/switch isn't completed */
		Exception exception1;
		exception1;
		loading_builtin = false;
		throw exception1;
		if (Logger.isEnabled())
			Logger.log(new LogEvent(LOGID, 1, (new StringBuilder()).append("Built-in plugin '").append(builtin_plugins[i][2]).append("' is disabled").toString()));
		i++;
		  goto _L3
_L2:
		if (Logger.isEnabled())
			Logger.log(new LogEvent(LOGID, "Loading dynamically registered plugins"));
		for (i = 0; i < registration_queue.size();)
		{
			Object entry = registration_queue.get(i);
			Class cla;
			String id;
			if (entry instanceof Class)
			{
				cla = (Class)entry;
				id = cla.getName();
			} else
			{

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -