package chapter_11.warehouse1;

import chapter_11.warehouse.Warehouse;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import java.rmi.RemoteException;

/**
 * This server program instantiates a remote warehouse object, registers it with the naming service, and waits for clients to invoke methods.
 * @author Jerry-0824
 * @version 1.0.0 2017-01-03 17:08
 */
public class WarehouseServer {
    public static void main(String[] args) throws RemoteException, NamingException {
        System.out.println("Constructing server implementation ... ");
        WarehouseImpl centralWarehouse = new WarehouseImpl();

        System.out.println("Binding server implementation to registry ... ");
        Context namingContext = new InitialContext();
        namingContext.bind("rmi:central_warehouse", centralWarehouse);

        System.out.println("Waiting fro invocations from clients ... ");
    }
}
