?? main.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 + -