main.java

来自「一个基于RMI的网络聊天室」· Java 代码 · 共 62 行

JAVA
62
字号
/*
 * Copyright 1999 by dreamBean Software,
 * All rights reserved.
 */


import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.net.MalformedURLException;
import java.rmi.server.*;
import java.rmi.*;




/**
 *   This is the admin class that manages the chat server.
 *
 *   @see TopicServerImpl
 *   @author Rickard 謆erg (rickard@dreambean.com)
 *   @version $Revision:$
 */
public class Main
{
   // Attributes ----------------------------------------------------
  // To prevent GC


   //
   // Public --------------------------------------------------------



   public static void main(String[] args)
   {
           try

           {
      // Create remote object
     TopicServerImpl server = new TopicServerImpl(Integer.getInteger("chat.server.threads", 5).intValue());

      // Load configuration
      server.setPort(Integer.getInteger("chat.server.port", 0).intValue());

      // Export server
      UnicastRemoteObject.exportObject(server, server.getPort());

      // Create a few topics
      server.createTopic(new TopicInfo("Room1", "Welcome to the room1"));
      server.createTopic(new TopicInfo("room2", "Welcome to room2"));
      server.createTopic(new TopicInfo("room3", "Welcome to the room3"));

      // Register server with naming service
      Naming.rebind("topics",server);
  }
  catch(Exception e)
  {
	  e.printStackTrace();
	  }
   }
}

⌨️ 快捷键说明

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