コード例 #1
0
Wise2Corba_Singleton * get_Wise2Corba_Singleton(int * argc,char ** argv,char * init_string)
{

  if( static_init_string != NULL ) {
    if( strcmp(static_init_string,init_string) == 0 ) {
      return &singleton;
    } else {
      fprintf(stderr,"Trouble! Asked for orbs of different types %s and %s",init_string,static_init_string);
      return NULL;
    }
  }

  /* else, initiate orb */

  singleton.ev = g_new0(CORBA_Environment,1);

  CORBA_exception_init(singleton.ev);
  singleton.orb = CORBA_ORB_init(argc,argv,init_string,singleton.ev);
  /* FIXME: Exception check! */
  singleton.poa = (PortableServer_POA)CORBA_ORB_resolve_initial_references(singleton.orb,
									   "RootPOA",singleton.ev);

  static_init_string = CORBA_string_dup(init_string);

  return &singleton;
}
コード例 #2
0
JNIEXPORT jstring JNICALL
Java_jp_ac_utsunomiya_is_SS2012FPGA_initialize( JNIEnv* env,
        jobject thiz,
        jstring ior)
{
    //printf("Hello from JNI");

    char *bytes = (*env)->GetStringUTFChars(env, ior, NULL);

    int argc = 1;
    char* argv_word = "";
    char** argv;
    argv[0] = argv_word;

    orb = (CORBA_ORB)CORBA_ORB_init(&argc, argv, 0, &corba_env);
    ev = &corba_env;

    _obj = (CORBA_jp_ac_utsunomiya_is_SS2012FPGA) CORBA_ORB_string_to_object
           (orb, bytes, &corba_env);


    //char objname[256];
    //sprintf(objname, "%x", &_obj);
    jstring strj = (*env)->NewStringUTF(env, "motor");

    (*env)->ReleaseStringUTFChars(env, ior, bytes);
    return strj;
}
コード例 #3
0
int main(int argc, char *argv[])
{
	CORBA_ORB orb;
	CORBA_Environment ev;
	CORBA_exception_init(&ev);
	orb = CORBA_ORB_init(&argc, argv, "matecorba-local-orb", &ev);
	return 0;
}
コード例 #4
0
/**
 * matecomponent_activation_orb_init:
 * @argc: pointer to program's argument count
 * @argv: argument array
 * 
 * Initialize MateComponent Activation's ORB - do this once centrally
 * so it can be easily shared.
 * 
 * Return value: the ORB.
 **/
CORBA_ORB
matecomponent_activation_orb_init (int *argc, char **argv)
{
        CORBA_Context def_ctx;
	CORBA_Environment ev;
	const char *hostname;
	gchar *orb_id;

	CORBA_exception_init (&ev);

#ifdef HAVE_GTHREADS
	orb_id = "matecorba-local-mt-orb";
#else
	orb_id = "matecorba-local-non-threaded-orb";
#endif
	matecomponent_activation_orb = CORBA_ORB_init (argc, argv, orb_id, &ev);
	g_assert (ev._major == CORBA_NO_EXCEPTION);

	matecomponent_activation_init_activation_env ();

	/* Set values in default context */
	CORBA_ORB_get_default_context (matecomponent_activation_orb, &def_ctx, &ev);
        CORBA_Context_create_child (def_ctx, "activation", &matecomponent_activation_context, &ev);
	g_assert (ev._major == CORBA_NO_EXCEPTION);
        CORBA_Object_release ((CORBA_Object) def_ctx, &ev);
	g_assert (ev._major == CORBA_NO_EXCEPTION);

	hostname = matecomponent_activation_hostname_get ();
	CORBA_Context_set_one_value (matecomponent_activation_context, "hostname",
				     (char *) hostname, &ev);
	CORBA_Context_set_one_value (matecomponent_activation_context, "username",
				     (char *) g_get_user_name (), &ev);

	CORBA_exception_free (&ev);

#ifdef MATECOMPONENT_ACTIVATION_DEBUG
	if (getenv ("MATECOMPONENT_ACTIVATION_TRAP_SEGV")) {
#ifdef HAVE_SIGACTION
		struct sigaction sa;
		sa.sa_handler = do_barrier;
		sigaction (SIGSEGV, &sa, NULL);
		sigaction (SIGPIPE, &sa, NULL);
#else
                signal (SIGSEGV, do_barrier);
#ifdef SIGPIPE
                signal (SIGPIPE, do_barrier);
#endif
#endif
	}
	if (getenv ("MATECOMPONENT_ACTIVATION_BARRIER_INIT")) {
		volatile int barrier = 1;
		while (barrier);
	}
#endif

	return matecomponent_activation_orb;
}
コード例 #5
0
 */static 
