Go Back   ZeroC Forums > Help Center

Reply
 
LinkBack Thread Tools Rate Thread Display Modes
  #1 (permalink)  
Old 10-23-2004
robert robert is offline
Registered User
 
 
Join Date: Oct 2004
Posts: 10
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.
Reply With Quote
  #2 (permalink)  
Old 10-23-2004
marc's Avatar
marc marc is offline
ZeroC Staff
 
Name: Marc Laukien
Organization: ZeroC, Inc.
Project: The Internet Communications Engine
 
Join Date: Feb 2003
Location: Florida
Posts: 1,781
I'm afraid I don't understand. Why is there no way to fill in the context at the client side? It's simply the last parameter of any operation call. Alternatively, you can set a default context with the proxy's ice_newContext() operation.

For the server side, you receive the context through the current parameter in a servant locator, as well as in each individual operation call.
Reply With Quote
  #3 (permalink)  
Old 10-23-2004
robert robert is offline
Registered User
 
 
Join Date: Oct 2004
Posts: 10
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.
Reply With Quote
  #4 (permalink)  
Old 10-23-2004
marc's Avatar
marc marc is offline
ZeroC Staff
 
Name: Marc Laukien
Organization: ZeroC, Inc.
Project: The Internet Communications Engine
 
Join Date: Feb 2003
Location: Florida
Posts: 1,781
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);
Reply With Quote
  #5 (permalink)  
Old 10-23-2004
robert robert is offline
Registered User
 
 
Join Date: Oct 2004
Posts: 10
Thank you!

Great and fast explanation, this really helped!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

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


All times are GMT -4. The time now is 05:08 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0
(c) 2008 ZeroC, Inc.