Registration

Name

Registration -- Registering CORBA objects to OAF.

Synopsis

#include <liboaf/liboaf.h>


enum        OAF_RegistrationResult;
OAF_RegistrationResult oaf_active_server_register
                                            (const char *iid,
                                             CORBA_Object obj);
void        oaf_active_server_unregister    (const char *iid,
                                             CORBA_Object obj);
struct      OAFPlugin;
struct      OAFPluginObject;
void        oaf_plugin_use                  (PortableServer_Servant servant,
                                             gpointer impl_ptr);
void        oaf_plugin_unuse                (gpointer impl_ptr);

Description

When writing a component which can be activated through OAF by clients, you need to be register your component to OAF once it is created.

Details

enum OAF_RegistrationResult

   typedef enum
   {
      OAF_REG_SUCCESS,
      OAF_REG_NOT_LISTED,
      OAF_REG_ALREADY_ACTIVE,
      OAF_REG_ERROR
   }
   OAF_RegistrationResult;


oaf_active_server_register ()

OAF_RegistrationResult oaf_active_server_register
                                            (const char *iid,
                                             CORBA_Object obj);

Registers obj with iid in the local OAF daemon.

iid : IID of the server to register.
obj : CORBA::Object to register.
Returns : status of the registration.


oaf_active_server_unregister ()

void        oaf_active_server_unregister    (const char *iid,
                                             CORBA_Object obj);

Unregisters obj with iid in the local OAF daemon.

iid : IID of the server to unregister.
obj : CORBA::Object to unregister.


struct OAFPlugin

typedef struct
{
	const OAFPluginObject *plugin_object_list;
	const char *description;
}
OAFPlugin;

Components which want to be activated as shared libraries must export an OAFPlugin structure of name OAF_Plugin_info. An exmaple of how to use it folows:
static CORBA_Object
hi_shlib_make_object (PortableServer_POA poa,
                      const char *iid,
                      gpointer impl_ptr,
                      CORBA_Environment *ev)
{
        CORBA_Object object_ref;

        object_ref = impl_Hi__create (poa, ev);
        if (object_ref == CORBA_OBJECT_NIL 
            || ev->_major != CORBA_NO_EXCEPTION) {
                printf ("Server cannot get objref\n");
                return CORBA_OBJECT_NIL;
        }

        oaf_plugin_use (poa, impl_ptr);

        return object_ref;
}

static const OAFPluginObject hi_plugin_list[] = {
        {
                "OAFIID:Hi:20000923",
                hi_shlib_make_object
        },
        {
                NULL
  	}
};

const OAFPlugin OAF_Plugin_info = {
        hi_plugin_list,
        "Hi example"
};


struct OAFPluginObject

typedef struct
{
	const char *iid;

	/* This routine should call oaf_plugin_use(servant, impl_ptr), 
         * as should all routines which activate CORBA objects
	 * implemented by this shared library. This needs to be done 
         * before making any CORBA calls on the object, or
	 * passing that object around. First thing after servant creation 
         * always works. :) 
         */

        CORBA_Object (*activate) (PortableServer_POA poa,
                                  const char *iid, 
                                  gpointer impl_ptr,	/* This pointer should be stored by the implementation
                                                         * to be passed to oaf_plugin_unuse() in the 
                                                         * implementation's destruction routine. */
				    CORBA_Environment * ev);
}
OAFPluginObject;


oaf_plugin_use ()

void        oaf_plugin_use                  (PortableServer_Servant servant,
                                             gpointer impl_ptr);

You should call this routine to activate a shared library-based CORBA Object. It will be called by OAF if the component exports correctly an OAFPlugin structure named "OAF_Plugin_info".

servant : The servant that was created
impl_ptr : The impl_ptr that was passed to the original activation routine


oaf_plugin_unuse ()

void        oaf_plugin_unuse                (gpointer impl_ptr);

Side effects: May arrange for the shared library that the implementation is in to be unloaded.

When a shlib plugin for a CORBA object is destroying an implementation, it should call this function to make sure that the shared library is unloaded as needed.

impl_ptr : The impl_ptr that was passed to the activation routine