|
|
|
|||||
|
passing a context to a locator
Hello!
We need to implement transactional behaviour into an Ice based architecture. The Ice context mechanism seems to be a fine solution to pass the transaction context to all servant calls. However, we are also enthusiastic about locators and started to use them. But there seems to be a gap. Within the locator we need to select records from our database in order to invoke the requested servants. These selects must be done in the appropriate database transaction contexts. But we can't pass the transaction handle from the client to the locator residing on the server! Though the locator receives a context (via the Ice::Current parameter), there seems to be no way to fill that context on the client side. Looks like locators can't be used when transactions are required, or am I missing something? Or is there a better recommendation to realize transactions within an Ice based architecture? Thanks! Robert. |
|
|||||
|
Further details
Hi Marc,
thanks for your fast reaction! My problem is that the locator is not only called by method invocations but also when a servant/proxy pair is just created. For example I might call stringToProxy() on the client's adapter what results in an incarnation of a servant via it's locator. It looks like this on the client side: ::std::string szFilePrxString = "file/" + fileId + ":" + ic->getProperties()->getProperty("Fileservice.Endpoints"); Ice::ObjectPrx obj = ic->stringToProxy(szFilePrxString); CFilePrx file = CFilePrx::checkedCast(obj); This triggers the server's file locator which selects the file in the database - but I don't know how to pass the client specific transaction context. Cheers Robert. |
|
||||||
|
stringToProxy() does not result in any method invocation on the server, but checkedCast() does. And you are right, there is no way to explicitly pass a context to checkedCast(). This is something we must fix.
In the meantime, you can use the default context as a workaround. For example: Ice::Context ctx = ... Ice::ObjectPrx p = ... p = p->ice_newContext(ctx); MyModule::DerivedObjectPrx q = MyModule::DerivedObjectPrx::checkedCast(p); Then all invocations on p will use ctx as context implicitly. Another workaround is to explicitly call ice_isA() in combination with an uncheckedCast: Ice::Context ctx = ... Ice::ObjectPrx p = ... MyModule::DerivedObjectPrx q; if(p->ice_isA("::MyModule::DerivedObject", ctx)) q = MyModule::DerivedObjectPrx::uncheckedCast(p); |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| passing objects | nicole | Help Center | 5 | 02-12-2007 10:12 PM |
| IceStorm and Ice::Context | Nis Baggesen | Help Center | 2 | 03-06-2006 07:52 AM |
| Problem passing context map with createSession() | bartley | Help Center | 6 | 02-02-2006 11:39 PM |
| Passing parameters to constructor | jacopo | Help Center | 2 | 05-12-2005 01:47 PM |