void 
server_init (int                 *argc_ptr, 
	     char                *argv[],
	     CORBA_ORB           *orb,
	     PortableServer_POA  *poa,
	     CORBA_Environment   *ev)
{
	PortableServer_POA         rootpoa     = CORBA_OBJECT_NIL;
	PortableServer_POAManager  rootpoa_mgr = CORBA_OBJECT_NIL; 

	CORBA_Environment  local_ev[1];
	CORBA_exception_init(local_ev);

	/* init signal handling */
	signal(SIGTERM, server_shutdown);
	
	/* create Object Request Broker (ORB) */
	
        (*orb) = CORBA_ORB_init(argc_ptr, argv, "orbit-local-mt-orb", ev);
	if (etk_raised_exception(ev)) 
		goto failed_orb;

        rootpoa = (PortableServer_POA) 
		CORBA_ORB_resolve_initial_references(*orb, "RootPOA", ev);
	if (etk_raised_exception(ev)) 
		goto failed_poa;
	
        rootpoa_mgr = PortableServer_POA__get_the_POAManager(rootpoa, ev);
	if (etk_raised_exception(ev)) 
		goto failed_poamanager;

	/* create default POA with specific policies */

	(*poa) = server_create_multi_threaded_poa (*orb, 
						   rootpoa, 
						   rootpoa_mgr, 
						   ev);
	if (etk_raised_exception(ev)) 
		goto failed_child_poa;

	PortableServer_POAManager_activate(rootpoa_mgr, ev);
	if (etk_raised_exception(ev)) 
		goto failed_activation;

        CORBA_Object_release ((CORBA_Object) rootpoa_mgr, ev);
	return;

 failed_activation:
 failed_child_poa:
 failed_poamanager:
        CORBA_Object_release ((CORBA_Object) rootpoa_mgr, local_ev);
 failed_poa:
	CORBA_ORB_destroy(*orb, local_ev);		
 failed_orb:
	return;
}
コード例 #6
0
ファイル: test-mem.c プロジェクト: OS2World/SYSTEM-OS-Voyager
static
void
main_func(int argc, char *argv[]) {
        PortableServer_POA         poa         = CORBA_OBJECT_NIL;
        PortableServer_POAManager  poa_manager = CORBA_OBJECT_NIL;
        CORBA_Environment  ev[1];
        CORBA_exception_init(ev);
	
	/* init signal handling */
	
        signal(SIGINT,  server_shutdown);
        signal(SIGTERM, server_shutdown);
	
        /* create Object Request Broker (ORB) */
	
        global_orb = CORBA_ORB_init(&argc, 
				    argv, 
				    "orbit-local-treaded-orb", 
				    ev);
        g_assert (!ORBIT_EX (ev));
	
        /* get Portable Object Adaptor (POA) */
	
        poa = (PortableServer_POA) 
          CORBA_ORB_resolve_initial_references(global_orb,
					       "RootPOA",
					       ev);
        g_assert (!ORBIT_EX (ev));

        /* activate POA Manager */
	
	poa_manager = PortableServer_POA__get_the_POAManager(poa, ev);
        g_assert (!ORBIT_EX (ev));
	
        PortableServer_POAManager_activate(poa_manager, ev);
        g_assert (!ORBIT_EX (ev));
	
 	LEAK_DETECT_WITH_TOLERANCE (1000, test_ORBit_alloc (), 50); 
 	LEAK_DETECT_WITH_TOLERANCE (1000, test_ORBit_sequence (), 50); 
	LEAK_DETECT_WITH_TOLERANCE (1000, test_activate_deactivate (poa, ev), 50);

        /* tear down the ORB */
	CORBA_Object_release ((CORBA_Object) poa_manager, ev);
	g_assert (!ORBIT_EX (ev));

	CORBA_Object_release ((CORBA_Object) poa, ev);
	g_assert (!ORBIT_EX (ev));

        if (global_orb != CORBA_OBJECT_NIL) {
                /* going to destroy orb.. */
                CORBA_ORB_destroy(global_orb, ev);
		g_assert (!ORBIT_EX (ev));
        }
}
コード例 #7
0
 */static 
