Implementation of GDA Providers

As a sample implementation of a GDA provider the gda-odbc will be used.

Makefile.am Entires for GDA Providers

First the relevant parts of the Makefile.am will be introduced.

(1)	    bin_PROGRAMS  = gda-odbc-srv

(2)	    lib_LTLIBRARIES = libgda_odbc.la 
	    
(3)	    IDLFILES = $(top_srcdir)/gda/gda.idl \
	             $(top_srcdir)/gda/gda-command.idl \
	             $(top_srcdir)/gda/gda-connection.idl \
	             $(top_srcdir)/gda/gda-error.idl \
	             $(top_srcdir)/gda/gda-fieldx.idl \
	             $(top_srcdir)/gda/gda-parameter.idl \
	             $(top_srcdir)/gda/gda-recordset.idl

(4)	    INCLUDES = -I. \
  	             -DGNOMELOCALEDIR=\""$(datadir)/locale"\" \
	             -I$(includedir) \
	             $(ORB_CFLAGS) \
	             $(GNOME_INCLUDEDIR)
(5)
	    gda_odbc_srv_SOURCES = main.c
(6)
	    gda_odbc_srv_LDADD   = \
		     libgda_odbc.la \
		     $(top_builddir)/iodbc/libiodbc.la \
		     $(GNORBA_LIBS) \
		     $(INTLLIBS)

(7)	    libgda_odbc_la_SOURCES = \
		     gda-types.h \
		     gda-command.h    \
	        ..........
(8)	             gnome-shlib.c

(9)	    gda.h: $(IDLFILES)
    	             orbit-idl -I$(top_srcdir)/gda $(top_srcdir)/gda/gda.idl
	    gda-common.c: $(IDLFIaLES)
	             orbit-idl -I$(top_srcdir)/gda $(top_srcdir)/gda/gda.idl
	  

31Makefile.am Entries

(1)
The name of the executable provider. The name should have the prefix gda and the suffix srv.
(2)
The name of the shared library provider. The name should have the prefix libgda and no suffix.
(3)
The IDL files for the GDA Client/Server interface.
(4)
Include files used by the provider
(5)
Minimalistic main function for the provider.
(6)
Libraries needed for the provider. Note that the shared library type provider libgda_odbc.la is also mentioned here. The main implementation is done in this shared library and the main program only provides initialization of ORBit and the shared library.
(7)
Enumeration of the files which implement the provider. The gnome-shlib.c entry is mandatory.
(8)
Initialization functions and data structures for ORBit shared library servers. From functions in this file the initialization functions of the server should be called.
(9)
Rules to generate the include file, the skeleton and the common CORBA files from the IDL files.

main Function for Executable Type Providers

	  int main(int argc, char* argv[])
	  {
	    CORBA_ORB                 orb;
	    CORBA_Environment*        ev;
	    CORBA_Object              connection_factory_obj;
	    CORBA_Object              name_service;
	    gpointer                  servant;
	    PortableServer_POA        root_poa;
	    PortableServer_POAManager pm;
	    CORBA_char*               objref;
	    FILE*                     logstream;
	    struct sigaction          sa;
	    int                       output_fd;

	    sa.sa_handler = SIG_IGN;
	    sigaction(SIGPIPE, &sa, 0);
	    
	    logstream = fopen("/tmp/gda-odbc-srv.log", "a");
	    g_log_set_handler("GDA ODBC", 0xffffffff, g_log_2_file, logstream);

	    ev = g_new0(CORBA_Environment,1);

	    CORBA_exception_init(ev);

	    orb = gnome_CORBA_init("gda-odbc-srv", "0.1", &argc, argv, GNORBA_INIT_SERVER_FUNC, ev);
	    Exception(ev);
	    root_poa = (PortableServer_POA)CORBA_ORB_resolve_initial_references(orb, "RootPOA", ev);
	    Exception(ev);
	    
	    connection_factory_obj = connection_factory__create(root_poa, &servant, ev);
	    
	    Exception(ev);
	    objref                 = CORBA_ORB_object_to_string(orb, connection_factory_obj, ev);
	    Exception(ev);
	    name_service = gnome_name_service_get();
	    if (!CORBA_Object_is_nil(name_service, ev))
	      {
	         goad_server_register(name_service, connection_factory_obj, "gda-odbc", "object", ev);
	         printf("%s\n", objref); fflush(stdout);
	      }
	    output_fd = fileno(logstream);
	    setvbuf(stderr, 0, _IOLBF, 0);
	    setvbuf(stdout, 0, _IOLBF, 0);
	    dup2(output_fd, fileno(stdout));
	    dup2(output_fd, fileno(stderr));
	    close(output_fd);
	    pm = PortableServer_POA__get_the_POAManager(root_poa, ev);
	    Exception(ev);
	    PortableServer_POAManager_activate(pm, ev);
	    Exception(ev);
	    CORBA_ORB_run(orb, ev);
	    return 0;
	  }