My IDL looks like:
interface TransactionResource {
void prepare() raises (NotPreparedException);
void commit() raises(TransactionException);
void rollback() raises(TransactionException);
};
interface ManageDemand : TransactionResource {
string createDemand(in string demand);
};
interface ManageAccount : TransactionResource {
string createDemand(in string demand);
};
I create the ManageDemand distributed object on Server , I make it persistent, and it's reachable through the CORBALOC address.
On my client I have:
Object obj = orb.string_to_object(url.toString());
TransactionResource transactionResource = null;
if (obj._is_a("IDL:transaction/ManageDemand:1.0")){
transactionResource = ManageDemandHelper.narrow(obj);
} else {
transactionResource = ManageAccountHelper.narrow(obj);
}
When I try to test if the transactionResource object (distributed reference) is an instance of ManageDemand, the result is true.
But if I invoke Transaction object, defined like this:
interface Transaction {
ProxyStream addResource(in TransactionResource resource);
}
And I pass in parameter the transactionResource distributed reference, in this method when I test if this resource is an instance of ManageDemand, the result is false.
What I have to do, to recognize that this transactionResource is instance of ManageDemand on the addResource method?
I don't know how you test if the transactionResource object(TransactionResource resource) is an instance of ManageDemand, in the 'addResource' method of your Transaction Servant implementation.
I guess maybe, you test it just like below:
If yes, then you wont' get the correct answer, since the 'resource' object obtained from the client is "_TransactionResourceStub" class, therefore, you can't use the 'instanceof' method to test.
However, you still can use the '_is_a' method to test it ,like below:
Then, you'll get the correct answer.