void 
server_init (int                 *argc_ptr, 
	     char                *argv[],
	     CORBA_ORB           *orb,
	     PortableServer_POA  *poa,
	     CORBA_Environment   *ev)
{
	PortableServer_POAManager  poa_manager = CORBA_OBJECT_NIL; 

	CORBA_Environment  local_ev[1];
	CORBA_exception_init(local_ev);

	/* init signal handling */
	signal(SIGINT,  server_shutdown);
	signal(SIGTERM, server_shutdown);
	
	/* create Object Request Broker (ORB) */
	
        (*orb) = CORBA_ORB_init(argc_ptr, argv, "orbit-local-mt-orb", ev);
	if (etk_raised_exception(ev)) 
		goto failed_orb;

        (*poa) = (PortableServer_POA) 
		CORBA_ORB_resolve_initial_references(*orb, "RootPOA", ev);
	if (etk_raised_exception(ev)) 
		goto failed_poa;

        poa_manager = PortableServer_POA__get_the_POAManager(*poa, ev);
	if (etk_raised_exception(ev)) 
		goto failed_poamanager;

	PortableServer_POAManager_activate(poa_manager, ev);
	if (etk_raised_exception(ev)) 
		goto failed_activation;

        CORBA_Object_release ((CORBA_Object) poa_manager, ev);
	return;

 failed_activation:
 failed_poamanager:
        CORBA_Object_release ((CORBA_Object) poa_manager, local_ev);
 failed_poa:
	CORBA_ORB_destroy(*orb, local_ev);		
 failed_orb:
	return;
}
コード例 #8
0
static
void
client_init (int               *argc_ptr,
	     char              *argv[],
             CORBA_ORB         *orb,
             CORBA_Environment *ev)
{
        /* init signal handling */
 
        signal(SIGINT,  client_shutdown);
        signal(SIGTERM, client_shutdown);
         
        /* create Object Request Broker (ORB) */
         
        (*orb) = CORBA_ORB_init(argc_ptr, argv, "orbit-local-orb", ev);
        if (etk_raised_exception(ev)) return;
}
コード例 #9
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);
}
コード例 #10
0
int
main (int argc, char *argv[])
{
	CORBA_Environment ev;

	free (malloc (8));

	g_thread_init (NULL);

	CORBA_exception_init (&ev);

	timer = g_timer_new ();
	g_timer_start (timer);

	g_timer_reset (timer);
	orb = CORBA_ORB_init (&argc, argv, "matecorba-local-orb", &ev);
	g_assert (ev._major == CORBA_NO_EXCEPTION);
	fprintf (stderr, "ORB: init took %g(ms)\n",
		 (elapsed_time = g_timer_elapsed (timer, NULL)) * 1000.0);
	bogomark += elapsed_time;

	test_copy ();

	test_activation ();

	g_timer_reset (timer);
	CORBA_ORB_destroy (orb, &ev);
	g_assert (ev._major == CORBA_NO_EXCEPTION);
	fprintf (stderr, "ORB: destroy took %g(ms)\n",
		 (elapsed_time = g_timer_elapsed (timer, NULL)) * 1000.0);
	bogomark += elapsed_time;
	g_timer_reset (timer);

	CORBA_Object_release ((CORBA_Object) orb, &ev);
	g_assert (ev._major == CORBA_NO_EXCEPTION);

	g_timer_destroy (timer);

	fprintf (stderr, "Overall bogomark %g\n", 1000.0 / bogomark);

	return 0;
}
コード例 #11
0
ファイル: phonebook.c プロジェクト: berkus/flick
int main(int argc, char **argv) 
{
	CORBA_ORB orb = 0;
	CORBA_Environment ev;
	data_phonebook obj;
	int sel, done;
	
	if (argc != 2) {
		fprintf(stderr,
			"Usage: %s <phone obj reference>\n", argv[0]);
		exit(1);
	}
	
	orb = CORBA_ORB_init(&argc, argv, 0, &ev);
	if (ev._major != CORBA_NO_EXCEPTION) {
		printf("Can't initialize the ORB.\n");
		exit(1);
	}
	
	obj = CORBA_ORB_string_to_object(orb, argv[1], &ev);
	if (ev._major != CORBA_NO_EXCEPTION) {
		printf("Can't convert `%s' into an object reference.\n",
		       argv[1]);
		exit(1);
	}
	
	done = 0;
	while (!done) {
		read_integer(("\n(1) Add an entry (2) Remove an entry "
			      "(3) Find a phone number (4) Exit: "),
			     &sel);
		switch(sel) {
		case 1:  add_entry(obj); break;
		case 2:  remove_entry(obj); break;
		case 3:  find_entry(obj); break;
		case 4:  done = 1; break;
		default: printf("Please enter 1, 2, 3, or 4.\n");
		}
	}
	return 0;
}
コード例 #12
0
ファイル: passlong-server.c プロジェクト: corbinbs/CORBin
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);
}
コード例 #13
0
ファイル: test-poa.c プロジェクト: 3v3vuln/ORBit2
int
main (int argc, char **argv) 
{
	CORBA_Environment  ev[1];
	PortableServer_POA rootpoa, poa;

	CORBA_exception_init (ev);

	orb = CORBA_ORB_init (&argc, argv, "", ev);

	rootpoa = (PortableServer_POA)
		CORBA_ORB_resolve_initial_references (orb, "RootPOA", ev);
	g_assert (ev->_major == CORBA_NO_EXCEPTION);

	{
		poa = ORBit_POA_new_from (orb, rootpoa, "Foo", NULL, ev);
		g_assert (ev->_major == CORBA_NO_EXCEPTION);
	
		PortableServer_POA_destroy (poa, FALSE, FALSE, ev);
		CORBA_Object_release ((CORBA_Object) poa, ev);
	}

	CORBA_Object_release ((CORBA_Object) rootpoa, ev);

	CORBA_ORB_destroy (orb, ev);
	g_assert (ev->_major == CORBA_NO_EXCEPTION);

	CORBA_Object_release ((CORBA_Object) orb, ev);
	g_assert (ev->_major == CORBA_NO_EXCEPTION);

	CORBA_exception_free (ev);

	fprintf (stderr, "PASS: test-poa\n");

	return 0;
}
コード例 #14
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;
}
コード例 #15
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;
}
コード例 #16
0
int
main (int argc, char *argv[]) {
	CORBA_Environment ev;
	CORBA_ORB orb;
	CORBA_double rv;
	char buf[30];
	int i;

	int niters = 1000;

	CORBA_exception_init(&ev);
	orb = CORBA_ORB_init(&argc, argv, "orbit-local-orb", &ev);

	/* read IOR from command line as first argument */
	if(argc < 2) {
		g_print ("ERROR, usage: %s <ior> [<#iterations>]\n", argv[0]);
		return 1;
	}

	if (argv[1][0] == '$')
	  argv[1] = getenv (argv[1]+1);

	/* read (optional) number of iterations from command line as
	 * second argument (100) */    
	if(argc == 3)
		niters = atoi(argv[2]);
    
	/* bind to object */
	echo_client = CORBA_ORB_string_to_object(orb, argv[1], &ev);
	ABORT_IF_EXCEPTION (&ev, "cannot bind to object");
	g_assert (echo_client!=NULL);

	/* Iterate various times.  Each time the client invokes
	 * 'echoString(..)'  a new reference to service is returned which
	 * is used for next loop. At end of each loop the old
	 * obj. reference is released. */
	for(i = 0; i < niters; i++) {
		/* Method call without any argument, usefull to tell
		 * lifeness */
		Echo_doNothing(echo_client, &ev);
		ABORT_IF_EXCEPTION (&ev, "service raised exception ");

		/* Ask echo-service to print string 'buf' on console. The
		 * service returns random double float value in 'vr' */
		g_snprintf(buf, sizeof(buf), "Hello, world [%d]", i);
		bec = Echo_echoString(echo_client, buf, &rv, &ev);
		ABORT_IF_EXCEPTION (&ev, "service raised exception ");

		/* print random value generated by echo-service */
		if ( !echo_opt_quiet )
			g_message("[client] %g", rv);

		/* Asynchronous/oneway method call, the function returns
		 * immediately.  Usefull for log-message transfer */
		Echo_doOneWay(echo_client, "log message ", &ev);
		ABORT_IF_EXCEPTION (&ev, "service raised exception ");

		/* release first object reference and use the new one for
		 * next loop */
		CORBA_Object_release(echo_client, &ev);
		ABORT_IF_EXCEPTION (&ev, "service raised exception ");

		/* swap object references */ 
		echo_client = bec; bec = CORBA_OBJECT_NIL;
	}
    
	/* release initial object reference */
	CORBA_Object_release(echo_client, &ev);
	ABORT_IF_EXCEPTION (&ev, "service raised exception ");

	/* shutdown ORB, shutdown IO channels */
	CORBA_ORB_shutdown (orb, FALSE, &ev);
	ABORT_IF_EXCEPTION(&ev, "ORB shutdown ...");

	/* destroy local ORB */
	CORBA_ORB_destroy(orb, &ev);
	ABORT_IF_EXCEPTION (&ev, "destroying local ORB raised exception");

	return 0;
}
コード例 #17
0
ファイル: CORBAChanellWorker.c プロジェクト: codehaus/plj
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.");
	
}
コード例 #18
0
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;
}