Creado el Servidor de gestorSubastas
[pcd.git] / src / subastas / Servidor.java
1 package subastas;
2
3 import java.io.File;
4 import java.io.FileNotFoundException;
5 import java.io.FileOutputStream;
6 import java.io.PrintWriter;
7
8 import org.omg.CORBA.*;
9 import org.omg.CORBA.ORBPackage.InvalidName;
10 import org.omg.PortableServer.*;
11 import org.omg.PortableServer.POAManagerPackage.AdapterInactive;
12 import org.omg.PortableServer.POAPackage.ServantNotActive;
13 import org.omg.PortableServer.POAPackage.WrongPolicy;
14
15 public class Servidor {
16
17         /**
18          * @param args
19          * @throws InvalidName 
20          * @throws AdapterInactive 
21          * @throws WrongPolicy 
22          * @throws ServantNotActive 
23          * @throws FileNotFoundException 
24          */
25         public static void main(String[] args) throws InvalidName, AdapterInactive, ServantNotActive, WrongPolicy, FileNotFoundException {
26         //inicializacion del orb
27         ORB orb = ORB.init(args, null);
28
29         //creacion del poa raiz
30         POA poa = POAHelper.narrow(orb.resolve_initial_references("RootPOA"));
31
32         //crear y activar sirvientes
33         poa.the_POAManager().activate();
34         gestorSubastasImpl sirviente = new gestorSubastasImpl(poa);
35         org.omg.CORBA.Object obj = poa.servant_to_reference(sirviente);
36
37         String ior = orb.object_to_string(obj);
38         PrintWriter ps = new PrintWriter(new FileOutputStream(new File("server.ior")));
39         ps.println(ior);
40         ps.close();
41
42         orb.run();
43         }
44
45 }