User guide

C-5
Cisco Transport Manager Release 9.2 GateWay/CORBA User Guide and Programmer Manual
OL-20937-01
Appendix C OSS Use Cases and Client Development
C.2.2 Sample Code in Java
C.2.2 Sample Code in Java
A typical CORBA client application involves the following steps:
Step 1 Initialize the client connection to the object request broker (ORB).
Step 2 Obtain a reference to the naming service.
Step 3 Resolve the reference to EMSSessionFactory. See C.2.2.3 Get Reference to EMSSessionFactory,
page C-7.
Step 4 Implement NmsSession_IOperations. See C.2.2.4 Implement NmsSession_IOperations, page C-7.
Step 5 Retrieve EmsSession by supplying the username and password. See C.2.2.5 Log In and Retrieve
EmsSession, page C-8.
Step 6 Query EmsSession and obtain a list of managers available for operations. See C.2.2.6 Retrieve List of
Managers, page C-9.
Step 7 Invoke the desired method on that manager. See C.2.2.7 getEMS Operation on EMS Manager, page C-9.
If you want your client to receive notifications from CTM GateWay/CORBA, the following additional
steps are required:
Step 8 Obtain a reference to an EventChannel object in the notification server in Step 2.
Step 9 Obtain a ConsumerAdmin object reference.
Step 10 Invoke obtain_notification_push_consumer() on the SupplierAdmin object, specifying
CosNotifyChannelAdmin::STRUCTURED_EVENT as a parameter. This operation returns a reference
to the StructuredProxyPushSupplier.
Step 11 Implement an instance of StructuredPushConsumer (defined by the OMG).
Step 12 Invoke the connect_structured_push_consumer() operation on the StructuredProxyPushSupplier object
to connect the StructuredPushConsumer implementation object to the notification channel.
Step 13 Monitor incoming notifications.
The following sections show sample Java code for the steps required to develop a client application.
Note The sample code shown is for illustrative purposes only; the code might not compile as shown. The
sample code does not handle all exceptions.
C.2.2.1 Initialize the Client Connection
// Import OMG packages
import org.omg.CORBA.IntHolder;
import org.omg.CORBA.ORB;
import org.omg.CORBA.Policy;
// Import naming context packages.
import org.omg.CosNaming.NameComponent;
import org.omg.CosNaming.NamingContextExt;
import org.omg.CosNaming.NamingContextExtHelper;
// Import notify channel and event service packages.
import org.omg.CosEventChannelAdmin.AlreadyConnected;