1
// IDL_Cubit_Client.java,v 1.1 1998/09/16 00:26:33 schmidt Exp
3
// ============================================================================
6
// IDL_Cubit_Client.java
9
// Michael Kircher (mk1@cs.wustl.edu)
12
// Connects to the cubit factory, gets a cubit object and
13
// calls the cube_short method on it. The purpose of this
14
// class is to demonstrate how to use the JavaIDL ORB to access
17
// ============================================================================
20
public class IDL_Cubit_Client
23
private org.omg.CORBA.ORB orb_;
24
private org.omg.CORBA.Object naming_service_object_;
26
public void init (String[] args)
30
orb_ = org.omg.CORBA.ORB.init (args, null);
32
// Get the Naming Service initial reference
34
System.out.println ("Using the lookup protocol!");
35
NS_Resolve ns_resolve = new NS_Resolve ();
36
naming_service_object_ = ns_resolve.resolve_name_service (orb_);
39
catch(org.omg.CORBA.SystemException e) {
40
System.err.println ("PushConsumerFactory constructor: ORB and Name Service initialization");
41
System.err.println(e);
52
// Get the Naming Context to allow resolving the EventService and
54
CosNaming.NamingContext naming_context =
55
CosNaming.NamingContextHelper.narrow (naming_service_object_);
57
if (naming_context == null)
59
System.err.println ("The Naming Context is null");
62
System.out.println ("Reference to the Naming Service is ok.");
64
CosNaming.NameComponent[] cubit_factory_name = new CosNaming.NameComponent[2];
65
cubit_factory_name[0] = new CosNaming.NameComponent ("IDL_Cubit","");
66
cubit_factory_name[1] = new CosNaming.NameComponent ("cubit_factory","");
67
org.omg.CORBA.Object factory_obj = naming_context.resolve (cubit_factory_name);
69
if (factory_obj == null)
71
System.err.println ("Factory object is nil!");
75
Cubit_Factory cubit_Factory = Cubit_FactoryHelper.narrow (factory_obj);
77
Cubit cubit = cubit_Factory.make_cubit ("key0");
81
System.out.println ("The call cube_short (4) results in: " +cubit.cube_short (x));
84
catch (CosNaming.NamingContextPackage.CannotProceed e)
86
System.err.println ("CosNaming.NamingContextPackage.CannotProceed");
87
System.err.println (e);
89
catch (CosNaming.NamingContextPackage.InvalidName e)
91
System.err.println ("CosNaming.NamingContextPackage.InvalidName");
92
System.err.println (e);
94
catch (CosNaming.NamingContextPackage.NotFound e)
96
System.err.println ("CosNaming.NamingContextPackage.NotFound");
97
System.err.println (e);
99
catch(org.omg.CORBA.SystemException e)
101
System.err.println ("PushConsumerFactory.run: Failure");
102
System.err.println(e);
106
public static void main (String[] args) {
108
IDL_Cubit_Client cubit_Client = new IDL_Cubit_Client ();
109
cubit_Client.init (args);
115
} // public class IDL_Cubit_Client