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 static void main(String args[]) { try { // create and initialize the ORB ORB orb = ORB.init(args, null); System.out.println("ORB initialised\n"); // get the root naming context org.omg.CORBA.Object objRef = orb.resolve_initial_references("NameService"); // Use NamingContextExt instead of NamingContext, // part of the Interoperable naming Service. NamingContextExt ncRef = NamingContextExtHelper.narrow(objRef); // resolve the Object Reference in Naming String name = "Hello1"; helloImpl = HelloHelper.narrow(ncRef.resolve_str(name)); System.out.println("Obtained a handle on server object: " + helloImpl); System.out.println(helloImpl.sayHello()); helloImpl.shutdown(); } catch (Exception e) { System.out.println("ERROR : " + e); e.printStackTrace(System.out); } } // end main
public NotificationTestCaseSetup() throws Exception { ifrServerSetup = new IFRServerSetup( TestUtils.testHome() + "/src/test/idl/TypedNotification.idl", null, null); ORBSetUp(); serverORB = ORB.init(new String[0], orbProps); POAHelper.narrow(serverORB.resolve_initial_references("RootPOA")).the_POAManager().activate(); container_ = PicoContainerFactory.createRootContainer((org.jacorb.orb.ORB) serverORB); container_.unregisterComponent(Repository.class); container_.registerComponent( new AbstractComponentAdapter(Repository.class, Repository.class) { public Object getComponentInstance(PicoContainer picocontainer) throws PicoInitializationException, PicoIntrospectionException { try { return getRepository(); } catch (Exception e) { throw new RuntimeException(e); } } public void verify(PicoContainer picocontainer) throws PicoIntrospectionException {} }); testUtils_ = new NotificationTestUtils(getServerORB()); POAHelper.narrow(orb.resolve_initial_references("RootPOA")).the_POAManager().activate(); }
public void foo() throws InterceptorOrderingException { try { Current current = (Current) orb.resolve_initial_references("PICurrent"); Any any = current.get_slot(MyInitializer.slot_id); String s = any.extract_string(); System.out.println("TestObjectImpl.foo, extracted from PICurrent: >>" + s + "<<"); String expectedPiFlow = "JacOrbRocks:receive_request_service_contexts:preinvoke:receive_request:foo"; if (!expectedPiFlow.equals(s)) { System.out.println("### THROWING EX " + expectedPiFlow + " and " + s); throw new InterceptorOrderingException(); } System.out.println("TestObjectImpl.foo calling bar()"); TestObjectHelper.narrow(_this_object()).bar(); } catch (InterceptorOrderingException e) { throw e; } catch (Exception e) { e.printStackTrace(); } }
public boolean processCommand(String[] cmdArgs, ORB orb, PrintStream out) { int serverId = illegalServerId; try { // determine the server id if (cmdArgs.length == 2) if (cmdArgs[0].equals("-serverid")) serverId = (Integer.valueOf(cmdArgs[1])).intValue(); else if (cmdArgs[0].equals("-applicationName")) serverId = ServerTool.getServerIdForAlias(orb, cmdArgs[1]); if (serverId == illegalServerId) return parseError; // startup the server Activator activator = ActivatorHelper.narrow( orb.resolve_initial_references(ORBConstants.SERVER_ACTIVATOR_NAME)); activator.activate(serverId); out.println(CorbaResourceUtil.getText("servertool.startserver2")); } catch (ServerNotRegistered ex) { out.println(CorbaResourceUtil.getText("servertool.nosuchserver")); } catch (ServerAlreadyActive ex) { out.println(CorbaResourceUtil.getText("servertool.serverup")); } catch (ServerHeldDown ex) { out.println(CorbaResourceUtil.getText("servertool.helddown")); } catch (Exception ex) { ex.printStackTrace(); } return commandDone; }
public boolean processCommand(String[] cmdArgs, ORB orb, PrintStream out) { if ((cmdArgs.length == 2) && cmdArgs[0].equals("-applicationName")) { String str = (String) cmdArgs[1]; try { Repository repository = RepositoryHelper.narrow( orb.resolve_initial_references(ORBConstants.SERVER_REPOSITORY_NAME)); try { int result = repository.getServerID(str); out.println(); out.println( CorbaResourceUtil.getText("servertool.getserverid2", str, Integer.toString(result))); out.println(); } catch (ServerNotRegistered e) { out.println(CorbaResourceUtil.getText("servertool.nosuchserver")); } } catch (Exception ex) { ex.printStackTrace(); } return commandDone; } else return parseError; }
public KerberosServer(String[] args) { try { // initialize the ORB and POA. orb = ORB.init(args, null); POA rootPOA = (POA) orb.resolve_initial_references("RootPOA"); org.omg.CORBA.Policy[] policies = new org.omg.CORBA.Policy[3]; policies[0] = rootPOA.create_id_assignment_policy(IdAssignmentPolicyValue.USER_ID); policies[1] = rootPOA.create_lifespan_policy(LifespanPolicyValue.PERSISTENT); Any sasAny = orb.create_any(); SASPolicyValuesHelper.insert( sasAny, new SASPolicyValues(EstablishTrustInClient.value, EstablishTrustInClient.value, true)); policies[2] = orb.create_policy(SAS_POLICY_TYPE.value, sasAny); POA securePOA = rootPOA.create_POA("SecurePOA", rootPOA.the_POAManager(), policies); rootPOA.the_POAManager().activate(); // create object and write out IOR securePOA.activate_object_with_id("SecureObject".getBytes(), this); org.omg.CORBA.Object demo = securePOA.servant_to_reference(this); PrintWriter pw = new PrintWriter(new FileWriter(args[0])); pw.println(orb.object_to_string(demo)); pw.flush(); pw.close(); } catch (Exception e) { e.printStackTrace(); } }
public boolean processCommand(String[] cmdArgs, ORB orb, PrintStream out) { int serverId = illegalServerId; try { if (cmdArgs.length == 2) { if (cmdArgs[0].equals("-serverid")) serverId = (Integer.valueOf(cmdArgs[1])).intValue(); else if (cmdArgs[0].equals("-applicationName")) serverId = ServerTool.getServerIdForAlias(orb, cmdArgs[1]); } // the server id has to be specified if (serverId == illegalServerId) return parseError; // activate the server Activator activator = ActivatorHelper.narrow( orb.resolve_initial_references(ORBConstants.SERVER_ACTIVATOR_NAME)); String[] orbList = activator.getORBNames(serverId); out.println(CorbaResourceUtil.getText("servertool.orbidmap2")); for (int i = 0; i < orbList.length; i++) { out.println("\t " + orbList[i]); } } catch (ServerNotRegistered ex) { out.println("\tno such server found."); } catch (Exception ex) { ex.printStackTrace(); } return commandDone; }
@Override public Emitter connect(String nickname, Receiver rcv) { if (isConnected(nickname)) { for (Emitter e : emitters) { if (nickname.equals(e.client())) { System.out.println(nickname + " est déjà connécté "); return e; // je sort et je retourne l'émeteur ! } } } EmitterImpl emitter = new EmitterImpl(); receivers.add(rcv); // J'ajoute le receiver dans le ArrayList clients.add(nickname); System.out.println("Le client " + nickname + " vient de se connecter ! "); Emitter em = null; POA rootpoa; try { rootpoa = POAHelper.narrow(orb.resolve_initial_references("RootPOA")); rootpoa.the_POAManager().activate(); org.omg.CORBA.Object ref = rootpoa.servant_to_reference(emitter); em = EmitterHelper.narrow(ref); em.client(nickname); emitters.add(em); // on ajoute cet emmetteur ! } catch (Exception e) { e.printStackTrace(); } return em; }
public static ORB getORB() { synchronized (ORBFactory.class) { if (orb == null) { Properties properties; try { properties = (Properties) AccessController.doPrivileged( new PrivilegedAction() { public Object run() { return System.getProperties(); } }); } catch (SecurityException ignored) { log.trace("Unable to retrieve system properties", ignored); properties = null; } // Create the singleton ORB orb = ORB.init(new String[0], properties); // Activate the root POA try { POA rootPOA = (POA) orb.resolve_initial_references("RootPOA"); rootPOA.the_POAManager().activate(); } catch (Throwable t) { log.warn("Unable to activate POA", t); } } return orb; } }
public void testThereShouldBeOnlyOneLogfile() throws Exception { File dir = TestUtils.createTempDir("bugjac384"); Properties props = new Properties(); props.setProperty("org.omg.CORBA.ORBClass", "org.jacorb.orb.ORB"); props.setProperty("org.omg.CORBA.ORBSingletonClass", "org.jacorb.orb.ORBSingleton"); props.setProperty("jacorb.log.default.verbosity", "4"); props.setProperty("jacorb.logfile", dir.getAbsolutePath() + "/logfile.txt"); props.setProperty("jacorb.logfile.append", "on"); props.setProperty("jacorb.logfile.maxLogSize", "1500"); props.setProperty("jacorb.logfile.rotateCount", "2"); ORB orb = ORB.init(new String[0], props); orb.shutdown(true); ((org.jacorb.config.JacORBConfiguration) ((org.jacorb.orb.ORB) orb).getConfiguration()) .shutdownLogging(); orb = ORB.init(new String[0], props); POA poa = POAHelper.narrow(orb.resolve_initial_references("RootPOA")); poa.destroy(true, true); orb.shutdown(true); ((org.jacorb.config.JacORBConfiguration) ((org.jacorb.orb.ORB) orb).getConfiguration()) .shutdownLogging(); final String[] list = dir.list(); assertEquals(Arrays.asList(list).toString(), 2, list.length); }
public static void main(String[] args) { try { String tableID = "Test-Tafel2"; ORB _orb; Properties props = new Properties(); props.put("org.omg.CORBA.ORBInitialPort", "1050"); props.put("org.omg.CORBA.ORBInitialHost", "192.168.2.20"); _orb = ORB.init(new String[0], props); org.omg.CORBA.Object objRef = _orb.resolve_initial_references("NameService"); NamingContextExt ncRef = NamingContextExtHelper.narrow(objRef); BoardService boardServiceObj = (BoardService) BoardServiceHelper.narrow(ncRef.resolve_str(tableID + "/BoardService")); User _user1 = new User("Yumo"); boardServiceObj.sendMessage( _user1, new Message("Hallo Test-Tafel no. 1", _user1.name, new Date().toString()), tableID); } catch (InvalidName ex) { Logger.getLogger(BoardServiceTestbench.class.getName()).log(Level.SEVERE, null, ex); } catch (NotFound ex) { Logger.getLogger(BoardServiceTestbench.class.getName()).log(Level.SEVERE, null, ex); } catch (CannotProceed ex) { Logger.getLogger(BoardServiceTestbench.class.getName()).log(Level.SEVERE, null, ex); } catch (org.omg.CosNaming.NamingContextPackage.InvalidName ex) { Logger.getLogger(BoardServiceTestbench.class.getName()).log(Level.SEVERE, null, ex); } catch (UnknownUser ex) { Logger.getLogger(BoardServiceTestbench.class.getName()).log(Level.SEVERE, null, ex); } }
GrmWrapperCorba(ORB orb) { try { org.omg.CORBA.Object ns = orb.resolve_initial_references("NameService"); NamingContextExt nameService = NamingContextExtHelper.narrow(ns); grm = GrmHelper.narrow(nameService.resolve(nameService.to_name("GRM"))); } catch (Exception e) { e.printStackTrace(); } }
/** * create a new IdlWriter for the default JacORB IR which writes to a specific PrintStream * * @param orb * @param ps a PrintStream * @param logger */ public IdlWriter(ORB orb, PrintStream ps, Logger logger) { printStream = ps; this.logger = logger; try { ir = org.omg.CORBA.RepositoryHelper.narrow( orb.resolve_initial_references("InterfaceRepository")); factory = org.omg.DynamicAny.DynAnyFactoryHelper.narrow( orb.resolve_initial_references("DynAnyFactory")); } catch (org.omg.CORBA.ORBPackage.InvalidName e) { throw new INTERNAL(e.toString()); } if (ir == null) { logger.error("No IR configured! Exiting.."); System.exit(1); } }
public boolean processCommand(String[] cmdArgs, ORB orb, PrintStream out) { int serverId = illegalServerId; boolean listOneServer = false; ServerDef serverDef; // determine if list single server or all servers listOneServer = (cmdArgs.length != 0); if ((cmdArgs.length == 2) && cmdArgs[0].equals("-serverid")) serverId = (Integer.valueOf(cmdArgs[1])).intValue(); if ((serverId == illegalServerId) && listOneServer) return parseError; // process the list server command try { Repository repository = RepositoryHelper.narrow( orb.resolve_initial_references(ORBConstants.SERVER_REPOSITORY_NAME)); if (listOneServer) { try { serverDef = repository.getServer(serverId); out.println(); printServerDef(serverDef, serverId, out); out.println(); } catch (ServerNotRegistered e) { out.println(CorbaResourceUtil.getText("servertool.nosuchserver")); } } else { int[] servers = repository.listRegisteredServers(); out.println(CorbaResourceUtil.getText("servertool.list2")); sortServers(servers); for (int i = 0; i < servers.length; i++) { try { serverDef = repository.getServer(servers[i]); out.println( "\t " + servers[i] + "\t\t" + serverDef.serverName + "\t\t" + serverDef.applicationName); } catch (ServerNotRegistered e) { } } } } catch (Exception ex) { ex.printStackTrace(); } return commandDone; }
public boolean processCommand(String[] cmdArgs, ORB orb, PrintStream out) { int serverId = illegalServerId; String orbId = ""; try { // parse command String arg; int i = 0; while (i < cmdArgs.length) { arg = cmdArgs[i++]; if (arg.equals("-serverid")) { if (i < cmdArgs.length) serverId = (Integer.valueOf(cmdArgs[i++])).intValue(); else return parseError; } else if (arg.equals("-applicationName")) { if (i < cmdArgs.length) serverId = ServerTool.getServerIdForAlias(orb, cmdArgs[i++]); else return parseError; } else if (arg.equals("-orbid")) { if (i < cmdArgs.length) orbId = cmdArgs[i++]; } } // the server id has to be specified if (serverId == illegalServerId) return parseError; // locate the server // deactivate the server Locator locator = LocatorHelper.narrow(orb.resolve_initial_references(ORBConstants.SERVER_LOCATOR_NAME)); ServerLocationPerORB location = locator.locateServerForORB(serverId, orbId); // print success message out.println(CorbaResourceUtil.getText("servertool.locateorb2", location.hostname)); int numEntries = location.ports.length; for (i = 0; i < numEntries; i++) { EndPointInfo Port = location.ports[i]; out.println("\t\t" + Port.port + "\t\t" + Port.endpointType + "\t\t" + orbId); } } catch (InvalidORBid ex) { out.println(CorbaResourceUtil.getText("servertool.nosuchorb")); } catch (ServerHeldDown ex) { out.println(CorbaResourceUtil.getText("servertool.helddown")); } catch (ServerNotRegistered ex) { out.println(CorbaResourceUtil.getText("servertool.nosuchserver")); } catch (Exception ex) { ex.printStackTrace(); } return commandDone; }
public void printSAS() { try { org.omg.PortableInterceptor.Current current = (org.omg.PortableInterceptor.Current) orb.resolve_initial_references("PICurrent"); org.omg.CORBA.Any anyName = current.get_slot(org.jacorb.security.sas.SASInitializer.sasPrincipalNamePIC); String name = anyName.extract_string(); System.out.println("printSAS for user " + name); } catch (Exception e) { System.out.println("printSAS Error: " + e); } }
static int getServerIdForAlias(ORB orb, String applicationName) throws ServerNotRegistered { try { Repository rep = RepositoryHelper.narrow( orb.resolve_initial_references(ORBConstants.SERVER_REPOSITORY_NAME)); int serverid = rep.getServerID(applicationName); return rep.getServerID(applicationName); } catch (Exception ex) { throw (new ServerNotRegistered()); } }
public boolean processCommand(String[] cmdArgs, ORB orb, PrintStream out) { int serverId = illegalServerId; try { if (cmdArgs.length == 2) { if (cmdArgs[0].equals("-serverid")) serverId = (Integer.valueOf(cmdArgs[1])).intValue(); else if (cmdArgs[0].equals("-applicationName")) serverId = ServerTool.getServerIdForAlias(orb, cmdArgs[1]); } // the server id has to be specified if (serverId == illegalServerId) return parseError; // deactivate server, hold it down and and unregister it // deactivate the server try { Activator activator = ActivatorHelper.narrow( orb.resolve_initial_references(ORBConstants.SERVER_ACTIVATOR_NAME)); activator.uninstall(serverId); } catch (ServerHeldDown ex) { } // unregister the server from the repository Repository repository = RepositoryHelper.narrow( orb.resolve_initial_references(ORBConstants.SERVER_REPOSITORY_NAME)); repository.unregisterServer(serverId); // print success message out.println(CorbaResourceUtil.getText("servertool.unregister2")); } catch (ServerNotRegistered ex) { out.println(CorbaResourceUtil.getText("servertool.nosuchserver")); } catch (Exception ex) { ex.printStackTrace(); } return commandDone; }
public boolean processCommand(String[] cmdArgs, ORB orb, PrintStream out) { ServerDef serverDef; // process the list active servers command try { Repository repository = RepositoryHelper.narrow( orb.resolve_initial_references(ORBConstants.SERVER_REPOSITORY_NAME)); Activator activator = ActivatorHelper.narrow( orb.resolve_initial_references(ORBConstants.SERVER_ACTIVATOR_NAME)); int[] servers = activator.getActiveServers(); out.println(CorbaResourceUtil.getText("servertool.list2")); ListServers.sortServers(servers); for (int i = 0; i < servers.length; i++) { try { serverDef = repository.getServer(servers[i]); out.println( "\t " + servers[i] + "\t\t" + serverDef.serverName + "\t\t" + serverDef.applicationName); } catch (ServerNotRegistered e) { } } } catch (Exception ex) { ex.printStackTrace(); } return commandDone; }
// Set up the client private void onConnectClicked() { // Create the arguments array String args[] = { "-ORBInitialHost", serverAddressField.getText(), "-ORBInitialPort", serverPortField.getText() }; try { // create and initialize the ORB ORB orb = ORB.init(args, null); // get the root naming context org.omg.CORBA.Object objRef = orb.resolve_initial_references("NameService"); // Use NamingContextExt instead of NamingContext. This is // part of the Interoperable naming Service. ncRef = NamingContextExtHelper.narrow(objRef); // resolve the Object Reference in Naming String name = "AuctionFactory"; auctionFactoryImpl = AuctionFactoryHelper.narrow(ncRef.resolve_str(name)); appletDisplay("Connected to server"); // Activate the login functionality btnLogIn.setEnabled(true); usernameField.setEnabled(true); passwordField.setEnabled(true); } catch (Exception e) { appletDisplay("Unable to connect to server"); System.out.println("ERROR : " + e); e.printStackTrace(System.out); // Deactivate functionality btnLogIn.setEnabled(false); usernameField.setEnabled(false); passwordField.setEnabled(false); btnRefresh.setEnabled(false); sellList.setEnabled(false); bidList.setEnabled(false); btnCreateNewAuction.setEnabled(false); txtDescription.setEnabled(false); txtStartingPrice.setEnabled(false); btnSellItem.setEnabled(false); btnBid.setEnabled(false); txtBidPrice.setEnabled(false); loggedIn = false; } }
static { orb = ORB.init(new String[0], null); System.setProperty( "javax.rmi.CORBA.PortableRemoteObjectClass", PortableRemoteObjectDelegateImpl.class.getName()); PortableRemoteObjectDelegateImpl.setORB(orb); try { POA poa = POAHelper.narrow(orb.resolve_initial_references("RootPOA")); poa.the_POAManager().activate(); } catch (InvalidName e) { initException = e; } catch (AdapterInactive e) { initException = e; } }
public boolean processCommand(String[] cmdArgs, ORB orb, PrintStream out) { try { Repository repository = RepositoryHelper.narrow( orb.resolve_initial_references(ORBConstants.SERVER_REPOSITORY_NAME)); String[] applicationNames = repository.getApplicationNames(); out.println(CorbaResourceUtil.getText("servertool.listappnames2")); out.println(); for (int i = 0; i < applicationNames.length; i++) out.println("\t" + applicationNames[i]); } catch (Exception ex) { ex.printStackTrace(); } return commandDone; }
private ORB getOrbForServer(int port) throws InvalidName, AdapterInactive, WrongPolicy, ServantNotActive, IOException { System.setProperty("org.omg.CORBA.ORBInitialPort", String.valueOf(port)); final ORB orb = ORB.init(new String[0], null); System.clearProperty("org.omg.CORBA.ORBInitialPort"); POA rootPOA = POAHelper.narrow(orb.resolve_initial_references("RootPOA")); rootPOA.the_POAManager().activate(); org.omg.CORBA.Object objref = rootPOA.servant_to_reference(new LibraryImpl(rootPOA)); iorString = orb.object_to_string(objref); return orb; }
/** * <code>test192Op</code> dummy impl. * * @return an <code>boolean</code> value depending upon the result of the interceptors. true for * local; false for not local. */ public boolean test192Op() { boolean result = false; try { Current current = (Current) orb.resolve_initial_references("PICurrent"); Any anyName = current.get_slot(SInitializer.slotID); result = anyName.extract_boolean(); } catch (InvalidSlot e) { e.printStackTrace(); throw new INTERNAL(e.toString()); } catch (InvalidName e) { e.printStackTrace(); throw new INTERNAL(e.toString()); } return result; }
@Override public void start(StartContext context) throws StartException { JacORBLogger.ROOT_LOGGER.debugServiceStartup( context.getController().getName().getCanonicalName()); ORB orb = this.orbInjector.getOptionalValue(); POA parentPOA = this.parentPOAInjector.getOptionalValue(); // if an ORB has been injected, we will use the ORB.resolve_initial_references method to // instantiate the POA. if (orb != null) { try { this.poa = POAHelper.narrow(orb.resolve_initial_references(this.poaName)); } catch (Exception e) { throw JacORBMessages.MESSAGES.errorResolvingInitRef(this.poaName, e); } } // if a parent POA has been injected, we use it to create the policies and then the POA itself. else if (parentPOA != null) { try { Policy[] poaPolicies = this.createPolicies(parentPOA); this.poa = parentPOA.create_POA(this.poaName, null, poaPolicies); } catch (Exception e) { throw JacORBMessages.MESSAGES.errorCreatingPOAFromParent(e); } } else { throw JacORBMessages.MESSAGES.invalidPOACreationArgs(); } // check if the POA should be bound to JNDI under java:/jboss. if (this.bindingName != null) { CorbaServiceUtil.bindObject(context.getChildTarget(), this.bindingName, this.poa); } // activate the created POA. try { this.poa.the_POAManager().activate(); } catch (Exception e) { throw JacORBMessages.MESSAGES.errorActivatingPOA(e); } }
@Override public void start(StartContext context) throws StartException { log.debugf("Starting Service " + context.getController().getName().getCanonicalName()); ORB orb = this.orbInjector.getOptionalValue(); POA parentPOA = this.parentPOAInjector.getOptionalValue(); // if an ORB has been injected, we will use the ORB.resolve_initial_references method to // instantiate the POA. if (orb != null) { try { this.poa = POAHelper.narrow(orb.resolve_initial_references(this.poaName)); } catch (Exception e) { throw new StartException("Failed to resolve initial reference " + this.poaName, e); } } // if a parent POA has been injected, we use it to create the policies and then the POA itself. else if (parentPOA != null) { try { Policy[] poaPolicies = this.createPolicies(parentPOA); this.poa = parentPOA.create_POA(this.poaName, null, poaPolicies); } catch (Exception e) { throw new StartException("Failed to create POA from parent POA", e); } } else { throw new StartException( "Unable to instantiate POA: either the running ORB or the parent POA must be specified"); } // check if the POA should be bound to JNDI under java:/jboss. if (this.bindingName != null) { CorbaServiceUtil.bindObject(context.getChildTarget(), this.bindingName, this.poa); } // activate the created POA. try { this.poa.the_POAManager().activate(); } catch (Exception e) { throw new StartException("Failed to activate POA", e); } }
public static void main(String args[]) { try { // 创建和初始化ORB ORB orb = ORB.init(args, null); // 获得命名服务的Context org.omg.CORBA.Object objRef = orb.resolve_initial_references("NameService"); NamingContextExt ncRef = NamingContextExtHelper.narrow(objRef); // 获得名为“HelloService”的HelloService对象的远程引用 String name = "HelloService"; helloServiceImpl = HelloServiceHelper.narrow(ncRef.resolve_str(name)); // 调用HelloService对象的远程方法 System.out.println("Obtained a handle on server object: " + helloServiceImpl); System.out.println(helloServiceImpl.sayHello()); helloServiceImpl.shutdown(); } catch (Exception e) { System.out.println("ERROR : " + e); e.printStackTrace(System.out); } }