00001
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include <iostream.h>
00024 #include "BridgeStub.h"
00025 #include <OB/CORBA.h>
00026 #include <OB/CosNaming.h>
00027 #include "Parser.h"
00028 #include "StdAfx.h"
00029 #include "SoapCorba.h"
00030 #include "DbObjects.h"
00031 #include "ReadIR.h"
00032 #include "SoapBridge.h"
00033 #include "SoapBridge_skel.h"
00034 #include <sys/timeb.h>
00035 #include "sbimpl.h"
00036
00038 CORBA::ORB_ptr orb;
00039
00041 DynamicAny::DynAnyFactory_var dynFact;
00042
00044 IRPLUS_H irplusHandle;
00045
00047 CORBA::String_var ObjCtxMan_SIOR;
00048
00054 JTCMonitor *p_struct_tm_monitor;
00055
00057 int main (int argn, char *argv [])
00058 {
00059 sbInitialize ();
00060 p_struct_tm_monitor = new JTCMonitor;
00061 CORBA_H corbaHdl = initCorba (argn, argv);
00062 orb = (CORBA::ORB_ptr) corbaHdl;
00063 {
00064 CORBA::Object_var factObj = orb->resolve_initial_references ("DynAnyFactory");
00065 dynFact = DynamicAny::DynAnyFactory::_narrow (factObj);
00066 }
00067 irplusHandle = initIRPlus (corbaHdl, argv [1], argv [2], true);
00068 try {
00069 orb = (CORBA::ORB_ptr) corbaHdl;
00070 {
00071 CORBA::Object_var factObj = orb->resolve_initial_references ("DynAnyFactory");
00072 dynFact = DynamicAny::DynAnyFactory::_narrow (factObj);
00073 }
00074
00075 CORBA::Object_var poaObj = orb -> resolve_initial_references("RootPOA");
00076 PortableServer::POA_var poa = PortableServer::POA::_narrow(poaObj);
00077
00078
00079
00080
00081 PortableServer::POAManager_var manager = poa -> the_POAManager();
00082 manager -> activate();
00083
00084
00085
00086
00087
00088 AnyInterface *pi = new AnyInterface ();
00089 PortableServer::ObjectId_var id = poa -> activate_object(pi);
00090 CORBA::Object_var pDSI =
00091 poa -> create_reference_with_id(id, "IDL:CORBABridge:1.0");
00092 CORBA::String_var implDSI = orb -> object_to_string(pDSI);
00093 CosNaming::Name name;
00094 CosNaming::NamingContext_var inc;
00095 CosNaming::NamingContext_var myinc;
00096 try {
00097 CORBA::Object_var nms = orb->resolve_initial_references ("NameService");
00098 inc = CosNaming::NamingContext::_narrow (nms);
00099 assert (!CORBA::is_nil (inc));
00100 name.length (1);
00101 printf ("Binding %s to 'CORBABridge' naming context\n", argv [0]);
00102 name [0].id = CORBA::string_dup ("CORBABridge");
00103 name [0].kind = CORBA::string_dup ("");
00104 try {
00105 myinc = inc->bind_new_context (name);
00106 }
00107 catch (const CosNaming::NamingContext::AlreadyBound &) {
00108
00109 CORBA::Object_var ncb = inc->resolve (name);
00110 myinc = CosNaming::NamingContext::_narrow (ncb);
00111 }
00112 catch (...) {
00113 cout << "Fatal error: some exception while calling NameService!" << endl;
00114 }
00115 try {
00116 CosNaming::Name name2;
00117 name2.length (1);
00118 name2 [0].id = CORBA::string_dup ("CORBACall");
00119 name2 [0].kind = CORBA::string_dup ("");
00120 myinc->rebind (name2, pDSI);
00121 }
00122 catch (...) {
00123 printf ("Problem registering CORBABridge/CORBACall\n");
00124 return 2;
00125 }
00126 }
00127 catch (...) {
00128 cout << "Fatal error: could not contact NameService!" << endl;
00129 return -1;
00130 }
00131 }
00132 catch (...) {
00133 printf ("Back to the drawingboard\n");
00134 return 1;
00135 }
00136 orb->run ();
00137
00138 termCorba (corbaHdl);
00139 sbTerminate ();
00140 return 0;
00141 }
00142