static void DeadReferenceObj_test (PortableServer_Servant servant, CORBA_Environment *ev) { PortableServer_Current poa_current; PortableServer_POA poa; CORBA_Object obj = CORBA_OBJECT_NIL; poa_current = (PortableServer_Current) CORBA_ORB_resolve_initial_references (global_orb, "POACurrent", ev); g_assert (ev->_major == CORBA_NO_EXCEPTION); poa = PortableServer_Current_get_POA (poa_current, ev); g_assert (ev->_major == CORBA_NO_EXCEPTION); obj = PortableServer_POA_servant_to_reference (poa, servant, ev); g_assert (ev->_major == CORBA_NO_EXCEPTION); g_assert (obj != CORBA_OBJECT_NIL); CORBA_Object_release ((CORBA_Object) obj, ev); CORBA_Object_release ((CORBA_Object) poa, ev); CORBA_Object_release ((CORBA_Object) poa_current, ev); }
Wise2Corba_Singleton * get_Wise2Corba_Singleton(int * argc,char ** argv,char * init_string) { if( static_init_string != NULL ) { if( strcmp(static_init_string,init_string) == 0 ) { return &singleton; } else { fprintf(stderr,"Trouble! Asked for orbs of different types %s and %s",init_string,static_init_string); return NULL; } } /* else, initiate orb */ singleton.ev = g_new0(CORBA_Environment,1); CORBA_exception_init(singleton.ev); singleton.orb = CORBA_ORB_init(argc,argv,init_string,singleton.ev); /* FIXME: Exception check! */ singleton.poa = (PortableServer_POA)CORBA_ORB_resolve_initial_references(singleton.orb, "RootPOA",singleton.ev); static_init_string = CORBA_string_dup(init_string); return &singleton; }
*/static void server_init (int *argc_ptr, char *argv[], CORBA_ORB *orb, PortableServer_POA *poa, CORBA_Environment *ev) { PortableServer_POA rootpoa = CORBA_OBJECT_NIL; PortableServer_POAManager rootpoa_mgr = CORBA_OBJECT_NIL; CORBA_Environment local_ev[1]; CORBA_exception_init(local_ev); /* init signal handling */ signal(SIGTERM, server_shutdown); /* create Object Request Broker (ORB) */ (*orb) = CORBA_ORB_init(argc_ptr, argv, "orbit-local-mt-orb", ev); if (etk_raised_exception(ev)) goto failed_orb; rootpoa = (PortableServer_POA) CORBA_ORB_resolve_initial_references(*orb, "RootPOA", ev); if (etk_raised_exception(ev)) goto failed_poa; rootpoa_mgr = PortableServer_POA__get_the_POAManager(rootpoa, ev); if (etk_raised_exception(ev)) goto failed_poamanager; /* create default POA with specific policies */ (*poa) = server_create_multi_threaded_poa (*orb, rootpoa, rootpoa_mgr, ev); if (etk_raised_exception(ev)) goto failed_child_poa; PortableServer_POAManager_activate(rootpoa_mgr, ev); if (etk_raised_exception(ev)) goto failed_activation; CORBA_Object_release ((CORBA_Object) rootpoa_mgr, ev); return; failed_activation: failed_child_poa: failed_poamanager: CORBA_Object_release ((CORBA_Object) rootpoa_mgr, local_ev); failed_poa: CORBA_ORB_destroy(*orb, local_ev); failed_orb: return; }
void corba_register_server (void) { int v; CORBA_Environment ev; CORBA_exception_init (&ev); orb = gnome_CORBA_ORB(); poa = CORBA_ORB_resolve_initial_references (orb, "RootPOA", &ev); if (ev._major != CORBA_NO_EXCEPTION){ printf ("Can not resolve initial reference to RootPOA"); return; } poa_manager = PortableServer_POA__get_the_POAManager (poa, &ev); if (ev._major != CORBA_NO_EXCEPTION){ printf ("Can not get the POAmanager"); return; } PortableServer_POAManager_activate (poa_manager, &ev); if (ev._major != CORBA_NO_EXCEPTION){ printf ("Can not get the POAmanager"); return; } /* * Initialize the Factory Object */ POA_GNOME_FileManagerFactory__init ( (POA_GNOME_FileManagerFactory*)&poa_filemanagerfactory_servant, &ev); if (ev._major != CORBA_NO_EXCEPTION){ printf ("Can not initialize FileManagerFactory object\n"); return; } /* Activate the object */ CORBA_free (PortableServer_POA_activate_object (poa, &poa_filemanagerfactory_servant, &ev)); /* Get a refeerence to te object */ filemanagerfactory_server = PortableServer_POA_servant_to_reference ( poa, &poa_filemanagerfactory_servant, &ev); v = goad_server_register ( NULL, filemanagerfactory_server, "gmc_FileManagerFactory", "server", &ev); if (v != 0) return; }
static void main_func(int argc, char *argv[]) { PortableServer_POA poa = CORBA_OBJECT_NIL; PortableServer_POAManager poa_manager = CORBA_OBJECT_NIL; CORBA_Environment ev[1]; CORBA_exception_init(ev); /* init signal handling */ signal(SIGINT, server_shutdown); signal(SIGTERM, server_shutdown); /* create Object Request Broker (ORB) */ global_orb = CORBA_ORB_init(&argc, argv, "orbit-local-treaded-orb", ev); g_assert (!ORBIT_EX (ev)); /* get Portable Object Adaptor (POA) */ poa = (PortableServer_POA) CORBA_ORB_resolve_initial_references(global_orb, "RootPOA", ev); g_assert (!ORBIT_EX (ev)); /* activate POA Manager */ poa_manager = PortableServer_POA__get_the_POAManager(poa, ev); g_assert (!ORBIT_EX (ev)); PortableServer_POAManager_activate(poa_manager, ev); g_assert (!ORBIT_EX (ev)); LEAK_DETECT_WITH_TOLERANCE (1000, test_ORBit_alloc (), 50); LEAK_DETECT_WITH_TOLERANCE (1000, test_ORBit_sequence (), 50); LEAK_DETECT_WITH_TOLERANCE (1000, test_activate_deactivate (poa, ev), 50); /* tear down the ORB */ CORBA_Object_release ((CORBA_Object) poa_manager, ev); g_assert (!ORBIT_EX (ev)); CORBA_Object_release ((CORBA_Object) poa, ev); g_assert (!ORBIT_EX (ev)); if (global_orb != CORBA_OBJECT_NIL) { /* going to destroy orb.. */ CORBA_ORB_destroy(global_orb, ev); g_assert (!ORBIT_EX (ev)); } }
CosNaming_NamingContext etk_get_name_service (CORBA_ORB orb, CORBA_Environment *ev) { CORBA_char *str=NULL; CORBA_Object ref = (CORBA_Object) CORBA_ORB_resolve_initial_references(orb, "NameService", ev); if (etk_raised_exception(ev)) return CORBA_OBJECT_NIL; return (CosNaming_NamingContext) ref; }
*/static void server_init (int *argc_ptr, char *argv[], CORBA_ORB *orb, PortableServer_POA *poa, CORBA_Environment *ev) { PortableServer_POAManager poa_manager = CORBA_OBJECT_NIL; CORBA_Environment local_ev[1]; CORBA_exception_init(local_ev); /* init signal handling */ signal(SIGINT, server_shutdown); signal(SIGTERM, server_shutdown); /* create Object Request Broker (ORB) */ (*orb) = CORBA_ORB_init(argc_ptr, argv, "orbit-local-mt-orb", ev); if (etk_raised_exception(ev)) goto failed_orb; (*poa) = (PortableServer_POA) CORBA_ORB_resolve_initial_references(*orb, "RootPOA", ev); if (etk_raised_exception(ev)) goto failed_poa; poa_manager = PortableServer_POA__get_the_POAManager(*poa, ev); if (etk_raised_exception(ev)) goto failed_poamanager; PortableServer_POAManager_activate(poa_manager, ev); if (etk_raised_exception(ev)) goto failed_activation; CORBA_Object_release ((CORBA_Object) poa_manager, ev); return; failed_activation: failed_poamanager: CORBA_Object_release ((CORBA_Object) poa_manager, local_ev); failed_poa: CORBA_ORB_destroy(*orb, local_ev); failed_orb: return; }
void corba_init(void *p) { PortableServer_ObjectId objid = {0, sizeof("Freeamp-ORBit"), "Freeamp-ORBit"}; PortableServer_POA poa; CORBA_Environment ev; char *retval; CORBA_ORB orb; FILE * ofp; int argc=1; char *argv; char *homedir; char iorfile[1024]; char tmpbuf[1] = {0}; tptr = p; // :TODO: this should be fixed to pass on argv? argv=&tmpbuf[0]; CORBA_exception_init(&ev); orb = CORBA_ORB_init(&argc, &argv, "orbit-local-orb", &ev); POA_Freeamp__init(&poa_freeamp_servant, &ev); poa = (PortableServer_POA)CORBA_ORB_resolve_initial_references(orb, "RootPOA", &ev); PortableServer_POAManager_activate(PortableServer_POA__get_the_POAManager(poa, &ev), &ev); PortableServer_POA_activate_object_with_id(poa, &objid, &poa_freeamp_servant, &ev); freeamp_client = PortableServer_POA_servant_to_reference(poa, &poa_freeamp_servant, &ev); if (!freeamp_client) { printf("Cannot get objref\n"); return; } homedir = getenv("HOME"); strncpy(iorfile, homedir, 1024); // :TODO: add error checking strncat(iorfile, "/.freeamp.ior", 1024); retval = CORBA_ORB_object_to_string(orb, freeamp_client, &ev); ofp = fopen(iorfile,"w"); fprintf(ofp,"%s", retval); fclose(ofp); CORBA_free(retval); fprintf(stdout,"FreeAMP-CORBA Ready. | Waiting for commands.\n"); fflush(stdout); CORBA_ORB_run(orb, &ev); }
static PortableServer_POA create_mult_id_poa (CORBA_Environment *ev) { PortableServer_POA rootpoa; PortableServer_POA retval; CORBA_PolicyList *policies; rootpoa = (PortableServer_POA) CORBA_ORB_resolve_initial_references (orb, "RootPOA", ev); g_assert (ev->_major == CORBA_NO_EXCEPTION); policies = CORBA_PolicyList__alloc (); policies->_maximum = 1; policies->_length = 1; policies->_buffer = CORBA_PolicyList_allocbuf (1); CORBA_sequence_set_release (policies, CORBA_TRUE); policies->_buffer[0] = (CORBA_Policy) PortableServer_POA_create_id_uniqueness_policy ( rootpoa, PortableServer_MULTIPLE_ID, ev); g_assert (ev->_major == CORBA_NO_EXCEPTION); retval = PortableServer_POA_create_POA (rootpoa, "Multiple Id POA", NULL, policies, ev); g_assert (ev->_major == CORBA_NO_EXCEPTION); CORBA_Policy_destroy (policies->_buffer[0], ev); CORBA_free (policies); g_assert (ev->_major == CORBA_NO_EXCEPTION); CORBA_Object_release ((CORBA_Object) rootpoa, ev); g_assert (ev->_major == CORBA_NO_EXCEPTION); return retval; }
/** * corba_init_server: * @void: * * Initializes the CORBA server for GMC. Returns whether initialization was * successful or not, and sets the global guignome_corba_have_server variable. * * Return value: TRUE if successful, FALSE otherwise. **/ int guignome_corba_init_server (void) { int retval; CORBA_Environment ev; retval = FALSE; CORBA_exception_init (&ev); /* Get the POA and create the server */ g_message("guignome_corba_init_server (1)\n"); poa = (PortableServer_POA) CORBA_ORB_resolve_initial_references (orb, "RootPOA", &ev); if (ev._major != CORBA_NO_EXCEPTION) goto out; CORBA_exception_free (&ev); g_message("guignome_corba_init_server (2)\n"); /* See if the servers are there */ ElvisPrivate_server = goad_server_activate_with_id ( NULL, "IDL:Elvis:ElvisPrivate:1.0", GOAD_ACTIVATE_EXISTING_ONLY, NULL); if (ElvisPrivate_server != CORBA_OBJECT_NIL) { guignome_corba_have_server = TRUE; retval = TRUE; g_message("guignome_corba_init_server (2b)\n"); } else retval = register_servers (); g_message("guignome_corba_init_server (3)\n"); out: return retval; }
int main (int argc, char *argv[]) { CORBA_ORB orb; CORBA_Environment* ev; PortableServer_ObjectId* oid; passlong account; PortableServer_POA root_poa; PortableServer_POAManager pm; CORBA_char* ior; ev = g_new0(CORBA_Environment,1); CORBA_exception_init(ev); /* Initialize the orb. The initialization routine checks the command * line parameters for directives that affect the orb */ orb = CORBA_ORB_init(&argc, argv, "orbit-local-orb", ev); root_poa = (PortableServer_POA) CORBA_ORB_resolve_initial_references(orb, "RootPOA", ev); /* ask for instanciation of one object account */ account = impl_passlong__create(root_poa, ev); /* Here we get the IOR for the acc object. Our "client" will use * the IOR to find the server to connect to */ ior = CORBA_ORB_object_to_string(orb, account, ev); /* print out the IOR, just so you can see what it looks like */ printf ("%s\n", ior); fflush(stdout); pm = PortableServer_POA__get_the_POAManager(root_poa, ev); PortableServer_POAManager_activate(pm,ev); CORBA_ORB_run(orb, ev); return (0); }
static PyObject * pycorba_orb_resolve_initial_references(PyCORBA_ORB *self, PyObject *args) { CORBA_Object objref; CORBA_Environment ev; gchar *identifier; PyObject *py_objref; if (!PyArg_ParseTuple(args, "s:CORBA.ORB.resolve_initial_references", &identifier)) return NULL; CORBA_exception_init(&ev); objref = CORBA_ORB_resolve_initial_references(self->orb, identifier, &ev); if (pymatecorba_check_ex(&ev)) return NULL; /* PortableServer::POA isn't a real CORBA object */ if (!strcmp(identifier, "RootPOA")) { return pymatecorba_poa_new((PortableServer_POA)objref); } py_objref = pycorba_object_new(objref); CORBA_Object_release(objref, NULL); return py_objref; }
int main (int argc, char **argv) { CORBA_Environment ev[1]; PortableServer_POA rootpoa, poa; CORBA_exception_init (ev); orb = CORBA_ORB_init (&argc, argv, "", ev); rootpoa = (PortableServer_POA) CORBA_ORB_resolve_initial_references (orb, "RootPOA", ev); g_assert (ev->_major == CORBA_NO_EXCEPTION); { poa = ORBit_POA_new_from (orb, rootpoa, "Foo", NULL, ev); g_assert (ev->_major == CORBA_NO_EXCEPTION); PortableServer_POA_destroy (poa, FALSE, FALSE, ev); CORBA_Object_release ((CORBA_Object) poa, ev); } CORBA_Object_release ((CORBA_Object) rootpoa, ev); CORBA_ORB_destroy (orb, ev); g_assert (ev->_major == CORBA_NO_EXCEPTION); CORBA_Object_release ((CORBA_Object) orb, ev); g_assert (ev->_major == CORBA_NO_EXCEPTION); CORBA_exception_free (ev); fprintf (stderr, "PASS: test-poa\n"); return 0; }
JNIEXPORT void JNICALL Java_org_pgj_chanells_corba_CORBAChanellWorker_run (JNIEnv * javaenv, jobject threadobj){ JNIEnv _javaenv = *javaenv; global_javaenv = javaenv; //--------------------------------------- // initialize class and method references //--------------------------------------- //chanell worker class and method ID`s chanell_worker_class = (*javaenv)->FindClass(javaenv, "org/pgj/chanells/corba/CORBAChanellWorker"); chanell_create_result = (*javaenv)->GetStaticMethodID(javaenv, chanell_worker_class, "createResultBean", "()Lorg/pgj/messages/Result;"); chanell_create_callreq = (*javaenv)->GetStaticMethodID(javaenv, chanell_worker_class, "createCallRequestBean", "()Lorg/pgj/messages/CallRequest;"); chanell_create_exception = (*javaenv)->GetStaticMethodID(javaenv, chanell_worker_class, "createExceptionBean", "()Lorg/pgj/messages/Exception;"); chanell_set_client = (*javaenv)->GetMethodID(javaenv, chanell_worker_class, "setClient","(ILorg/pgj/messages/Message;)V"); chanell_msg_arrival = (*javaenv)->GetMethodID(javaenv, chanell_worker_class, "msgArrival", "(Lorg/pgj/messages/Message;)V"); chanell_log = (*javaenv)->GetMethodID(javaenv, chanell_worker_class, "nativeLog", "(ILjava/lang/String;)V"); get_message = (*javaenv)->GetMethodID(javaenv, chanell_worker_class, "getMessage", "(Lorg/pgj/chanells/corba/CORBAClient;)Lorg/pgj/messages/Message;"); get_client = (*javaenv)->GetMethodID(javaenv, chanell_worker_class, "getClient", "(I)Lorg/pgj/chanells/corba/CORBAClient;"); //type mapper ID`s typemapper_interface = (*javaenv)->FindClass(javaenv, "org/pgj/typemapping/TypeMapper"); typemapper_map_method = (*javaenv)->GetMethodID(javaenv, typemapper_interface, "map", "([BLjava/lang/String;)Lorg/pgj/typemapping/Field;"); //message class message_class = (*javaenv)->FindClass(javaenv, STR_CLASS_MESSAGE); message_set_sid = (*javaenv)->GetMethodID(javaenv, message_class, "setSid", "(Ljava/lang/Object;)V"); message_get_sid = (*javaenv)->GetMethodID(javaenv, message_class, "getSid", "()Ljava/lang/Object;"); //result bean ID`s result_class = (*javaenv)->FindClass(javaenv, STR_CLASS_RESULT); result_setsize = (*javaenv)->GetMethodID(javaenv, result_class, "setSize","(II)V"); result_set =(*javaenv)->GetMethodID(javaenv, result_class, "set","(IILorg/pgj/typemapping/Field;)V"); result_get = (*javaenv)->GetMethodID(javaenv, result_class, "get","(II)Lorg/pgj/typemapping/Field;"); result_getrows = (*javaenv)->GetMethodID(javaenv, result_class, "getRows","()I"); result_getcolumns = (*javaenv)->GetMethodID(javaenv, result_class, "getColumns","()I"); //call request bean ID`s callreq_class = (*javaenv)->FindClass(javaenv, STR_CLASS_CALLREQ); callreq_set_method_name = (*javaenv)->GetMethodID(javaenv, callreq_class, "setMethodname", "(Ljava/lang/String;)V"); callreq_set_class_name = (*javaenv)->GetMethodID(javaenv, callreq_class, "setClassname", "(Ljava/lang/String;)V"); callreq_add_param = (*javaenv)->GetMethodID(javaenv, callreq_class, "addParam", "(Lorg/pgj/typemapping/Field;)V"); //exception bean ID`s error_class = (*javaenv)->FindClass(javaenv, STR_CLASS_EXCEPTION); error_get_message = (*javaenv)->GetMethodID(javaenv, error_class, "getMessage","()Ljava/lang/String;"); error_set_message = (*javaenv)->GetMethodID(javaenv, error_class, "getMessage","()Ljava/lang/String;"); error_get_stacktrace = (*javaenv)->GetMethodID(javaenv, error_class, "getStackTrace","()Ljava/lang/String;"); error_set_stacktrace = (*javaenv)->GetMethodID(javaenv, error_class, "setStackTrace","(Ljava/lang/String;)V"); error_get_classname = (*javaenv)->GetMethodID(javaenv, error_class, "getExceptionClassName","()Ljava/lang/String;"); error_set_classname = (*javaenv)->GetMethodID(javaenv, error_class, "setExceptionClassName","(Ljava/lang/String;)V"); message_sql = (*javaenv)->FindClass(javaenv, STR_CLASS_SQL); message_sql_cursor = (*javaenv)->FindClass(javaenv, STR_CLASS_SQL_CURSOR); sql_fetch_get_cursorname = (*javaenv)->GetMethodID(javaenv, message_sql_cursor, "getCursorName","()Ljava/lang/String;"); sql_fetch_set_cursorname = (*javaenv)->GetMethodID(javaenv, message_sql_cursor, "setCursorName","(Ljava/lang/String;)V"); message_sql_open_wia_sql = (*javaenv)->FindClass(javaenv, STR_CLASS_SQL_OPEN_SQL); message_sql_close = (*javaenv)->FindClass(javaenv, STR_CLASS_SQL_CLOSE); message_sql_fetch = (*javaenv)->FindClass(javaenv, STR_CLASS_SQL_FETCH); field_class = (*javaenv)->FindClass(javaenv, STR_CLASS_FIELD); field_get = (*javaenv)->GetMethodID(javaenv, field_class, "get","()[B"); field_rdbmstype = (*javaenv)->GetMethodID(javaenv, field_class, "rdbmsType","()Ljava/lang/String;"); if(_javaenv->ExceptionOccurred(javaenv)){ return; } worker_nlog(javaenv, threadobj, WNL_DEBUG,"-----corba-----\n"); //------------ // Start CORBA //------------ CORBA_exception_init(&env); orb = CORBA_ORB_init(&argc, argv, "orbit-local-orb", &env); poa = (PortableServer_POA) CORBA_ORB_resolve_initial_references(orb, "RootPOA", &env); poa_manager = PortableServer_POA__get_the_POAManager(poa, &env); PortableServer_POAManager_activate(poa_manager, &env); server = impl_org_pgj_corba_CallServer__create(poa, &env, javaenv, threadobj); worker_nlog(javaenv, threadobj, WNL_DEBUG,"starting orb\n"); //publish IOR { char* ior; jmethodID putIor; jclass workerclass; jbyteArray bior; gunichar ior_utf; worker_nlog(javaenv, threadobj, WNL_DEBUG, "critical area\n"); ior = CORBA_ORB_object_to_string(orb, server, &env); ior_utf = g_utf8_get_char(ior); bior = _javaenv->NewByteArray(javaenv, strlen(ior)); if(_javaenv->ExceptionCheck(javaenv)){ worker_nlog(javaenv, threadobj, WNL_FATAL, "problems"); return; } _javaenv->SetByteArrayRegion(javaenv, bior, 0, strlen(ior), ior); if(_javaenv->ExceptionCheck(javaenv)){ worker_nlog(javaenv, threadobj, WNL_ERROR, "error occured"); return; } workerclass = _javaenv->GetObjectClass(javaenv, threadobj); if(_javaenv->ExceptionCheck(javaenv)){ worker_nlog(javaenv, threadobj, WNL_ERROR, "problems"); return; } putIor = _javaenv->GetMethodID(javaenv, workerclass, "putIor", "([B)V"); if(_javaenv->ExceptionCheck(javaenv)){ worker_nlog(javaenv, threadobj, WNL_FATAL, "problems"); return; } worker_nlog(javaenv, threadobj, WNL_DEBUG, "publishing IOR"); _javaenv->CallObjectMethod(javaenv, threadobj, putIor, bior); if(_javaenv->ExceptionCheck(javaenv)){ worker_nlog(javaenv, threadobj, WNL_FATAL, "Error publishing IOR! Stoping!"); return; } worker_nlog(javaenv, threadobj, WNL_INFO, "IOR published successfuly"); } //publish IOR CORBA_ORB_run(orb, &env); worker_nlog(javaenv, threadobj, WNL_FATAL, "ORB run returned. There must be something problem here."); }
/** * matecomponent_activation_activate_shlib_server: * @sh: * @ev: * * Private function. * * Return value: */ CORBA_Object matecomponent_activation_activate_shlib_server (MateComponent_ActivationResult *sh, CORBA_Environment *ev) { CORBA_Object retval; const MateComponentActivationPlugin *plugin; ActivePluginInfo *local_plugin_info = NULL; const MateComponentActivationPluginObject *pobj; int i; PortableServer_POA poa; CORBA_ORB orb; char *filename; const char *iid; g_return_val_if_fail (sh->res._d == MateComponent_ACTIVATION_RESULT_SHLIB, CORBA_OBJECT_NIL); g_return_val_if_fail (sh->res._u.res_shlib._length > 0, CORBA_OBJECT_NIL); MATECOMPONENT_ACTIVATION_LOCK (); /* The location info is at the end to of the string list */ filename = sh->res._u.res_shlib._buffer[sh->res._u.res_shlib._length - 1]; if (living_by_filename) local_plugin_info = g_hash_table_lookup (living_by_filename, filename); if (!local_plugin_info) { /* We have to load the thing from scratch */ GModule *gmod; gboolean success; gmod = g_module_open (filename, G_MODULE_BIND_LAZY); if (!gmod) { char *error_string; MateComponent_GeneralError *error = MateComponent_GeneralError__alloc (); error_string = g_strdup_printf ( _("g_module_open of `%s' failed with `%s'"), filename, g_module_error ()); error->description = CORBA_string_dup (error_string); CORBA_exception_set (ev, CORBA_USER_EXCEPTION, ex_MateComponent_GeneralError, error); g_free (error_string); MATECOMPONENT_ACTIVATION_UNLOCK (); return CORBA_OBJECT_NIL; /* Couldn't load it */ } success = g_module_symbol (gmod, "MateComponent_Plugin_info", (gpointer *) &plugin); if (!success) { char *error_string; MateComponent_GeneralError *error = MateComponent_GeneralError__alloc (); g_module_close (gmod); error_string = g_strdup_printf ( _("Can't find symbol MateComponent_Plugin_info in `%s'"), filename); error->description = CORBA_string_dup (error_string); CORBA_exception_set (ev, CORBA_USER_EXCEPTION, ex_MateComponent_GeneralError, error); g_free (error_string); MATECOMPONENT_ACTIVATION_UNLOCK (); return CORBA_OBJECT_NIL; } local_plugin_info = g_malloc (sizeof (ActivePluginInfo) + strlen (filename) + 1); local_plugin_info->refcount = 0; local_plugin_info->loaded = gmod; strcpy (local_plugin_info->filename, filename); if (!living_by_filename) living_by_filename = g_hash_table_new (g_str_hash, g_str_equal); g_hash_table_insert (living_by_filename, local_plugin_info->filename, local_plugin_info); } else { int success; success = g_module_symbol (local_plugin_info->loaded, "MateComponent_Plugin_info", (gpointer *) & plugin); if (!success) { char *error_string; MateComponent_GeneralError *error = MateComponent_GeneralError__alloc (); error_string = g_strdup_printf ( _("Can't find symbol MateComponent_Plugin_info in `%s'"), filename); error->description = CORBA_string_dup (error_string); CORBA_exception_set (ev, CORBA_USER_EXCEPTION, ex_MateComponent_GeneralError, error); g_free (error_string); MATECOMPONENT_ACTIVATION_UNLOCK (); return CORBA_OBJECT_NIL; } } retval = CORBA_OBJECT_NIL; orb = matecomponent_activation_orb_get (); poa = (PortableServer_POA) CORBA_ORB_resolve_initial_references (orb, "RootPOA", ev); /* Index into the string list one element from the end to get the iid of the shlib */ iid = sh->res._u.res_shlib._buffer[sh->res._u.res_shlib._length - 2]; for (pobj = plugin->plugin_object_list; pobj->iid; pobj++) { if (strcmp (iid, pobj->iid) == 0) { /* Found a match */ break; } } if (pobj->iid) { /* Activate the shlib */ retval = pobj->activate (poa, pobj->iid, local_plugin_info, ev); if (ev->_major != CORBA_NO_EXCEPTION) retval = CORBA_OBJECT_NIL; /* Activate the factiories contained in the shlib */ i = sh->res._u.res_shlib._length - 2; for (i--; i >= 0 && !CORBA_Object_is_nil (retval, ev); i--) { CORBA_Object new_retval; iid = sh->res._u.res_shlib._buffer[i]; new_retval = MateComponent_GenericFactory_createObject ( retval, (char *) iid, ev); if (ev->_major != CORBA_NO_EXCEPTION || CORBA_Object_is_nil (new_retval, ev)) { if (ev->_major == CORBA_NO_EXCEPTION) { MateComponent_GeneralError *error = MateComponent_GeneralError__alloc (); char *error_string = g_strdup_printf ( _("Factory `%s' returned NIL for `%s'"), pobj->iid, iid); error->description = CORBA_string_dup (error_string); CORBA_exception_set (ev, CORBA_USER_EXCEPTION, ex_MateComponent_GeneralError, error); g_free (error_string); } new_retval = CORBA_OBJECT_NIL; } CORBA_Object_release (retval, ev); retval = new_retval; } } else { MateComponent_GeneralError *error = MateComponent_GeneralError__alloc (); char *error_string = g_strdup_printf ( _("Shlib `%s' didn't contain `%s'"), filename, iid); error->description = CORBA_string_dup (error_string); CORBA_exception_set (ev, CORBA_USER_EXCEPTION, ex_MateComponent_GeneralError, error); g_free (error_string); } CORBA_Object_release ((CORBA_Object) poa, ev); MATECOMPONENT_ACTIVATION_UNLOCK (); return retval; }
int main (int argc, char *argv[]) { PortableServer_ObjectId *objid; PortableServer_POA poa; GOptionContext *ctx; GOptionGroup *goption_group; GError *error = NULL; GMainLoop *loop; CORBA_Environment ev; CORBA_ORB orb; GSList *reg_env = NULL; signal (SIGINT, do_exit); signal (SIGTERM, do_exit); g_thread_init (NULL); CORBA_exception_init (&ev); orb = bonobo_activation_init (argc, argv); g_set_prgname ("bonobo-activation-empty-server"); ctx = g_option_context_new (NULL); goption_group = bonobo_activation_get_goption_group (); g_option_context_set_main_group (ctx, goption_group); if (!g_option_context_parse (ctx, &argc, &argv, &error)) { g_printerr ("%s\n", error->message); g_error_free (error); exit (1); } g_option_context_free (ctx); POA_Empty__init (&poa_empty_servant, &ev); poa = (PortableServer_POA) CORBA_ORB_resolve_initial_references (orb, "RootPOA", &ev); objid = PortableServer_POA_activate_object (poa, &poa_empty_servant, &ev); empty_client = PortableServer_POA_servant_to_reference (poa, &poa_empty_servant, &ev); if (!empty_client) { printf ("Cannot get objref\n"); return 1; } #ifndef G_OS_WIN32 reg_env = bonobo_activation_registration_env_set ( reg_env, "DISPLAY", getenv ("DISPLAY")); reg_env = bonobo_activation_registration_env_set ( reg_env, "SESSION_MANAGER", getenv ("SESSION_MANAGER")); reg_env = bonobo_activation_registration_env_set ( reg_env, "AUDIODEV", getenv ("AUDIODEV")); #endif reg_env = bonobo_activation_registration_env_set ( reg_env, "LANG", getenv ("LANG")); /* * NB. It is imperative to register the server that is being * requested last - or we can still race in the activation daemon. */ bonobo_activation_register_active_server ("OAFIID:Empty2:19991025", empty_client, reg_env); g_usleep (500000); /* 1/2 sec */ bonobo_activation_register_active_server ("OAFIID:Empty:19991025", empty_client, reg_env); bonobo_activation_registration_env_free (reg_env); PortableServer_POAManager_activate (PortableServer_POA__get_the_POAManager (poa, &ev), &ev); /* run the CORBA main loop for a couple of seconds then quit */ loop = g_main_loop_new (NULL, FALSE); g_timeout_add (1000, (GSourceFunc) g_main_loop_quit, loop); g_main_loop_run (loop); bonobo_activation_active_server_unregister ("OAFIID:Empty:19991025", empty_client); bonobo_activation_active_server_unregister ("OAFIID:Empty2:19991025", empty_client); PortableServer_POA_deactivate_object (poa, objid, &ev); return 0; }
int main (int argc, char *argv[]) { CORBA_ORB orb; CORBA_Environment ev; CosNaming_NamingContext context; const char* progname = "matecorba-name-server"; #ifdef HAVE_SYSLOG openlog(progname, LOG_NDELAY | LOG_PID, LOG_DAEMON); syslog(LOG_INFO,"starting"); #endif #ifdef HAVE_SIGACTION { sigset_t empty_mask; struct sigaction act; sigemptyset(&empty_mask); act.sa_handler = signal_handler; act.sa_mask = empty_mask; act.sa_flags = 0; sigaction(SIGINT, &act, NULL); sigaction(SIGHUP, &act, NULL); sigaction(SIGSEGV, &act, NULL); sigaction(SIGABRT, &act, NULL); act.sa_handler = SIG_IGN; sigaction(SIGPIPE, &act, NULL); } #else signal(SIGINT, signal_handler); #ifdef SIGHUP signal(SIGHUP, signal_handler); #endif signal(SIGSEGV, signal_handler); signal(SIGABRT, signal_handler); #ifdef SIGPIPE signal(SIGPIPE, SIG_IGN); #endif #endif CORBA_exception_init (&ev); orb = CORBA_ORB_init (&argc, argv, "matecorba-local-orb", &ev); { GOptionContext *context; GError *error = NULL; gboolean result; context = g_option_context_new(""); g_option_context_add_main_entries(context, goptions, GETTEXT_PACKAGE); result = g_option_context_parse(context, &argc, &argv, &error); g_option_context_free(context); if (!result) { g_warning("%s: bad arguments: %s\n", progname, error->message); g_error_free(error); exit(1); } } { PortableServer_POA root_poa; PortableServer_POAManager pm; root_poa = (PortableServer_POA) CORBA_ORB_resolve_initial_references (orb, "RootPOA", &ev); context = MateCORBA_CosNaming_NamingContextExt_create (root_poa, &ev); pm = PortableServer_POA__get_the_POAManager (root_poa, &ev); PortableServer_POAManager_activate (pm, &ev); CORBA_Object_release((CORBA_Object)pm, &ev); CORBA_Object_release((CORBA_Object)root_poa, &ev); } { CORBA_char *objstr; objstr = CORBA_ORB_object_to_string (orb, context, &ev); g_print ("%s\n", objstr); fflush (stdout); CORBA_free(objstr); } if ( opt_corbaloc_key ) { CORBA_sequence_CORBA_octet okey; okey._length = strlen(opt_corbaloc_key); okey._buffer = opt_corbaloc_key; MateCORBA_ORB_forw_bind(orb, &okey, context, &ev); } CORBA_ORB_run (orb, &ev); /* Don't release until done (dont know why) */ CORBA_Object_release (context, &ev); #ifdef HAVE_SYSLOG syslog(LOG_INFO, "exiting"); #endif return 0; }