public static void main(String[] args) { try { // init ORB ORB orb = ORB.init(args, null); // init POA POA poa = POAHelper.narrow(orb.resolve_initial_references("RootPOA")); poa.the_POAManager().activate(); // create a Adder object AdderImpl adderImpl = new AdderImpl(); // create the object reference org.omg.CORBA.Object adderRef = poa.servant_to_reference(adderImpl); org.omg.CORBA.Object nsObject = orb.resolve_initial_references("NameService"); NamingContextExt nc = NamingContextExtHelper.narrow(nsObject); nc.rebind(nc.to_name("Adder"), adderRef); // wait for requests orb.run(); } catch (Exception e) { System.out.println(e); } }
public void run() { try { ORB orb = ORB.init(args, null); // get reference to rootpoa & activate the POAManager POA poa = POAHelper.narrow(orb.resolve_initial_references("RootPOA")); poa.the_POAManager().activate(); // get the root naming context org.omg.CORBA.Object objRef = orb.resolve_initial_references("NameService"); // Use NamingContextExt which is part of the Interoperable // Naming Service (INS) specification. NamingContextExt ncRef = NamingContextExtHelper.narrow(objRef); DomainParticipantFactoryImpl impl = new DomainParticipantFactoryImpl(orb, poa); // get object reference from the servant (and implicitly register // it) org.omg.CORBA.Object oref = poa.servant_to_reference(impl); DomainParticipantFactory ref = DomainParticipantFactoryHelper.narrow(oref); if (ncRef != null) { // bind the Object Reference in Naming NameComponent path[] = ncRef.to_name("DomainParticipantFactory"); ncRef.rebind(path, ref); } System.out.println("Server ready and waiting ..."); orb.run(); } catch (Exception e) { System.out.println("e" + e); e.printStackTrace(); } }
public static void main(String args[]) { if (args.length == 0) { System.out.println("Koordinator Namen eingeben..."); } else { try { // ORB Eigenschaften setzen Properties props = new Properties(); props.put("org.omg.CORBA.ORBInitialPort", "1050"); props.put("org.omg.CORBA.ORBInitialHost", "localhost"); orb = ORB.init(args, props); // Referenz von rootPOA holen und POA Manager aktivieren POA rootPoa = POAHelper.narrow(orb.resolve_initial_references("RootPOA")); rootPoa.the_POAManager().activate(); // NamingContext besorgen NamingContextExt nc = NamingContextExtHelper.narrow(orb.resolve_initial_references("NameService")); // Objektreferenz mit Namen "koordinator" besorgen org.omg.CORBA.Object obj = nc.resolve_str(args[1]); // Referenz fuer den Servant besorgen ggt.Koordinator koord = KoordinatorHelper.narrow(obj); // Servant erzeugen StarterImpl starter = new StarterImpl(args[0], koord, rootPoa); // Referenz fuer den Servant besorgen org.omg.CORBA.Object ref = rootPoa.servant_to_reference(starter); // Downcast Corba-Objekt -> koordinator ggt.Starter href = StarterHelper.narrow(ref); // starter bei koordinator anmelden koord.activateStarter(href, args[0]); // binde die Object Reference an einen Namen String name = args[0]; NameComponent path[] = nc.to_name(name); nc.rebind(path, href); System.out.println("Koordinator laeuft ..."); // Orb starten und auf Clients warten orb.run(); } catch (Exception e) { System.err.println("Fehler: " + e); e.printStackTrace(System.out); } System.out.println("BankServer Exit"); } }
public void startMockServer(int corbaPort) { ORB orb = null; try { orb = getOrbForServer(corbaPort); System.out.println("Server Started..."); orb.run(); // blocks the current thread until the ORB is shutdown } catch (InvalidName | AdapterInactive | WrongPolicy | ServantNotActive e) { System.out.println("Unable to start the CORBA server."); e.printStackTrace(); } catch (IOException e) { System.out.println("Unable to generate the IOR file."); e.printStackTrace(); } if (orb != null) { orb.destroy(); } }
/** @param args the command line arguments */ public static void main(String args[]) { try { // create and initialize the ORB ORB orb = ORB.init(args, null); // get reference to rootpoa & activate the POAManager POA rootpoa = POAHelper.narrow(orb.resolve_initial_references("RootPOA")); rootpoa.the_POAManager().activate(); // create servant Log_viewerImpl log_viewerImpl = new Log_viewerImpl(); log_viewerImpl.setORB(orb); LogFrame frame = new LogFrame(log_viewerImpl); frame.setVisible(true); log_viewerImpl.setFrame(frame); // get object reference from the servant org.omg.CORBA.Object ref = rootpoa.servant_to_reference(log_viewerImpl); Log_viewer href = Log_viewerHelper.narrow(ref); // read stringified Registry to file FileReader fr = new FileReader(IORFILE); BufferedReader br = new BufferedReader(fr); String remoteRegistryIOR = br.readLine(); // get the romote Registry org.omg.CORBA.Object ncobj = orb.string_to_object(remoteRegistryIOR); NamingContext rootNC = NamingContextHelper.narrow(ncobj); frame.println("Obtained Name Service reference."); log_viewerImpl.serRootNC(rootNC); NameComponent[] name = new NameComponent[1]; name[0] = new NameComponent("Logger", ""); try { rootNC.bind(name, href); } catch (org.omg.CORBA.UserException ue) { ue.printStackTrace(); System.exit(-1); } frame.println("Logger Remote Interface bound in Name Service"); // wait for invocations from client frame.println("Logger ready and waiting ..."); orb.run(); frame.println("Logger Exiting ..."); System.out.println("Logger Exiting ..."); } catch (Exception e) { System.err.println("ERROR: " + e); // e.printStackTrace(System.out); } }
public void run() { theOrb.run(); }