01: package demo.notification.office;
02:
03: /**
04: *
05: */
06:
07: import org.omg.CosNotification.*;
08: import org.omg.CosNotifyComm.*;
09: import org.omg.CosNotifyChannelAdmin.*;
10:
11: import org.omg.CosNaming.*;
12: import org.omg.CosNaming.NamingContextPackage.*;
13: import org.omg.CORBA.ORB;
14: import org.omg.PortableServer.*;
15:
16: import demo.notification.office.*;
17:
18: class PrintServer {
19: /**
20: * main
21: */
22:
23: static public void main(String argv[]) {
24: EventChannel channel = null;
25: org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init(argv, null);
26:
27: try {
28: // initialize POA, get naming and event service references
29: POA poa = POAHelper.narrow(orb
30: .resolve_initial_references("RootPOA"));
31: poa.the_POAManager().activate();
32:
33: NamingContextExt nc = NamingContextExtHelper.narrow(orb
34: .resolve_initial_references("NameService"));
35:
36: EventChannelFactory factory = EventChannelFactoryHelper
37: .narrow(orb
38: .resolve_initial_references("NotificationService"));
39:
40: if (factory == null) {
41: System.err
42: .println("Could not find or narrow EventChannelFactory");
43: System.exit(1);
44: }
45:
46: org.omg.CORBA.IntHolder idHolder = new org.omg.CORBA.IntHolder();
47:
48: Property[] qos = new Property[0];
49: Property[] adm = new Property[0];
50:
51: channel = factory.create_channel(qos, adm, idHolder);
52: nc.rebind(nc.to_name("office_event.channel"), channel);
53:
54: System.out
55: .println("Channel "
56: + idHolder.value
57: + " created and bound to name office_event.channel.");
58:
59: // create a Printer object, implicitly activate it and advertise its presence
60: PrinterImpl printer = new PrinterImpl(channel, orb, poa);
61: printer.connect();
62: System.out.println("Printer created and connected");
63:
64: org.omg.CORBA.Object printerObj = poa
65: .servant_to_reference(printer);
66: nc.rebind(nc.to_name("Printer"), printerObj);
67: System.out.println("Printer exported");
68:
69: // wait for requests
70: orb.run();
71: } catch (Exception ex) {
72: ex.printStackTrace();
73: }
74: }
75: }
|