src/main/java/pityoulish/jrmi/server/Main.java
public static void main(String[] args)
    throws Exception
  {
    //@@@ get network interface from command line arguments, too?
    //@@@ Use ArgsInterpreter and SingleCommandHandlerBase?
    int port = 1088; // default for the exercises (RMI default is 1099)
    int capacity = 8;

    try {
      if (args.length > 0)
         port = Integer.parseInt(args[0]);
      if (args.length > 1)
         capacity = Integer.parseInt(args[1]);
    } catch (NumberFormatException nfx) {
      System.out.println(Catalog.fixEOL(Catalog.USAGE.lookup()));
      System.exit(1);
    }

    // The server name or IP address has to be set as a system property.
    // Otherwise, stubs will point to some version of 'localhost' and be
    // useless on other machines. Report whether the property is set.
    checkForHostnameProperty();

    LogConfig.configure(Main.class);
    LOGGER.log(Level.INFO, "starting Message Board server");

    MixedMessageBoard       mmb  = new MixedMessageBoardImpl(capacity);
    TicketManager           tim  = new DefaultTicketManager();

    RemoteMessageBoardImpl  rmbi = new RemoteMessageBoardImpl(mmb, tim);
    RemoteTicketIssuerImpl  rtii = new RemoteTicketIssuerImpl(tim, true);
    RemoteOutletManagerImpl romi = new RemoteOutletManagerImpl(tim);

    // These objects will most likely listen on another port than the registry.
    // It depends on the RMI implementation whether they share the same port.
    Remote rmbistub = UnicastRemoteObject.exportObject(rmbi, 0);
    Remote rtiistub = UnicastRemoteObject.exportObject(rtii, 0);
    Remote romistub = UnicastRemoteObject.exportObject(romi, 0);

    //@@@ NLS light?
    System.out.println(rmbistub);
    System.out.println(rtiistub);
    System.out.println(romistub);

    mmb.putSystemMessage(null, Catalog.SYSMSG_OPEN.lookup());
    mmb.putSystemMessage(null, Catalog.SYSMSG_CAPACITY_1.format(capacity));

    Registry mainreg = createDefaultRegistry(port);
    mainreg.bind(RegistryNames.MESSAGE_BOARD.lookupName, rmbi);
    mainreg.bind(RegistryNames.TICKET_ISSUER.lookupName, rtii);
    mainreg.bind(RemoteOutletManager.REGISTRY_NAME, romi);


    // If we just return here, the Java program keeps running. There are
    // service threads for the RMI Registry and remotely callable objects.
    // So wait a while, then shut down explicitly.

    Thread.sleep(3600000); // milliseconds
    System.exit(0);
    //@@@ shut down gracefully
  }
/**
   * Main entry point.
   *
   * @param args        the command line arguments
   *
   * @throws Exception  in case of a problem
   */
Main entry point.
@param args        the command line arguments

