Re: An object becomes NULL somewhere
- From: ERDI Gergo <cactus cactus rulez org>
- To: orbit-list cuc edu
- Cc: gnome-components-list gnome org
- Subject: Re: An object becomes NULL somewhere
- Date: Mon, 17 Jul 2000 13:14:28 +0200 (CEST)
Hi,
After talking with Sopwith about what a real bug report should look like,
I went and wrote a Java test program with only 70+ lines of code. (see
attached file bonobotest-java.java). You will need an ORB that supports
CORBA.Context, I used D.O.G.'s JavaORB 2.2.6.
However, this is not the end of the story. I also wrote an example program
using OmniORB and C++ (see attached file bonobotest-cxx.cc). You'll need
OmniORB to generate the .hh files, of course. After running it, I got a
nice list of the properties supported by the control.
That means it's not ORBit behaving nasty here, but DOG's JavaORB. I'll
submit a bug report to them. Of course, I still don't know what's so
special about some Bonobo methods that they fail to work with JavaORB.
--
.--= ULLA! =----------------------------. finger cactus@cactus.rulez.org
\ http://cactus.rulez.org \ for PGP public key
`----------= cactus@cactus.rulez.org =--'
A fejfájás a legtermészetesebb és legelterjedtebb fogamzásgátló.
#include <iostream>
#include "oaf.hh"
#include "bonobo-unknown.hh"
#include "bonobo-control.hh"
#include "bonobo-control-proxy.h"
#define TEST_IID "OAFIID:bonobo_entry:04e49c0b-95e2-4305-88a7-9f6721ddfa51"
int main (int argc, char **argv)
{
CORBA::ORB_ptr orb = CORBA::ORB_init (argc, argv, "omniORB2");
if (argc < 2)
{
cerr << "Usage: " << argv[0] << " <IOR>" << endl;
return -1;
}
/////////////////////////
// Get an object from OAF
CORBA::Context_ptr ctx;
orb->get_default_context (ctx);
CORBA::Any any;
any <<= "cactus";
ctx->set_one_value ("username", any);
any <<= "localhost";
ctx->set_one_value ("hostname", any);
any <<= "localdomain";
ctx->set_one_value ("domainname", any);
CORBA::Object_var obj = orb->string_to_object (argv[1]);
OAF::ActivationContext_var oaf = OAF::ActivationContext::_narrow (obj);
OAF::ActivationResult_var res = oaf->activate_from_id (TEST_IID, 0, ctx);
CORBA::Object_var res_obj = res->res.res_object ();
/////////////////////////
Bonobo::Unknown_var unknown = Bonobo::Unknown::_narrow (res_obj);
Bonobo::Control_var control = Bonobo::Control::_narrow (
unknown->query_interface ("IDL:Bonobo/Control:1.0"));
Bonobo::PropertyBag_var prop_bag = control->get_property_bag ();
Bonobo::PropertyList_var prop_list = prop_bag->get_properties ();
for (CORBA::ULong i = 0; i < prop_list->length(); i++)
cout << prop_list[i]->get_name () << endl;
prop_bag->unref ();
control->unref ();
unknown->unref ();
}
// HelloStringifiedClient.java, stringified object reference version
import java.io.*;
import org.omg.CORBA.*;
import OAF.*;
import Bonobo.*;
public class testorb
{
public static Context create_context (ORB orb)
{
org.omg.CORBA.Context ctx = orb.get_default_context ();
org.omg.CORBA.Any val = orb.create_any ();
String hostname;
try
{
hostname = java.net.InetAddress.getLocalHost().getHostName();
} catch (Exception e)
{
hostname = "localhost";
}
val.insert_string (hostname);
ctx.set_one_value ("hostname", val);
val.insert_string (System.getProperty("user.name"));
ctx.set_one_value ("username", val);
val.insert_string ("");
ctx.set_one_value ("domainname", val);
return ctx;
}
public static ActivationContext get_oaf (ORB orb) throws Exception
{
org.omg.CORBA.Object obj = null;
// Get the IOR
String filename = "/tmp/orbit-" +
System.getProperty ("user.name") +
"/reg.IDL:OAF_ActivationContext:1.0";
BufferedReader br = new BufferedReader (new FileReader (filename));
String ior = br.readLine ();
// Create a CORBA object from the IOR
obj = orb.string_to_object (ior);
// Downcast it to an ActivationContext
return ActivationContextHelper.narrow (obj);
}
static final String TEST_IID = "OAFIID:bonobo_entry:04e49c0b-95e2-4305-88a7-9f6721ddfa51";
static void main (String argv[])
{
try {
ORB orb = ORB.init ();
ActivationContext actx = get_oaf (orb);
Context ctx = create_context (orb);
ActivationResult res = actx.activate_from_id (TEST_IID, 0, ctx);
Bonobo.Unknown unknown =
Bonobo.UnknownHelper.narrow (res.res.res_object());
Bonobo.Control control = Bonobo.ControlHelper.narrow
(unknown.query_interface ("IDL:Bonobo/Control:1.0"));
Bonobo.PropertyBag prop_bag = control.get_property_bag ();
if (prop_bag == null)
System.err.println ("This is where the error occurs");
else
prop_bag.unref ();
control.unref ();
unknown.unref ();
} catch (Exception e) {
System.err.println("ERROR : " + e) ;
e.printStackTrace(System.err);
}
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]