import net.jini.core.entry.*;
import net.jini.core.lookup.*;
import net.jini.lookup.entry.*;
import com.sun.jini.lookup.*;
import com.sun.jini.lease.*;
import java.rmi.*;
import java.rmi.server.*;

/***************************************************************************

    MyServer -- The Jini Server Class

 ***************************************************************************/

    public class MyServer extends UnicastRemoteObject 
      implements MyServerInterface, ServiceIDListener
      {

      public MyServer () throws RemoteException 
        {
        super ();
        }


      public void serviceIDNotify (ServiceID sidIn)     // ServiceIDListener
        {
        System.out.println ("server: received ServiceID           " + sidIn);
        System.out.println ("*-----------------------------------------"
          + "--------------------------------*");
        }


      public String sayHello () throws RemoteException  // MyServiceInterface
        {
        System.out.println ("server: sayHello() called");
        return ("Hello World from MyServer!");
        }


      public static void main (String[] args)
        {
        MyServer myServer;
        Entry[] aeAttributes;
        JoinManager joinmanager;

        try 
          {
          System.setSecurityManager (new RMISecurityManager ());
          System.out.println ("*-----------------------------------------"
            + "--------------------------------*");

          aeAttributes = new Entry[1];
          aeAttributes[0] = new Name ("MyServerName");
          myServer = new MyServer ();

          System.out.println ("server: registering with lookup services...");
          joinmanager = new JoinManager 
            (
            myServer, 
            aeAttributes, 
            myServer, 
            new LeaseRenewalManager ()
            );
          System.out.println ("server: registered with lookups");
          } 

        catch (Exception e) 
          {
          System.out.println("main(): Exception " + e);
          }
        }
      }