@throws Exception  in case of a problem
Main entry point . @param args the command line arguments @throws Exception in case of a problem
public static void main(String[] args)
    throws Exception
  {
    int port = 1088; 
    int capacity = 8;
    try {
      if (args.length > 0)
         port = Integer.parseInt(args[0]);
      if (args.length > 1)
         capacity = Integer.parseInt(args[1]);
    } catch (NumberFormatException nfx) {
      System.out.println(Catalog.fixEOL(Catalog.USAGE.lookup()));
      System.exit(1);
    }
    checkForHostnameProperty();
    LogConfig.configure(Main.class);
    LOGGER.log(Level.INFO, "starting Message Board server");
    MixedMessageBoard       mmb  = new MixedMessageBoardImpl(capacity);
    TicketManager           tim  = new DefaultTicketManager();
    RemoteMessageBoardImpl  rmbi = new RemoteMessageBoardImpl(mmb, tim);
    RemoteTicketIssuerImpl  rtii = new RemoteTicketIssuerImpl(tim, true);
    RemoteOutletManagerImpl romi = new RemoteOutletManagerImpl(tim);
    Remote rmbistub = UnicastRemoteObject.exportObject(rmbi, 0);
    Remote rtiistub = UnicastRemoteObject.exportObject(rtii, 0);
    Remote romistub = UnicastRemoteObject.exportObject(romi, 0);
    System.out.println(rmbistub);
    System.out.println(rtiistub);
    System.out.println(romistub);
    mmb.putSystemMessage(null, Catalog.SYSMSG_OPEN.lookup());
    mmb.putSystemMessage(null, Catalog.SYSMSG_CAPACITY_1.format(capacity));
    Registry mainreg = createDefaultRegistry(port);
    mainreg.bind(RegistryNames.MESSAGE_BOARD.lookupName, rmbi);
    mainreg.bind(RegistryNames.TICKET_ISSUER.lookupName, rtii);
    mainreg.bind(RemoteOutletManager.REGISTRY_NAME, romi);
    Thread.sleep(3600000); 
    System.exit(0);
  }
public static void main ( String [ ] args ) throws Exception { int port = 1088 ; int capacity = 8 ; try { if ( args . length > 0 ) port = Integer . parseInt ( args [ 0 ] ) ; if ( args . length > 1 ) capacity = Integer . parseInt ( args [ 1 ] ) ; } catch ( NumberFormatException nfx ) { System . out . println ( Catalog . fixEOL ( Catalog . USAGE . lookup ( ) ) ) ; System . exit ( 1 ) ; } checkForHostnameProperty ( ) ; LogConfig . configure ( Main . class ) ; LOGGER . log ( Level . INFO , "starting Message Board server" ) ; MixedMessageBoard mmb = new MixedMessageBoardImpl ( capacity ) ; TicketManager tim = new DefaultTicketManager ( ) ; RemoteMessageBoardImpl rmbi = new RemoteMessageBoardImpl ( mmb , tim ) ; RemoteTicketIssuerImpl rtii = new RemoteTicketIssuerImpl ( tim , true ) ; RemoteOutletManagerImpl romi = new RemoteOutletManagerImpl ( tim ) ; Remote rmbistub = UnicastRemoteObject . exportObject ( rmbi , 0 ) ; Remote rtiistub = UnicastRemoteObject . exportObject ( rtii , 0 ) ; Remote romistub = UnicastRemoteObject . exportObject ( romi , 0 ) ; System . out . println ( rmbistub ) ; System . out . println ( rtiistub ) ; System . out . println ( romistub ) ; mmb . putSystemMessage ( null , Catalog . SYSMSG_OPEN . lookup ( ) ) ; mmb . putSystemMessage ( null , Catalog . SYSMSG_CAPACITY_1 . format ( capacity ) ) ; Registry mainreg = createDefaultRegistry ( port ) ; mainreg . bind ( RegistryNames . MESSAGE_BOARD . lookupName , rmbi ) ; mainreg . bind ( RegistryNames . TICKET_ISSUER . lookupName , rtii ) ; mainreg . bind ( RemoteOutletManager . REGISTRY_NAME , romi ) ; Thread . sleep ( 3600000 ) ; System . exit ( 0 ) ; }
Main entry point.
Main entry point .
//@@@ get network interface from command line arguments, too? //@@@ Use ArgsInterpreter and SingleCommandHandlerBase? // default for the exercises (RMI default is 1099) // The server name or IP address has to be set as a system property. // Otherwise, stubs will point to some version of 'localhost' and be // useless on other machines. Report whether the property is set. // These objects will most likely listen on another port than the registry. // It depends on the RMI implementation whether they share the same port. //@@@ NLS light? // If we just return here, the Java program keeps running. There are // service threads for the RMI Registry and remotely callable objects. // So wait a while, then shut down explicitly. // milliseconds //@@@ shut down gracefully