/*dumb marshalling hack */
static void
matecomponent_activation_registration_iterate (const MateComponentActivationBaseService *base_service,
			  CORBA_Object obj, CORBA_Environment *ev,
			  gulong offset, int nargs)
{
	GSList *link;
	char *ior = NULL;

	if (nargs == 4)
		ior = CORBA_ORB_object_to_string (matecomponent_activation_orb_get (), obj, ev);

	for (link = registries; link; link = link->next) {
		RegistryInfo *ri;
		void (*func_ptr) ();

		ri = link->data;

		func_ptr = *(gpointer *) ((guchar *) ri->registry + offset);

		if (!func_ptr)
			continue;

		switch (nargs) {
		case 4:
			func_ptr (ri->registry, ior, base_service, ri->user_data);
			break;
		case 2:
			func_ptr (ri->registry, ri->user_data);
			break;
		}
	}

	if (nargs == 4)
		CORBA_free (ior);
}
static void
create_bag (void)
{
	PropData   *pd = g_new0 (PropData, 1);
	BonoboArg  *def;
	char       *dstr;
	CORBA_char *ior;
	FILE       *iorfile;

	pd->i = 987654321;
	pd->l = 123456789;
	pd->b = TRUE;
	pd->f = 2.71828182845;
	pd->d = 3.14159265358;
	pd->s = "Hello world";

	/* Create the property bag. */
	pb = bonobo_property_bag_new (get_prop, set_prop, pd);

	dstr = "Testing 1 2 3";

	/* Add properties */
	bonobo_property_bag_add (pb, "int-test", PROP_INTEGER_TEST,
				 BONOBO_ARG_INT, NULL, dstr, 0);

	def = bonobo_arg_new (BONOBO_ARG_STRING);
	BONOBO_ARG_SET_STRING (def, "a default string");

	bonobo_property_bag_add (pb, "string-test", PROP_STRING_TEST,
				 BONOBO_ARG_STRING, def, dstr, 
				 Bonobo_PROPERTY_READABLE |
				 Bonobo_PROPERTY_WRITEABLE);

	bonobo_property_bag_add (pb, "long-test", PROP_LONG_TEST,
				 BONOBO_ARG_LONG, NULL, dstr, 0);

	bonobo_property_bag_add (pb, "boolean-test", PROP_BOOLEAN_TEST,
				 BONOBO_ARG_BOOLEAN, NULL, dstr, 0);

	def = bonobo_arg_new (BONOBO_ARG_FLOAT);
	BONOBO_ARG_SET_FLOAT (def, 0.13579);
	bonobo_property_bag_add (pb, "float-test", PROP_FLOAT_TEST,
				 BONOBO_ARG_FLOAT, def, dstr, 0);

	bonobo_property_bag_add (pb, "double-test", PROP_DOUBLE_TEST,
				 BONOBO_ARG_DOUBLE, NULL, dstr, 0);

	iorfile = fopen ("iorfile", "wb");

	/* Print out the IOR for this object. */
	ior = CORBA_ORB_object_to_string (orb, BONOBO_OBJREF (pb), &ev);

	/* So we can tee the output to compare */
	fwrite (ior, strlen (ior), 1, iorfile);
	fclose (iorfile);

	CORBA_free (ior);
}
示例#3
0
文件: corba.c 项目: pontocom/opensdrm
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);
}
void
etk_export_object_to_stream (CORBA_ORB          orb,
			     CORBA_Object       servant,
			     FILE              *stream,
			     CORBA_Environment *ev)
{
        CORBA_char *objref = NULL;
 
        /* write objref to file */
         
        objref = CORBA_ORB_object_to_string (orb, servant, ev);
        if (etk_raised_exception(ev)) return;
 
        /* print ior to terminal */
        fprintf (stream, "%s\n", objref);
        fflush (stream);
 
        CORBA_free (objref);
}
示例#5
0
static PyObject *
pycorba_orb_object_to_string(PyCORBA_ORB *self, PyObject *args)
{
    CORBA_string ret;
    CORBA_Environment ev;
    PyCORBA_Object *obj;
    PyObject *pyret;

    if (!PyArg_ParseTuple(args, "O!:CORBA.ORB.object_to_string",
			  &PyCORBA_Object_Type, &obj))
	return NULL;

    CORBA_exception_init(&ev);
    ret = CORBA_ORB_object_to_string(self->orb, obj->objref, &ev);

    if (pymatecorba_check_ex(&ev))
	return NULL;

    pyret = PyString_FromString(ret);
    CORBA_free(ret);
    return pyret;
}
示例#6
0
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);
}
示例#7
0
文件: main.c 项目: justinzane/navit
int main(int argc, char **argv)
{
#if 0
        CORBA_Environment ev;
        CORBA_ORB orb;
	Map map_client = CORBA_OBJECT_NIL;
#endif
	char *gps;

	setenv("LC_NUMERIC","C",1);
	setlocale(LC_ALL,"");
	setlocale(LC_NUMERIC,"C");
	gtk_set_locale();
	setlocale(LC_NUMERIC,"C");
	debug_init();
	gtk_init(&argc, &argv);
	gdk_rgb_init();

// 	i18n basic support

	bindtextdomain( "navit", "./locale" );
	textdomain( "navit" );

	map_data_default=load_maps(NULL);
	plugin_load();
	co=gui_gtk_window(1300000,7000000,32);
	
	co->route=route_new();
	route_mapdata_set(co->route, co->map_data); 
	gps=getenv("GPSDATA");
	if (gps) {
		co->vehicle=vehicle_new(gps);
		if (co->vehicle) {
			co->cursor=cursor_new(co,co->vehicle);
			sdl_gui_new(co->vehicle);
		}
	} else {
		g_warning(gettext("Environment-Variable GPSDATA not set - No gps tracking. Set it to file:filename or gpsd://host[:port]"));
	}
	co->speech=speech_new();
	if (! co->speech) 
		g_warning(gettext("Can't connect to speechd, no speech output available"));
	speech_handle=co->speech;
	if (co->vehicle)
		co->compass=compass_new(co);
	if (co->vehicle)
		co->track=track_new(co->map_data);


#if 0
        CORBA_exception_init(&ev);
        orb = CORBA_ORB_init(&argc, argv, "orbit-local-orb", &ev);
        g_assert(ev._major == CORBA_NO_EXCEPTION);

        map_srv_start_poa(orb, &ev);
        g_assert(ev._major == CORBA_NO_EXCEPTION);
        map_client = map_srv_start_object(&ev, map);
        retval = CORBA_ORB_object_to_string(orb, map_client, &ev);
        g_assert(ev._major == CORBA_NO_EXCEPTION);
	ior=fopen("map.ior","w");
	if (ior) {
  		fprintf(ior, "%s\n", retval);
		fclose(ior);
	}
        CORBA_free(retval);
#endif

	initSDL();
	gtk_main();
	return 0;
}
/* Copied largely from goad.c, goad_server_activate_exe() */
static CORBA_Object
od_server_activate_exe (MateComponent_ServerInfo                  *si,
			ODActivationInfo                   *actinfo,
			CORBA_Object                        od_obj,
			const MateComponent_ActivationEnvironment *environment,
			CORBA_Environment                  *ev)
{
	char **args;
	char *extra_arg, *ctmp, *ctmp2;
        int fd_arg;
	int i;
        char *iorstr, *iid;
        CORBA_Object retval;

	/* Munge the args */
	args = g_alloca (36 * sizeof (char *));
#ifndef G_OS_WIN32
        /* Split location_info into executable pathname and command-line
         * arguments.
         */
	for (i = 0, ctmp = ctmp2 = si->location_info; i < 32; i++) {
		while (*ctmp2 && !g_ascii_isspace ((guchar) *ctmp2))
			ctmp2++;
		if (!*ctmp2)
			break;

		args[i] = g_alloca (ctmp2 - ctmp + 1);
		strncpy (args[i], ctmp, ctmp2 - ctmp);
		args[i][ctmp2 - ctmp] = '\0';

		ctmp = ctmp2;
		while (*ctmp2 && g_ascii_isspace ((guchar) *ctmp2))
			ctmp2++;
		if (!*ctmp2)
			break;
		ctmp = ctmp2;
	}
	if (!g_ascii_isspace ((guchar) *ctmp) && i < 32)
		args[i++] = ctmp;
        if (i > 1)
                g_warning ("Passing command-line arguments in .server files is deprecated: \"%s\"", si->location_info);
#else
        /* We don't support command-line arguments in the location on
         * Win32, as the executable pathname might well contain spaces
         * itself (C:\Program Files\Evolution 2.6.2\libexec\...).
         * location_info is just the executable's pathname.
         */
        args[0] = g_alloca (strlen (si->location_info) + 1);
        strcpy (args[0], si->location_info);
        i = 1;
#endif

	extra_arg =
		g_alloca (strlen (si->iid) +
			    sizeof ("--oaf-activate-iid="));
	args[i++] = extra_arg;
	sprintf (extra_arg, "--oaf-activate-iid=%s", si->iid);

        fd_arg = i;
	extra_arg = g_alloca (sizeof ("--oaf-ior-fd=") + 10);
	args[i++] = "--oaf-ior-fd=%d";


        iorstr = CORBA_ORB_object_to_string (
                matecomponent_activation_orb_get (), od_obj, ev);

        if (ev->_major != CORBA_NO_EXCEPTION)
	  iorstr = NULL;

        if(actinfo->flags & MateComponent_ACTIVATION_FLAG_PRIVATE) {
                extra_arg = g_alloca (sizeof ("--oaf-private"));
                args[i++] = extra_arg;
                g_snprintf (extra_arg, sizeof ("--oaf-private"),
                            "--oaf-private");
        }

	args[i] = NULL;

        iid = g_strdup (si->iid);

        /* Here comes the too clever by 1/2 bit:
         *   we drop the (recursive) 'server_lock' - so we
         *   can get other threads re-entering / doing activations
         *   here. cf. od_server_activate_factory
         */
        {
                ServerLockState state;

                state = server_lock_drop ();
                /*
                 * We set the process group of activated servers to our process group;
                 * this allows people to destroy all OAF servers along with oafd
                 * if necessary
                 */
                retval = matecomponent_activation_server_by_forking
                        ( (const char **) args, TRUE, fd_arg, environment, iorstr,
                          iid, FALSE, matecomponent_object_directory_re_check_fn, actinfo, ev);

                server_lock_resume (state);
        }

        g_free (iid);

	CORBA_free (iorstr);

        return retval;
}
示例#9
0
文件: test1-use.c 项目: berkus/flick
int main(int argc, char **argv)
{
	CORBA_ORB orb = 0;
	CORBA_Object obj;
#define C_DECLV(type) CORBA_##type	ret##type, in##type, out##type, inout##type
#define T_DECLV(type) test1_##type	ret##type, in##type, out##type, inout##type
	C_DECLV(short);
	C_DECLV(long);
	T_DECLV(ushort);
	T_DECLV(ulong);
	C_DECLV(float);
	C_DECLV(double);
	C_DECLV(char);
	C_DECLV(boolean);
	C_DECLV(octet);
	C_DECLV(Object);
	
	CORBA_char *instring, *outstring, *inoutstring, *retstring;
	CORBA_long case_num;
	CORBA_Environment ev;
	
	orb = CORBA_ORB_init(&argc, argv, 0 /* use default ORBid */, &ev);
	obj = CORBA_ORB_string_to_object(orb, argv[1], &ev);
	if (ev._major != CORBA_NO_EXCEPTION) {
		printf("Problem converting `%s' to an object.\n", argv[1]);
		exit(1);
	}
	printf("Beginning communication...\n");
#define SHOWPARMS(prn, type)						    \
	if (ev._major != CORBA_NO_EXCEPTION)				    \
		printf("Exception: `%s' EXCEPTION RAISED FOR " #type "!\n", \
		       CORBA_exception_id(&ev));			    \
	else								    \
		printf("Exception: no\n");				    \
	printf("In:       " #prn"\n", in##type);			    \
	printf("Inout:    " #prn"\n", inout##type);			    \
	printf("Out:      " #prn"\n", out##type);			    \
	printf("Result:   " #prn"\n", ret##type);
#define RUNTEST(type, inval, inoutval, otherval, prn)			\
	in##type = inval;						\
	inout##type = inoutval;						\
	ret##type = out##type = otherval;				\
	ev._major = CORBA_NO_EXCEPTION;					\
	printf("Testing " #type" Before Call:\n");			\
	SHOWPARMS(##prn, ##type);					\
	printf("Calling Server...\n");					\
	ret##type = test1_test_##type(obj, in##type, &out##type,	\
				      &inout##type, &ev);		\
	printf("After Call:\n");					\
	SHOWPARMS(##prn, ##type);
	
	RUNTEST(short, 1234, 4321, 7, %d);
	RUNTEST(ushort, 65500, 33000, 6, %d);
	RUNTEST(long, 12341234, 43214321, 2, %d);
	RUNTEST(ulong, 3000000000U, 4000000000U, 5, %u);
	RUNTEST(float, 1.234, 2.345, 3.1415, %f);
	RUNTEST(double, 1.2345678901, 2.3456789012, 2.71828, %f);
	RUNTEST(boolean, 0, 1, 2, %d);
	RUNTEST(octet, 12, 23, 34, %d);
	RUNTEST(char, 'a', 'b', 'c', %c);
	
	/* Must allocate the `inout' string with the CORBA allocator. */
	inoutstring = (char *) CORBA_alloc(sizeof("Howdy"));
	(void)strcpy(inoutstring, "Howdy");
	RUNTEST(string, "Hello", inoutstring, "Ugh", %s);
	
	/* Now run the object passing test */
        inObject = CORBA_Object_duplicate(obj, &ev);
        inoutObject = CORBA_Object_duplicate(obj, &ev);
	/* check for exception */
        retObject = outObject = 0;
        printf("Testing Object Before Call:\n");
	if (ev._major != CORBA_NO_EXCEPTION)
		printf("Exception: `%s' EXCEPTION RAISED FOR Object!\n",
		       CORBA_exception_id(&ev));
	else
		printf("Exception: no\n");
        printf("In:       %p\nURL:\t%s\nIOR:\t%s\n", inObject,
	       CORBA_ORB_object_to_readable_string(orb, inObject, &ev),
	       CORBA_ORB_object_to_string(orb, inObject, &ev));
        printf("Inout:    %p\nURL:\t%s\nIOR:\t%s\n", (void *)inoutObject,
	       CORBA_ORB_object_to_readable_string(orb, inoutObject, &ev),
	       CORBA_ORB_object_to_string(orb, inoutObject, &ev));
        printf("Out:      %p\nURL:\t%s\nIOR:\t%s\n", (void *)outObject,
	       CORBA_ORB_object_to_readable_string(orb, outObject, &ev),
	       CORBA_ORB_object_to_string(orb, outObject, &ev));
        printf("Result:   %p\nURL:\t%s\nIOR:\t%s\n", (void *)retObject,
	       CORBA_ORB_object_to_readable_string(orb, retObject, &ev),
	       CORBA_ORB_object_to_string(orb, retObject, &ev));
        printf("Calling Server...\n");
        retObject = test1_test_Object(obj, inObject, &outObject, &inoutObject,
				      &ev);
        printf("After Call:\n");
	if (ev._major != CORBA_NO_EXCEPTION) 
		printf("Exception: `%s' EXCEPTION RAISED FOR Object!\n",
		       CORBA_exception_id(&ev));
	else
		printf("Exception: no\n");
        printf("In:       %p\nURL:\t%s\nIOR:\t%s\n", inObject,
	       CORBA_ORB_object_to_readable_string(orb, inObject, &ev),
	       CORBA_ORB_object_to_string(orb, inObject, &ev));
        printf("Inout:    %p\nURL:\t%s\nIOR:\t%s\n", inoutObject,
	       CORBA_ORB_object_to_readable_string(orb, inoutObject, &ev),
	       CORBA_ORB_object_to_string(orb, inoutObject, &ev));
        printf("Out:      %p\nURL:\t%s\nIOR:\t%s\n", outObject,
	       CORBA_ORB_object_to_readable_string(orb, outObject, &ev),
	       CORBA_ORB_object_to_string(orb, outObject, &ev));
        printf("Result:   %p\nURL:\t%s\nIOR:\t%s\n", retObject,
	       CORBA_ORB_object_to_readable_string(orb, retObject, &ev),
	       CORBA_ORB_object_to_string(orb, retObject, &ev));
	
	for (case_num = -1; case_num <= 5; case_num++) {
		ev._major = CORBA_NO_EXCEPTION;
		printf("Testing test_throw Before Call:\n"); 	
		if (ev._major != CORBA_NO_EXCEPTION) 
			printf("Exception: `%s' EXCEPTION RAISED FOR throw!\n",
			       CORBA_exception_id(&ev));	       
		else
			printf("Exception: no\n");
		printf("In:       %d\n", case_num);
		printf("Calling Server...\n");
		test1_test_throw(obj, case_num, &ev);
		printf("After Call:\n");
		switch (ev._major) {
		case CORBA_USER_EXCEPTION:
			if (!strcmp(CORBA_exception_id(&ev), ex_test1_x1))
				printf("Caught exception test1_x1!  "
				       "Case_Num: %d\n",
				       ((test1_x1 *)
					CORBA_exception_value(&ev))
				       ->case_num);
			else if (!strcmp(CORBA_exception_id(&ev),
					 ex_test1_x2))
				printf("Caught exception test1_x2!  "
				       "Obj URL: %s,  value: %d\n",
				       CORBA_ORB_object_to_readable_string(
					       orb,
					       ((test1_x2 *)
						CORBA_exception_value(&ev))->
					       obj,
					       &ev),
				       ((test1_x2 *)
					CORBA_exception_value(&ev))->value);
			else
				printf("Unknown User Exception Raised: `%s' "
				       "for throw!\n",
				       CORBA_exception_id(&ev));
			break;
		case CORBA_SYSTEM_EXCEPTION:
			printf("Exception: `%s' EXCEPTION RAISED FOR throw!\n",
			       CORBA_exception_id(&ev));
			break;
		default:
			printf("Exception: no\n");
			printf("In:       %d\n", case_num);
		}
	}
	
	printf("About to tell the server to exit...\n");
	test1_please_exit(obj, &ev);
	printf("Server should be exiting any moment...\n");
	return 0;
}
示例#10
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.");
	
}
示例#11
0
/* used to be called CORBA_BOA_obj_is_ready, which was entirely wrong.
   see Section 8.2 of the CORBA 2.0 Spec.   
   This function will create an object of the given type and implementation. */
FLICK_TARGET CORBA_BOA_create(CORBA_BOA ths, CORBA_ReferenceData *obj_key, 
			      const char *type_id, FLICK_SERVER impl,
			      CORBA_Environment *ev)
{
	FLICK_TARGET_STRUCT *new_refs;
	FLICK_TARGET_STRUCT *obj_ref;
	
	CORBA_octet *ref_key_buffer;
	char *ref_type_id;
	
	int type_id_len;
	
	if (ths->max_name_len < obj_key->_length)
		ths->max_name_len = obj_key->_length;
	
	/* Allocate the memory we need for the new object reference. */
	type_id_len = strlen(type_id);
	
	ref_key_buffer = t_malloc(CORBA_octet, obj_key->_length);
	ref_type_id = t_malloc(char, (type_id_len + 1));
	
	if (!ref_key_buffer || !ref_type_id) {
		if (ref_key_buffer) free(ref_key_buffer);
		if (ref_type_id) free(ref_type_id);
		flick_set_exception(ths, ev, ex_CORBA_NO_MEMORY,
				    0, CORBA_COMPLETED_NO);
		fprintf(stderr,
			"Error: can't malloc memory for new object.\n");
		return 0;
	}
	
	/* Reallocate our BOA's vector of references. */
	new_refs = t_realloc(ths->refs,
			     FLICK_TARGET_STRUCT,
			     (ths->count_servers + 1));
	if (!new_refs) {
		free(ref_key_buffer);
		free(ref_type_id);
		flick_set_exception(ths, ev, ex_CORBA_NO_MEMORY,
				    0, CORBA_COMPLETED_NO);
		fprintf(stderr,
			"Error: can't realloc memory for CORBA_BOA object "
			"references.\n");
		return 0;
	}
	ths->refs = new_refs;
	ths->count_servers += 1;
	
	obj_ref = &(ths->refs[ths->count_servers - 1]);
	
	obj_ref->boa              = ths;	
	obj_ref->server_func = impl;
	memcpy(ref_key_buffer, obj_key->_buffer, obj_key->_length);
	obj_ref->key._buffer  = ref_key_buffer;
	obj_ref->key._length  = obj_key->_length;
	obj_ref->key._maximum = obj_key->_maximum;
	
	strncpy(ref_type_id, type_id, (type_id_len + 1));
	obj_ref->type_id     = ref_type_id;
	obj_ref->type_id_len = type_id_len;
	obj_ref->ior_len = 0;
	obj_ref->ior = 0;
	if (!flick_cdr_make_ior(obj_ref, &obj_ref->ior,
				&obj_ref->ior_len, 0)) {
		flick_set_exception(boa, ev, ex_CORBA_NO_MEMORY,
				    0, CORBA_COMPLETED_NO);
		fprintf(stderr,
			"Error: can't malloc memory for IOR.\n");
		return 0;
	}
	
	/* Finally, print the URL- and IOR-style stringified object refs. */
	{
		char *url, *ior;
		unsigned int i;
		
		url = CORBA_ORB_object_to_readable_string(ths->orb, obj_ref,
							  ev);
		if (ev->_major != CORBA_NO_EXCEPTION)
			return 0;
		ior = CORBA_ORB_object_to_string(ths->orb, obj_ref, ev);
		if (ev->_major != CORBA_NO_EXCEPTION)
			return 0;
		
		printf("Object `");
		for (i = 0; i < obj_key->_length; ++i) {
			if (isprint(obj_key->_buffer[i]))
				putchar(obj_key->_buffer[i]);
			else
				printf("\\%03o", obj_key->_buffer[i]);
		}
		printf("' is ready.\n");
		printf("  URL:\t%s\n  IOR:\t%s\n", url, ior);
		
		free(url);
		free(ior);
	}
	
	return CORBA_Object_duplicate(obj_ref, ev);
}
示例#12
0
static int
do_activating(void)
{
	Bonobo_ActivationEnvironment environment;
	Bonobo_ActivationResult *a_res;
	Bonobo_ActivationContext ac;	
	Bonobo_StringList reqs = { 0 };
	char *resior;
	int res = 1;

	if (acior) {
                ac = CORBA_ORB_string_to_object (orb, acior, &ev);
                if (ev._major != CORBA_NO_EXCEPTION)
        	return 1;
	} else
                ac = bonobo_activation_activation_context_get ();

	memset (&environment, 0, sizeof (Bonobo_ActivationEnvironment));
                                                                                                                             
	a_res = Bonobo_ActivationContext_activateMatchingFull (
 				ac, specs, &reqs, &environment, 0,
                                bonobo_activation_client_get (),
				bonobo_activation_context_get (), &ev);
	switch (ev._major) {
	case CORBA_NO_EXCEPTION:
		g_print ("Activation ID \"%s\" ", a_res->aid);
		switch (a_res->res._d) {
		case Bonobo_ACTIVATION_RESULT_OBJECT:
			g_print ("RESULT_OBJECT\n");
			resior = CORBA_ORB_object_to_string (orb,
							     a_res->
							     res._u.res_object,
							     &ev);
			g_print ("%s\n", resior);
			break;
		case Bonobo_ACTIVATION_RESULT_SHLIB:
			g_print ("RESULT_SHLIB\n");
      			break;
		case Bonobo_ACTIVATION_RESULT_NONE:
			g_print ("RESULT_NONE\n");
			break;
		}
		res = 0;	
		break;
	case CORBA_USER_EXCEPTION:
		{
			char *id;
			id = CORBA_exception_id (&ev);
			g_print ("User exception \"%s\" resulted from query\n",
				 id);
			if (!strcmp (id,"IDL:Bonobo/ActivationContext/ParseFailed:1.0")) {
				Bonobo_Activation_ParseFailed
					* exdata = CORBA_exception_value (&ev);
                                if (exdata)
					g_print ("Description: %s\n",
						 exdata->description);
			} else if (!strcmp (id,"IDL:Bonobo/GeneralError:1.0")) {
				Bonobo_GeneralError *exdata;
                                                                                                                             
				exdata = CORBA_exception_value (&ev);
                                                                                                                             
				if (exdata)
					g_print ("Description: %s\n",
						 exdata->description);
			}
			res = 1;
		}
		break;
	case CORBA_SYSTEM_EXCEPTION:
		{
			char *id;
			id = CORBA_exception_id (&ev);
			g_print ("System exception \"%s\" resulted from query\n",
				 id);
			res = 1;
		}
		break;
	}
	return res;
}
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;
}