Java Code Examples for org.omg.CORBA.ORB#string_to_object()
The following examples show how to use
org.omg.CORBA.ORB#string_to_object() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CorbaUtils.java From cxf with Apache License 2.0 | 6 votes |
public static org.omg.CORBA.Object importObjectReference(ORB orb, String url) { org.omg.CORBA.Object result; if (url.startsWith("file:")) { return importObjectReferenceFromFile(orb, url.substring(5)); } else if ("IOR:".equalsIgnoreCase(url)) { throw new RuntimeException("Proxy not initialized. URL contains a invalid ior"); } String trimmedUrl = url.trim(); LastExport last = LAST_EXPORT_CACHE.get(); if (last != null && trimmedUrl.equals(last.getIor())) { return last.getRef(); } try { result = orb.string_to_object(trimmedUrl); } catch (java.lang.Exception ex) { throw new RuntimeException(ex); } return result; }
Example 2
Source File: CorbaUtils.java From cxf with Apache License 2.0 | 6 votes |
public static org.omg.CORBA.Object importObjectReferenceFromFile(ORB orb, String url) { org.omg.CORBA.Object result; java.io.File file = new java.io.File(url); if (!file.exists()) { throw new RuntimeException("Could not find file " + url + " to read the object reference"); } try (java.io.BufferedReader reader = new java.io.BufferedReader(new java.io.FileReader(file))) { String ior = reader.readLine(); if (ior == null) { throw new RuntimeException("Invalid object reference found in file " + url); } result = orb.string_to_object(ior.trim()); } catch (java.io.IOException ex) { throw new RuntimeException(ex); } return result; }
Example 3
Source File: OMCProxy.java From ipst with Mozilla Public License 2.0 | 5 votes |
/** * Initializes an ORB, converts the stringified OMC object to a real * CORBA object, and then narrows that object to an OmcCommunication * object. */ private static void setupOmcc(String stringifiedObjectReference) { /* Can't remember why this is needed. But it is. */ String[] args = {null}; ORB orb; orb = ORB.init(args, null); /* Convert string to object. */ org.omg.CORBA.Object obj = orb.string_to_object(stringifiedObjectReference); logOMCStatus("Corba IOR:" + stringifiedObjectReference); /* Convert object to OmcCommunication object. */ omcc = OmcCommunicationHelper.narrow(obj); }
Example 4
Source File: Client.java From cxf with Apache License 2.0 | 5 votes |
static int run(ORB orb, String[] args) throws UserException { // Get "hello" object // Resolve the HelloWorldImpl by using INS's corbaname url. // The URL locates the NameService running on localhost // and listening on 1050 and resolve 'HelloWorld' // from that NameService org.omg.CORBA.Object obj = orb.string_to_object("corbaname::localhost:1050#HelloWorld"); if (obj == null) { System.err.println("Client: Could not resolve target object"); return 1; } HelloWorld hello = HelloWorldHelper.narrow(obj); // Test our narrowed "hello" object System.out.println("Invoking greetMe..."); String result = null; if (args.length > 0) { result = hello.greetMe(args[args.length - 1]); } else { result = hello.greetMe("World"); } System.out.println("greetMe.result = " + result); return 0; }
Example 5
Source File: Client.java From cxf with Apache License 2.0 | 4 votes |
static int run(ORB orb, String[] args) throws UserException { // Get the Bank object org.omg.CORBA.Object obj = orb.string_to_object("corbaname::localhost:1050#Bank"); if (obj == null) { System.err.println("bank.Client: cannot read IOR from corbaname::localhost:1050#Bank"); return 1; } Bank bank = BankHelper.narrow(obj); // Test the method Bank.create_account() System.out.println("Creating account called \"Account1\""); Account account1 = bank.create_account("Account1"); System.out.println("Depositing 100.00 into account \"Account1\""); account1.deposit(100.00f); System.out.println("Current balance of \"Account1\" is " + account1.get_balance()); System.out.println(); // Test the method Bank.create_epr_account() System.out.println("Creating account called \"Account2\""); org.omg.CORBA.Object account2Obj = bank.create_epr_account("Account2"); Account account2 = AccountHelper.narrow(account2Obj); System.out.println("Depositing 5.00 into account \"Account2\""); account2.deposit(5.00f); System.out.println("Current balance of \"Account2\" is " + account2.get_balance()); System.out.println(); // Create two more accounts to use with the getAccount calls Account acc3 = bank.create_account("Account3"); acc3.deposit(200.00f); Account acc4 = bank.create_account("Account4"); acc4.deposit(400.00f); // Test the method Bank.get_account() System.out.println("Retrieving account called \"Account3\""); Account account3 = bank.get_account("Account3"); System.out.println("Current balance for \"Account3\" is " + account3.get_balance()); System.out.println("Depositing 10.00 into account \"Account3\""); account3.deposit(10.00f); System.out.println("New balance for account \"Account3\" is " + account3.get_balance()); System.out.println(); // Test the method Bank.get_epr_account() System.out.println("Retrieving account called \"Account4\""); Account account4 = bank.get_account("Account4"); System.out.println("Current balance for \"Account4\" is " + account4.get_balance()); System.out.println("Withdrawing 150.00 into account \"Account4\""); account4.deposit(-150.00f); System.out.println("New balance for account \"Account4\" is " + account4.get_balance()); System.out.println(); bank.remove_account("Account1"); bank.remove_account("Account2"); bank.remove_account("Account3"); bank.remove_account("Account4"); return 0; }