Компонентный подход в программировании

       

public class HelloImpl extends UnicastRemoteObject


package examples.rmi;
import java.rmi.registry.LocateRegistry; import java.rmi.registry.Registry; import java.rmi.server.UnicastRemoteObject;
public class HelloImpl extends UnicastRemoteObject implements Hello { public static final String ServerHost = "hostname"; public static final String ServerURL = "rmi://" + ServerHost + ":2001/SERVER"; public static final int RegistryPort = 2000;
public HelloImpl () throws java.rmi.RemoteException { }
public String hello () throws java.rmi.RemoteException { return "Hello!"; }
public static void main (String[] args) { try { Hello stub = new HelloImpl(); Registry registry = LocateRegistry.getRegistry(RegistryPort); registry.rebind(ServerURL, stub); } catch (Exception e) { System.out.println("server creation exception"); e.printStackTrace(); } } }
Пример 13.1.
Закрыть окно




package examples.rmi;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import java.rmi.server.UnicastRemoteObject;
public class HelloImpl extends UnicastRemoteObject implements Hello


{
public static final String ServerHost = "hostname";
public static final String ServerURL = "rmi://" + ServerHost + ":2001/SERVER";
public static final int RegistryPort = 2000;
public HelloImpl () throws java.rmi.RemoteException { }
public String hello () throws java.rmi.RemoteException
{ return "Hello!"; }
public static void main (String[] args)
{
try
{
Hello stub = new HelloImpl();
Registry registry = LocateRegistry.getRegistry(RegistryPort);
registry.rebind(ServerURL, stub);
}
catch (Exception e)
{
System.out.println("server creation exception");
e.printStackTrace();
}
}
}

Содержание раздела