home *** CD-ROM | disk | FTP | other *** search
Java Source | 1998-05-08 | 2.6 KB | 75 lines |
- /*
- * Copyright (c) 1997-1998 Borland International, Inc. All Rights Reserved.
- *
- * This SOURCE CODE FILE, which has been provided by Borland as part
- * of a Borland product for use ONLY by licensed users of the product,
- * includes CONFIDENTIAL and PROPRIETARY information of Borland.
- *
- * USE OF THIS SOFTWARE IS GOVERNED BY THE TERMS AND CONDITIONS
- * OF THE LICENSE STATEMENT AND LIMITED WARRANTY FURNISHED WITH
- * THE PRODUCT.
- *
- * IN PARTICULAR, YOU WILL INDEMNIFY AND HOLD BORLAND, ITS RELATED
- * COMPANIES AND ITS SUPPLIERS, HARMLESS FROM AND AGAINST ANY CLAIMS
- * OR LIABILITIES ARISING OUT OF THE USE, REPRODUCTION, OR DISTRIBUTION
- * OF YOUR PROGRAMS, INCLUDING ANY CLAIMS OR LIABILITIES ARISING OUT OF
- * OR RESULTING FROM THE USE, MODIFICATION, OR DISTRIBUTION OF PROGRAMS
- * OR FILES CREATED FROM, BASED ON, AND/OR DERIVED FROM THIS SOURCE
- * CODE FILE.
- */
- package visibroker.samples.locate;
-
- public class AccountFinder {
-
- private static void UsageHelper()
- {
- System.out.println("Unable to locate LocationService\n" +
- " -Make sure the locserv process is running\n" +
- " -Make sure you set the client's System Property\n" +
- " ORBservices=\"com.visigenic.vbroker.ObjLocation\"");
- }
-
- public static void main(String[] args)
- {
- try {
- // Initialize the ORB.
- org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init(args,null);
- // Initialize the BOA.
- org.omg.CORBA.BOA boa = orb.BOA_init();
- com.visigenic.vbroker.ObjLocation.Agent the_agent = null;
-
- try {
- org.omg.CORBA.Object obj =
- orb.resolve_initial_references("LocationService");
- if ((obj == null) ||
- ((the_agent=com.visigenic.vbroker.ObjLocation.AgentHelper.narrow(obj)) == null)) {
- UsageHelper();
- System.exit(1);
- }
- } catch (org.omg.CORBA.ORBPackage.InvalidName e) {
- System.out.println("Not able to resolve references " +
- "for LocationService");
- UsageHelper();
- System.exit(1);
- } catch (Exception e) {
- System.out.println("Caught exception: " + e);
- UsageHelper();
- System.exit(1);
- }
-
- org.omg.CORBA.Object[] accountRefs =
- the_agent.all_instances("IDL:Bank/AccountManager:1.0");
- System.out.println("Agent returned " + accountRefs.length +
- " object references");
- for (int i=0; i < accountRefs.length; i++) {
- System.out.println("Stringified IOR for account #" + (i+1) + ":");
- System.out.println(orb.object_to_string(accountRefs[i]));
- System.out.println();
- }
- } catch (Exception e) {
- System.out.println("Caught exception: " + e);
- System.exit(1);
- }
- }
- }
-