[omniORB] A new/remove (lifecycle?) question
Bruce Cameron
cameron.bruce@mayo.edu
Tue, 04 Jan 2000 08:40:00 -0600
Perhaps someone can help me (or tell me why I can't) do the
following using omniORB:
I've 2 classes "A" & "B":
interface A { // the essence of A
long getID ();
void addB (in B ptr);
void remove ();
};
interface B { // the essence of B
long getID ();
void remove ();
};
These are created by a factory:
interface factory {
A new_A ();
B new_B ();
};
Class A's remove method is implemented so that if there
are any Bs added to this A, each B's remove() is called
before disposing of A. The addB method is:
void A::addB (B_ptr ptr) {
arrayOfB_ptr[index] = ptr;
index++;
}
While the client can create/remove As and Bs alone till
the cows come home, the following kills off the client:
CORBA::Object_var obj = factory->new_A();
A_var aClass = A::_narrow(obj);
for (i = 0; i < 5; i++) {
obj = factory->new_B();
B_var bClass = B::_narrow(obj);
aClass->addB(bClass);
}
aClass->remove();
obj = factory->new_A();
aClass = A::_narrow(obj);
for (i = 0; i < 5; i++) {
obj = factory->new_B(); // <============ dies here
B_var bClass = B::_narrow(obj);
aClass->addB(bClass);
}
I know there's a bug in my logic somewhere. Do I have
to use a lifecycle move() when adding Bs to A? Does the
client have to maintain object relationships rather
than doing it on the server side?
Thanks in advance.
--
--Bruce