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

📄 chatserver_simple.jad

📁 《透视Java》的源码
💻 JAD
字号:
// Decompiled by Jad v1.5.7g. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) 
// Source File Name:   d.java

package covertjava.chat;

import java.io.PrintStream;
import java.net.InetAddress;
import java.rmi.Naming;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import java.rmi.server.UnicastRemoteObject;

// Referenced classes of package covertjava.chat:
//            b, MessageInfo, c

public class d extends UnicastRemoteObject
    implements b
{

    protected d()
        throws Exception
    {
        b = 1149;
    }

    public static d a()
        throws Exception
    {
        if(a == null)
            a = new d();
        return a;
    }

    public void b()
        throws Exception
    {
        System.out.println("Initializing the chat server...");
        String s = System.getProperty("chat.serverPort");
        if(s != null)
            b = Integer.parseInt(s);
        c = a(b);
        java.rmi.Remote remote = null;
        String s1 = String.valueOf(String.valueOf((new StringBuffer("//127.0.0.1:")).append(b).append("/chatserver")));
        try
        {
            remote = Naming.lookup(s1);
        }
        catch(Exception exception) { }
        if(remote != null)
        {
            throw new Exception("Another instance of ChatApplication is already running on this machine");
        } else
        {
            Naming.rebind(s1, this);
            e = InetAddress.getLocalHost().getHostName();
            f = System.getProperty("user.name");
            System.out.println("ChatApplication server initialized");
            return;
        }
    }

    public void a(String s, String s1)
        throws Exception
    {
        if(s == null || s.trim().length() == 0)
        {
            throw new Exception("Please specify host name");
        } else
        {
            System.out.println(String.valueOf(String.valueOf((new StringBuffer("Sending message to host ")).append(s).append(": ").append(s1))));
            String s2 = String.valueOf(String.valueOf((new StringBuffer("//")).append(s).append(":").append(b).append("/chatserver")));
            b b1 = (b)Naming.lookup(s2);
            MessageInfo messageinfo = new MessageInfo(e, f);
            b1.receiveMessage(s1, messageinfo);
            System.out.println("Message sent to host ".concat(String.valueOf(String.valueOf(s))));
            return;
        }
    }

    public void a(c c1)
    {
        d = c1;
    }

    public Registry a(int i)
        throws Exception
    {
        System.out.println("Trying to get the registry on port ".concat(String.valueOf(String.valueOf(i))));
        Registry registry = null;
        try
        {
            registry = LocateRegistry.getRegistry(i);
            registry.list();
        }
        catch(Exception exception)
        {
            System.out.println("Registry was not running, trying to create one...");
            registry = LocateRegistry.createRegistry(i);
            registry.list();
        }
        return registry;
    }

    public void receiveMessage(String s, MessageInfo messageinfo)
        throws RemoteException
    {
        System.out.println("Received message from host ".concat(String.valueOf(String.valueOf(messageinfo.a()))));
        if(d != null)
            d.a(s, messageinfo);
    }

    protected static d a;
    protected int b;
    protected Registry c;
    c d;
    String e;
    String f;
}

⌨️ 快捷键说明

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