コード例 #1
0
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;
}
コード例 #2
0
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;
}
コード例 #3
0
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;
}
コード例 #4
0
static void
test_activation (void)
{
	CORBA_Environment   env;
	PortableServer_POA  poa;
	GSList             *objids = NULL, *l;
	int                 i;

	fprintf (stderr, "Testing object activation...\n");

	CORBA_exception_init (&env);

	POA_Test__init (&test_servant, &env);

	poa = create_mult_id_poa (&env);

	g_assert (env._major == CORBA_NO_EXCEPTION);

	g_timer_reset (timer);

	for (i = 0; i < 1000; i++) {
		PortableServer_ObjectId *objid;

		objid = PortableServer_POA_activate_object (poa, &test_servant, &env);
		g_assert (env._major == CORBA_NO_EXCEPTION);

		objids = g_slist_append (objids, objid);
	}

	elapsed_time = g_timer_elapsed (timer, NULL);
	bogomark += elapsed_time;
	fprintf (stderr, " activation : %g(ms)\n", elapsed_time);

	g_timer_reset (timer);

	for (l = objids; l; l = l->next) {
		PortableServer_POA_deactivate_object (poa, l->data, &env);
		g_assert (env._major == CORBA_NO_EXCEPTION);
	}

	elapsed_time = g_timer_elapsed (timer, NULL);
	bogomark += elapsed_time;
	fprintf (stderr, " de-activation : %g(ms)\n", elapsed_time);
	
	for (l = objids; l; l = l->next)
		CORBA_free (l->data);
	g_slist_free (objids);

	POA_Test__fini (&test_servant, &env);

	PortableServer_POA_destroy (poa, CORBA_FALSE, CORBA_FALSE, &env);
	g_assert (env._major == CORBA_NO_EXCEPTION);
	CORBA_Object_release ((CORBA_Object) poa, &env);
	g_assert (env._major == CORBA_NO_EXCEPTION);

	CORBA_exception_free (&env);
}
コード例 #5
0
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;
	
}
コード例 #6
0
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;
}
コード例 #7
0
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;
}
コード例 #8
0
/* 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);
}
コード例 #9
0
ファイル: test-mem.c プロジェクト: OS2World/SYSTEM-OS-Voyager
static void
test_activate_deactivate (PortableServer_POA poa, CORBA_Environment * ev)
{
   impl_POA_Test *newservant;
   PortableServer_ObjectId *objid;

   newservant = g_new0(impl_POA_Test, 1);
   newservant->servant.vepv = &impl_Test_vepv;

   POA_Test__init((PortableServer_Servant) newservant, ev);

   objid = PortableServer_POA_activate_object(poa, newservant, ev);
   g_assert (!ORBIT_EX (ev));

   PortableServer_POA_deactivate_object (poa, objid, ev);
   g_assert (!ORBIT_EX (ev));

   CORBA_free(objid);
}
コード例 #10
0
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;
}
コード例 #11
0
ファイル: pyorbit-poa.c プロジェクト: GNOME/pyorbit
static PyObject *
pyorbit_poa_activate_object(PyCORBA_Object *self, PyObject *args)
{
    CORBA_Environment ev;
    PyPortableServer_Servant *pyservant;
    PortableServer_ServantBase *servant;
    PortableServer_ObjectId *id;
    PyObject *ret;

    if (!PyArg_ParseTuple(args, "O!:POA.activate_object",
			  &PyPortableServer_Servant_Type, &pyservant))
	return NULL;
    servant = PYSERVANT_TO_SERVANT(pyservant);

    CORBA_exception_init(&ev);
    id = PortableServer_POA_activate_object((PortableServer_POA)self->objref,
					    servant, &ev);
    if (pyorbit_check_ex(&ev))
	return NULL;

    ret = PyString_FromStringAndSize((char *) id->_buffer, id->_length);
    CORBA_free(id);
    return ret;
}
コード例 #12
0
ファイル: empty-server.c プロジェクト: Distrotech/libbonobo
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;
}
コード例 #13
0
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 RETAIN servant retention policy, USE_DEFAULT_SERVANT
     * request processing policy and MULTIPLE_ID id uniqueness policy.
     */
    poa_policies           = CORBA_PolicyList__alloc ();
    poa_policies->_maximum = 3;
    poa_policies->_length  = 3;
    poa_policies->_buffer  = CORBA_PolicyList_allocbuf (3);
    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_request_processing_policy (
                                   rootpoa,
                                   PortableServer_USE_DEFAULT_SERVANT,
                                   &ev);

    poa_policies->_buffer[2] = (CORBA_Policy)
                               PortableServer_POA_create_servant_retention_policy (
                                   rootpoa,
                                   PortableServer_RETAIN,
                                   &ev);

    child_poa = PortableServer_POA_create_POA (rootpoa,
                "Default Servant 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_Policy_destroy (poa_policies->_buffer[2], &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;
    }

    /*
     * Register the default servant.
     */
    PortableServer_POA_set_servant (child_poa, &poatest_servant, &ev);
    if (POATEST_EX (&ev)) {
        POATEST_PRINT_EX ("set_servant : ", &ev);
        return CORBA_OBJECT_NIL;
    }

    /*
     * Activate an object.
     */
    objid = PortableServer_POA_activate_object (child_poa, &poatest_servant, &ev);
    if (POATEST_EX (&ev)) {
        POATEST_PRINT_EX ("activate_object : ", &ev);
        return CORBA_OBJECT_NIL;
    }
    CORBA_free (objid);

    /*
     * Create a reference for an inactive object.
     */
    poatest_obj = PortableServer_POA_create_reference (child_poa, "IDL:poatest:1.0", &ev);
    if (POATEST_EX (&ev)) {
        POATEST_PRINT_EX ("create_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;
}