1 package demo.notification.office; 2 3 6 7 import org.omg.CosNotification.*; 8 import org.omg.CosNotifyComm.*; 9 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 23 24 static public void main (String argv[]) 25 { 26 EventChannel channel = null; 27 org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init(argv, null); 28 29 try 30 { 31 POA poa = POAHelper.narrow(orb.resolve_initial_references("RootPOA") ); 33 poa.the_POAManager().activate(); 34 35 NamingContextExt nc = 36 NamingContextExtHelper.narrow(orb.resolve_initial_references("NameService")); 37 38 EventChannelFactory factory = 39 EventChannelFactoryHelper.narrow( orb.resolve_initial_references("NotificationService")); 40 41 if( factory == null ) 42 { 43 System.err.println("Could not find or narrow EventChannelFactory"); 44 System.exit(1); 45 } 46 47 org.omg.CORBA.IntHolder idHolder = 48 new org.omg.CORBA.IntHolder (); 49 50 Property[] qos = new Property[0]; 51 Property[] adm = new Property[0]; 52 53 channel = factory.create_channel(qos, adm, idHolder); 54 nc.rebind( nc.to_name("office_event.channel"), channel ); 55 56 System.out.println("Channel " + idHolder.value + 57 " created and bound to name office_event.channel."); 58 59 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.servant_to_reference( printer ); 65 nc.rebind( nc.to_name("Printer"), printerObj); 66 System.out.println("Printer exported"); 67 68 orb.run(); 70 } 71 catch (Exception ex) 72 { 73 ex.printStackTrace(); 74 } 75 } 76 } 77 | Popular Tags |