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

📄 pluginsingleinstancehandler.java

📁 java 文件下载器。可自定义
💻 JAVA
字号:
// 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:   PluginSingleInstanceHandler.java

package org.gudy.azureus2.pluginsimpl.local.launch;

import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.net.*;
import org.gudy.azureus2.core3.util.SystemProperties;
import org.gudy.azureus2.plugins.PluginManagerArgumentHandler;
import org.gudy.azureus2.plugins.logging.LoggerChannelListener;

public class PluginSingleInstanceHandler
{

	private static boolean active;
	private static int port;
	private static PluginManagerArgumentHandler handler;

	public PluginSingleInstanceHandler()
	{
	}

	public static void initialise(int _port, PluginManagerArgumentHandler _handler)
	{
		port = _port;
		handler = _handler;
		String multi_instance = System.getProperty("MULTI_INSTANCE");
		if (multi_instance != null && multi_instance.equalsIgnoreCase("true"))
		{
			return;
		} else
		{
			active = true;
			return;
		}
	}

	protected static boolean process(LoggerChannelListener log, String args[])
	{
		if (active)
		{
			if (startListener(log))
			{
				return false;
			} else
			{
				sendArguments(log, args);
				return true;
			}
		} else
		{
			return false;
		}
	}

	protected static boolean startListener(LoggerChannelListener log)
	{
		ServerSocket server_socket = new ServerSocket(port, 50, InetAddress.getByName("127.0.0.1"));
		log.messageLogged(1, (new StringBuilder()).append("SingleInstanceHandler: listening on 127.0.0.1:").append(port).append(" for passed arguments").toString());
		Thread t = new Thread("Single Instance Handler", server_socket, log) {

			final ServerSocket val$server_socket;
			final LoggerChannelListener val$log;

			public void run()
			{
_L2:
				Socket socket;
				ObjectInputStream ois;
				socket = null;
				ois = null;
				socket = server_socket.accept();
				String address = socket.getInetAddress().getHostAddress();
				if (address.equals("localhost") || address.equals("127.0.0.1"))
					break MISSING_BLOCK_LABEL_71;
				socket.close();
				if (ois != null)
					try
					{
						ois.close();
					}
					catch (Throwable e) { }
				if (socket != null)
					try
					{
						socket.close();
					}
					catch (Throwable e) { }
				continue; /* Loop/switch isn't completed */
				ois = new ObjectInputStream(socket.getInputStream());
				ois.readInt();
				String header = (String)ois.readObject();
				if (header.equals(PluginSingleInstanceHandler.getHeader()))
					break MISSING_BLOCK_LABEL_167;
				log.messageLogged(3, (new StringBuilder()).append("SingleInstanceHandler: invalid header - ").append(header).toString());
				if (ois != null)
					try
					{
						ois.close();
					}
					catch (Throwable e) { }
				if (socket != null)
					try
					{
						socket.close();
					}
					catch (Throwable e) { }
				continue; /* Loop/switch isn't completed */
				String args[] = (String[])(String[])ois.readObject();
				PluginSingleInstanceHandler.handler.processArguments(args);
				Throwable e;
				if (ois != null)
					try
					{
						ois.close();
					}
					// Misplaced declaration of an exception variable
					catch (Throwable e) { }
				if (socket != null)
					try
					{
						socket.close();
					}
					// Misplaced declaration of an exception variable
					catch (Throwable e) { }
				continue; /* Loop/switch isn't completed */
				e;
				log.messageLogged("SingleInstanceHandler: receive error", e);
				if (ois != null)
					try
					{
						ois.close();
					}
					// Misplaced declaration of an exception variable
					catch (Throwable e) { }
				if (socket != null)
					try
					{
						socket.close();
					}
					// Misplaced declaration of an exception variable
					catch (Throwable e) { }
				if (true) goto _L2; else goto _L1
_L1:
				Exception exception;
				exception;
				if (ois != null)
					try
					{
						ois.close();
					}
					catch (Throwable e) { }
				if (socket != null)
					try
					{
						socket.close();
					}
					catch (Throwable e) { }
				throw exception;
			}

			
			{
				server_socket = serversocket;
				log = loggerchannellistener;
				super(x0);
			}
		};
		t.setDaemon(true);
		t.start();
		return true;
		Throwable e;
		e;
		return false;
	}

	protected static void sendArguments(LoggerChannelListener log, String args[])
	{
		Socket socket = null;
		socket = new Socket("127.0.0.1", port);
		ObjectOutputStream oos = new ObjectOutputStream(socket.getOutputStream());
		oos.writeInt(0);
		oos.writeObject(getHeader());
		oos.writeObject(args);
		log.messageLogged(1, "SingleInstanceHandler: arguments passed to existing process");
		Throwable e;
		if (socket != null)
			try
			{
				socket.close();
			}
			// Misplaced declaration of an exception variable
			catch (Throwable e) { }
		break MISSING_BLOCK_LABEL_111;
		e;
		log.messageLogged("SingleInstanceHandler: send error", e);
		if (socket != null)
			try
			{
				socket.close();
			}
			// Misplaced declaration of an exception variable
			catch (Throwable e) { }
		break MISSING_BLOCK_LABEL_111;
		Exception exception;
		exception;
		if (socket != null)
			try
			{
				socket.close();
			}
			catch (Throwable e) { }
		throw exception;
	}

	protected static String getHeader()
	{
		return (new StringBuilder()).append(SystemProperties.getApplicationName()).append(" Single Instance Handler").toString();
	}

}

⌨️ 快捷键说明

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