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); }
static Examples_ByteSeq_Storage impl_Examples_ByteSeq_Storage__create(PortableServer_POA poa, CORBA_Environment * ev) { Examples_ByteSeq_Storage retval; impl_POA_Examples_ByteSeq_Storage *newservant; PortableServer_ObjectId *objid; newservant = g_new0(impl_POA_Examples_ByteSeq_Storage, 1); newservant->servant.vepv = &impl_Examples_ByteSeq_Storage_vepv; newservant->poa = (PortableServer_POA) CORBA_Object_duplicate((CORBA_Object) poa, ev); POA_Examples_ByteSeq_Storage__init((PortableServer_Servant) newservant, ev); /* Before servant is going to be activated all * private attributes must be initialized. */ /* ------ init private attributes here ------ */ newservant->chunk = ORBit_sequence_alloc (TC_CORBA_sequence_CORBA_octet, 64); /* ------ ---------- end ------------- ------ */ objid = PortableServer_POA_activate_object(poa, newservant, ev); CORBA_free(objid); retval = PortableServer_POA_servant_to_reference(poa, newservant, ev); return retval; }
static Examples_BadCall impl_Examples_BadCall__create(PortableServer_POA poa, CORBA_Environment * ev) { Examples_BadCall retval; impl_POA_Examples_BadCall *newservant; PortableServer_ObjectId *objid; newservant = g_new0(impl_POA_Examples_BadCall, 1); newservant->servant.vepv = &impl_Examples_BadCall_vepv; newservant->poa = (PortableServer_POA) CORBA_Object_duplicate((CORBA_Object) poa, ev); POA_Examples_BadCall__init((PortableServer_Servant) newservant, ev); /* Before servant is going to be activated all * private attributes must be initialized. */ /* ------ init private attributes here ------ */ newservant->counter=0; /* init */ /* ------ ---------- end ------------- ------ */ objid = PortableServer_POA_activate_object(poa, newservant, ev); CORBA_free(objid); retval = PortableServer_POA_servant_to_reference(poa, newservant, ev); return retval; }
GNOME_FileManagerWindow impl_GNOME_FileManagerFactory_create_window(impl_POA_GNOME_FileManagerFactory * servant, CORBA_char * dir, CORBA_Environment * ev) { GNOME_FileManagerWindow retval; impl_POA_GNOME_FileManagerWindow *newservant; PortableServer_ObjectId *objid; newservant = g_new0(impl_POA_GNOME_FileManagerWindow, 1); newservant->servant.vepv = &impl_GNOME_FileManagerWindow_vepv; newservant->poa = poa; newservant->mywin = new_panel_at ((dir && *dir) ? dir : home_dir); gtk_signal_connect(GTK_OBJECT(newservant->mywin->xwindow), "destroy", impl_GNOME_FileManagerWindow_close, newservant); POA_GNOME_FileManagerWindow__init((PortableServer_Servant) newservant, ev); objid = PortableServer_POA_activate_object(poa, newservant, ev); CORBA_free(objid); retval = PortableServer_POA_servant_to_reference(poa, newservant, ev); return retval; }
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 Wise2HSP_HSPmanagerFactory impl_Wise2HSP_HSPmanagerFactory__create(PortableServer_POA poa, CORBA_Environment *ev) { Wise2HSP_HSPmanagerFactory retval; impl_POA_Wise2HSP_HSPmanagerFactory *newservant; PortableServer_ObjectId *objid; newservant = g_new0(impl_POA_Wise2HSP_HSPmanagerFactory, 1); newservant->servant.vepv = &impl_Wise2HSP_HSPmanagerFactory_vepv; newservant->poa = poa; POA_Wise2HSP_HSPmanagerFactory__init((PortableServer_Servant)newservant, ev); objid = PortableServer_POA_activate_object(poa, newservant, ev); CORBA_free(objid); retval = PortableServer_POA_servant_to_reference(poa, newservant, ev); return retval; }
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); }
/* Create a reference for our private server object */ static Elvis_ElvisPrivate ElvisPrivateServer_create (PortableServer_POA poa, CORBA_Environment *ev) { ElvisPrivateServant *eps; PortableServer_ObjectId *objid; /* Intialise the function pointers in the class */ Elvis_ElvisPrivate_init (); /* Create a servant instance and set its virtual method table up? */ eps=g_new0(ElvisPrivateServant, 1); eps->servant.vepv = &elvis_elvisprivate_vepv; POA_Elvis_ElvisPrivate__init ((PortableServer_Servant) eps, ev); objid = PortableServer_POA_activate_object (poa, eps, ev); CORBA_free (objid); return PortableServer_POA_servant_to_reference (poa, eps, ev); }
Wise2HSP_HSPmanagerFactory new_Wise2HSP_HSPmanagerFactory(PortableServer_POA poa, Wise2_HSPScanInterface * hsi,CORBA_Environment * ev) { Wise2HSP_HSPmanagerFactory retval; impl_POA_Wise2HSP_HSPmanagerFactory *newservant; PortableServer_ObjectId *objid; newservant = g_new0(impl_POA_Wise2HSP_HSPmanagerFactory, 1); newservant->servant.vepv = &impl_Wise2HSP_HSPmanagerFactory_vepv; newservant->poa = poa; newservant->hsi = hsi; newservant->is_verbose = 1; POA_Wise2HSP_HSPmanagerFactory__init((PortableServer_Servant)newservant, ev); objid = PortableServer_POA_activate_object(poa, newservant, ev); CORBA_free(objid); retval = PortableServer_POA_servant_to_reference(poa, newservant, ev); return retval; }
static CORBA_Object activate_plugin (PortableServer_POA poa, const char *iid, gpointer impl_ptr, CORBA_Environment *ev) { CORBA_Object objref; POA_Plugin__init (&plugin_servant, ev); bonobo_activation_plugin_use (&plugin_servant, impl_ptr); bonobo_activation_plugin_impl_ptr = impl_ptr; objref = PortableServer_POA_servant_to_reference (poa, &plugin_servant, ev); return objref; }
static Wise2HSP_HSP_ts_iterator impl_Wise2HSP_HSP_ts_iterator__create(PortableServer_POA poa, LinearHSPmanager * lm,int max_size,CORBA_Environment * ev) { Wise2HSP_HSP_ts_iterator retval; impl_POA_Wise2HSP_HSP_ts_iterator *newservant; PortableServer_ObjectId *objid; newservant = g_new0(impl_POA_Wise2HSP_HSP_ts_iterator, 1); newservant->servant.vepv = &impl_Wise2HSP_HSP_ts_iterator_vepv; newservant->poa = poa; newservant->lm = lm; newservant->max_size = max_size; newservant->current_pos = 0; POA_Wise2HSP_HSP_ts_iterator__init((PortableServer_Servant) newservant, ev); objid = PortableServer_POA_activate_object(poa, newservant, ev); CORBA_free(objid); retval = PortableServer_POA_servant_to_reference(poa, newservant, ev); return retval; }
poatest poatest_run (PortableServer_POA rootpoa, PortableServer_POAManager rootpoa_mgr) { CORBA_Environment ev; poatest poatest_obj; CORBA_exception_init( &ev ); /* * Initialise the servant. */ POA_poatest__init (&poatest_servant, &ev); if (POATEST_EX (&ev)) { POATEST_PRINT_EX ("POA_poatest__init : ", &ev); return CORBA_OBJECT_NIL; } /* * Imlicitly activate the Object. * See sections 11.2.7 and 11.3.8.21. */ poatest_obj = PortableServer_POA_servant_to_reference (rootpoa, &poatest_servant, &ev); if (POATEST_EX (&ev)) { POATEST_PRINT_EX ("servant_to_reference : ", &ev); return CORBA_OBJECT_NIL; } /* * Activate the POAManager. POA will now accept requests */ PortableServer_POAManager_activate (rootpoa_mgr, &ev); if (POATEST_EX (&ev)) { POATEST_PRINT_EX ("POAManager_activate : ", &ev); return CORBA_OBJECT_NIL; } return poatest_obj; }
static PyObject * pyorbit_poa_servant_to_reference(PyCORBA_Object *self, PyObject *args) { CORBA_Environment ev; PyPortableServer_Servant *pyservant; PortableServer_ServantBase *servant; CORBA_Object reference; PyObject *py_reference; if (!PyArg_ParseTuple(args, "O!:POA.servant_to_reference", &PyPortableServer_Servant_Type, &pyservant)) return NULL; servant = PYSERVANT_TO_SERVANT(pyservant); CORBA_exception_init(&ev); reference = PortableServer_POA_servant_to_reference((PortableServer_POA)self->objref, servant, &ev); if (pyorbit_check_ex(&ev)) return NULL; py_reference = pycorba_object_new(reference); CORBA_Object_release(reference, NULL); return py_reference; }
poatest poatest_run (PortableServer_POA rootpoa, PortableServer_POAManager rootpoa_mgr) { CORBA_Environment ev; poatest poatest_obj1, poatest_obj2; CORBA_PolicyList *poa_policies; CORBA_exception_init( &ev ); /* * Create child POA with MULTIPLE_ID Object Id Uniqueness policy and * IMPLICIT_ACTIVATION Implicit Activation policy. */ poa_policies = CORBA_PolicyList__alloc (); poa_policies->_maximum = 2; poa_policies->_length = 2; poa_policies->_buffer = CORBA_PolicyList_allocbuf (2); CORBA_sequence_set_release (poa_policies, CORBA_TRUE); poa_policies->_buffer[0] = (CORBA_Policy) PortableServer_POA_create_id_uniqueness_policy ( rootpoa, PortableServer_MULTIPLE_ID, &ev); poa_policies->_buffer[1] = (CORBA_Policy) PortableServer_POA_create_implicit_activation_policy ( rootpoa, PortableServer_IMPLICIT_ACTIVATION, &ev); child_poa = PortableServer_POA_create_POA (rootpoa, "Multiple Id POA", rootpoa_mgr, poa_policies, &ev); if (POATEST_EX (&ev)) { POATEST_PRINT_EX ("create_POA : ", &ev); return CORBA_OBJECT_NIL; } CORBA_Policy_destroy (poa_policies->_buffer[0], &ev); CORBA_Policy_destroy (poa_policies->_buffer[1], &ev); CORBA_free (poa_policies); /* * Initialise the servant. */ POA_poatest__init (&poatest_servant, &ev); if (POATEST_EX (&ev)) { POATEST_PRINT_EX ("POA_poatest__init : ", &ev); return CORBA_OBJECT_NIL; } /* * Implicitly activate two objects. */ poatest_obj1 = PortableServer_POA_servant_to_reference (child_poa, &poatest_servant, &ev); if (POATEST_EX (&ev)) { POATEST_PRINT_EX ("servant_to_reference : ", &ev); return CORBA_OBJECT_NIL; } CORBA_Object_release (poatest_obj1, &ev); poatest_obj2 = PortableServer_POA_servant_to_reference (child_poa, &poatest_servant, &ev); if (POATEST_EX (&ev)) { POATEST_PRINT_EX ("servant_to_reference : ", &ev); return CORBA_OBJECT_NIL; } /* * Activate the POAManager. POA will now accept requests */ PortableServer_POAManager_activate (rootpoa_mgr, &ev); if (POATEST_EX (&ev)) { POATEST_PRINT_EX ("POAManager_activate : ", &ev); return CORBA_OBJECT_NIL; } return poatest_obj2; }
poatest poatest_run (PortableServer_POA rootpoa, PortableServer_POAManager rootpoa_mgr) { CORBA_Environment ev; poatest poatest_obj; CORBA_PolicyList *poa_policies; PortableServer_ObjectId *objid; CORBA_exception_init (&ev); /* * Create child POA with USER_ID Id Assignment policy. */ poa_policies = CORBA_PolicyList__alloc (); poa_policies->_maximum = 1; poa_policies->_length = 1; poa_policies->_buffer = CORBA_PolicyList_allocbuf (1); CORBA_sequence_set_release (poa_policies, CORBA_TRUE); poa_policies->_buffer[0] = (CORBA_Policy) PortableServer_POA_create_id_assignment_policy ( rootpoa, PortableServer_USER_ID, &ev); child_poa = PortableServer_POA_create_POA (rootpoa, "User Id POA", rootpoa_mgr, poa_policies, &ev); if (POATEST_EX (&ev)) { POATEST_PRINT_EX ("create_POA : ", &ev); return CORBA_OBJECT_NIL; } CORBA_Policy_destroy (poa_policies->_buffer[0], &ev); CORBA_free (poa_policies); /* * Initialise the servant. */ POA_poatest__init (&poatest_servant, &ev); if (POATEST_EX (&ev)) { POATEST_PRINT_EX ("POA_poatest__init : ", &ev); return CORBA_OBJECT_NIL; } /* * Set up the ObjectId. */ objid = PortableServer_string_to_ObjectId ("Test Id", &ev); if (POATEST_EX (&ev)) { POATEST_PRINT_EX ("string_to_ObjectId : ", &ev); return CORBA_OBJECT_NIL; } /* * Activate object with user assigned Id. */ PortableServer_POA_activate_object_with_id (child_poa, objid, &poatest_servant, &ev); if (POATEST_EX (&ev)) { POATEST_PRINT_EX ("activate_object_with_id : ", &ev); return CORBA_OBJECT_NIL; } CORBA_free (objid); poatest_obj = PortableServer_POA_servant_to_reference (child_poa, &poatest_servant, &ev); if (POATEST_EX (&ev)) { POATEST_PRINT_EX ("servant_to_reference : ", &ev); return CORBA_OBJECT_NIL; } /* * Activate the POAManager. POA will now accept requests */ PortableServer_POAManager_activate (rootpoa_mgr, &ev); if (POATEST_EX (&ev)) { POATEST_PRINT_EX ("POAManager_activate : ", &ev); return CORBA_OBJECT_NIL; } return poatest_obj; }
poatest poatest_run (PortableServer_POA rootpoa, PortableServer_POAManager rootpoa_mgr) { CORBA_Environment ev; poatest poatest_obj; CORBA_PolicyList *poa_policies; PortableServer_ObjectId *objid; CORBA_exception_init (&ev); /* * Create child POA with USER_ID Id Assignment and PERSISTENT lifespan policy. */ poa_policies = CORBA_PolicyList__alloc (); poa_policies->_maximum = 2; poa_policies->_length = 2; poa_policies->_buffer = CORBA_PolicyList_allocbuf (2); CORBA_sequence_set_release (poa_policies, CORBA_TRUE); poa_policies->_buffer[0] = (CORBA_Policy) PortableServer_POA_create_id_assignment_policy ( rootpoa, PortableServer_USER_ID, &ev); poa_policies->_buffer[1] = (CORBA_Policy) PortableServer_POA_create_lifespan_policy ( rootpoa, PortableServer_PERSISTENT, &ev); child_poa = PortableServer_POA_create_POA (rootpoa, "User Id and Persistent POA", rootpoa_mgr, poa_policies, &ev); if (POATEST_EX (&ev)) { POATEST_PRINT_EX ("create_POA : ", &ev); return CORBA_OBJECT_NIL; } /* * Initialise the servant. */ POA_poatest__init (&poatest_servant, &ev); if (POATEST_EX (&ev)) { POATEST_PRINT_EX ("POA_poatest__init : ", &ev); return CORBA_OBJECT_NIL; } /* * Set up the ObjectId. */ objid = PortableServer_string_to_ObjectId ("Test Id", &ev); if (POATEST_EX (&ev)) { POATEST_PRINT_EX ("string_to_ObjectId : ", &ev); return CORBA_OBJECT_NIL; } /* * Activate object with user assigned Id. */ PortableServer_POA_activate_object_with_id (child_poa, objid, &poatest_servant, &ev); if (POATEST_EX (&ev)) { POATEST_PRINT_EX ("activate_object_with_id : ", &ev); return CORBA_OBJECT_NIL; } /* * Get reference for object. */ poatest_obj = PortableServer_POA_servant_to_reference (child_poa, &poatest_servant, &ev); if (POATEST_EX (&ev)) { POATEST_PRINT_EX ("servant_to_reference : ", &ev); return CORBA_OBJECT_NIL; } /* * Deactivate object and destroy POA */ PortableServer_POA_deactivate_object(child_poa, objid, &ev); if (POATEST_EX (&ev)) { POATEST_PRINT_EX ("deactivate_object : ", &ev); return CORBA_OBJECT_NIL; } PortableServer_POA_destroy (child_poa, CORBA_FALSE, CORBA_FALSE, &ev); if (POATEST_EX (&ev)) { POATEST_PRINT_EX ("POA_destroy : ", &ev); return CORBA_OBJECT_NIL; } /* * Re-create POA and re-activate the object. */ child_poa = PortableServer_POA_create_POA (rootpoa, "User Id and Persistent POA", rootpoa_mgr, poa_policies, &ev); if (POATEST_EX (&ev)) { POATEST_PRINT_EX ("create_POA : ", &ev); return CORBA_OBJECT_NIL; } PortableServer_POA_activate_object_with_id (child_poa, objid, &poatest_servant, &ev); if (POATEST_EX (&ev)) { POATEST_PRINT_EX ("activate_object_with_id : ", &ev); return CORBA_OBJECT_NIL; } /* * Reference should still be valid. */ CORBA_free (objid); CORBA_Policy_destroy (poa_policies->_buffer[0], &ev); CORBA_Policy_destroy (poa_policies->_buffer[1], &ev); CORBA_free (poa_policies); /* * Activate the POAManager. POA will now accept requests */ PortableServer_POAManager_activate( rootpoa_mgr, &ev ); if (POATEST_EX (&ev)) { POATEST_PRINT_EX ("POAManager_activate : ", &ev); return CORBA_OBJECT_NIL; } return poatest_obj; }
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; }