
/*
 * Server to test the behavior of user-defined and 
 * system exceptions
 */

import java.io.*;
import org.omg.CORBA.*;
import org.omg.PortableServer.*;

public class Server {
	
  public static void main(String[] args)
  { try {
	// Initialize the ORB.
	ORB orb = ORB.init(args, null);

	POA poa=POAHelper.narrow(orb.resolve_initial_references("RootPOA"));
        poa.the_POAManager().activate();

	// Create the object
	ExceptionTestImpl exceptionTest=
	  new ExceptionTestImpl();

        // create the object reference
        org.omg.CORBA.Object obj = poa.servant_to_reference(exceptionTest);

        // print stringified object reference
        FileWriter out = new FileWriter("ior");
        out.write( orb.object_to_string( obj ) );
        out.close();

        // wait for requests
        System.out.println("Server started with IOR: "
                + orb.object_to_string(obj));

        orb.run();
	}

	catch(SystemException ex) {
		ex.printStackTrace();
	}
        catch( java.lang.Exception ie) {
            System.err.println(ie);
        }

  }
}

