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

📄 main.java

📁 《精通RMI:Java与EJB企业级应用开发》书籍的源代码. 本书是讲述RMI技术的经典著作
💻 JAVA
字号:
/*
 * Copyright 1999 by dreamBean Software,
 * All rights reserved.
 */
package masteringrmi.helloworld.server;

import java.io.IOException;
import java.net.MalformedURLException;
import java.rmi.Naming;
import java.rmi.AlreadyBoundException;
import java.rmi.RemoteException;

/**
 *   Main server class. This creates a remote object, and registers it
 *   with the registry service.
 *
 *   The RMI-registry must be started prior to executing this class. Also,
 *   since we are not using dynamic class downloading the RMI-registry must
 *   have all the client-classes of the remote object in its classpath (i.e. the remote interface+the stub).
 *   
 *   Since it does not require dynamic class downloading from the client we do not install a SecurityManager.
 *
 *   @see HelloWorldImpl
 *   @author Rickard 謆erg (rickard@dreambean.com)
 *   @version $Revision:$
 */
public class Main
{
   // Static --------------------------------------------------------

   /**
    *   Run server as stand-alone application.
    *
    * @param   args  
    * @exception   Exception  
    */
   public static void main(String[] args)
      throws Exception
   {
      new Main();
   }
   
   // Public --------------------------------------------------------

   /**
    *   Create a remote object and register it with the RMI-registry.
    *
    */
   public Main()
   {
      try
      {
         // Create remote object
         HelloWorldImpl server = new HelloWorldImpl();
      
         // Register server with naming service
         // Use rebind instead of bind
         // This is useful if this is a restart of the server,
         // since we then will overwrite the old binding
         Naming.rebind(HelloWorldImpl.NAME, server);
         
         System.out.println("Server has been started and registered");
      } catch (MalformedURLException e)
      {
         System.out.println("The server name was incorrect");
         e.printStackTrace(System.err);
      } catch (RemoteException e)
      {
         System.out.println("The object could not be created");
         e.printStackTrace(System.err);
      }
   }

   /** @link aggregation 
    * @stereotype use
    * @label manages*/
   /*#HelloWorldImpl attribute1;*/
}

⌨️ 快捷键说明

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