Discussion:
[omniORB] Does omniORB support smart proxies?
Tuyen Chau
2006-09-27 04:46:56 UTC
Permalink
Sorry if this question has been asked before. Does omniORB support
smart proxies? I'm porting an Orbix application that uses smart proxies
to cache values in client objects and avoid unnecessary remote
invocations. I can't find any mention of this in the omniORB
documentation. I'm hoping somebody has implemented smart proxies with
omniORB and could point me in the right direction.

Thanks in advance for any help you can provide,
Tuyen
Jeffrey Coffman
2006-09-27 21:46:20 UTC
Permalink
Hello,

I am looking for masters project ideas and thought I would querey the group to see if anyone had some ideas for project involving CORBA or anything that could be added to omniORB? I had thought adding AMI support would be a good project but may be to big for one person to finish in a timely manner. Any ideas or suggestions?

thanks,

Jeff


_______________________________________________
omniORB-list mailing list
omniORB-***@omniorb-support.com
http://www.omniorb-support.com/mailman/listinfo/omniorb-list



---------------------------------
Do you Yahoo!?
Everyone is raving about the all-new Yahoo! Mail.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.omniorb-support.com/pipermail/omniorb-list/attachments/20060927/858e0ef9/attachment.htm
Tuyen Chau
2006-09-28 01:18:59 UTC
Permalink
I only found two threads discussing smart proxies in the last 10 years:

http://www.omniorb-support.com/pipermail/omniorb-list/2001-September/019210.html

http://www.omniorb-support.com/pipermail/omniorb-list/2000-December/016822.html

In the first thread, the author said he had implemented smart proxies,
but then quickly dived into details about how the POF works without
mentioning how the smart proxies were implemented in the first place.

In the second thread, Stefan Seefeld said:

------------------------------------------------
you should use some form of distributed ref counting, i.e. derive
your servants
from an
interface RefCountBase
{
void increment();
void decrement();
};
Of course, you need to call these methods explicitely. There is no
portable
way to add that to proxy classes. However, what I did to get a
similar effect,
template <typename Interface>
class RefCount_var
{
RefCount_var(typename Interface::_type_ptr i) : _i(i) {}
~RefCount_var()
{
if (!CORBA::is_nil(_i))
try { _i->decrement();}
catch (...) {}
}
//...
}
RefCount_var<SomeObject> object = ...; // assumes ownership like
'normal' vars...
------------------------------------------------

I still don't understand what Stefan said in the above. Does anyone
understand it, or know how to generate smart proxies in omniORB? In my
understanding, the process must involve creating a smart proxy factory
class and somehow have it registered so omniORB will use it to create
instances of proxy classes instead of the default CLASS_ptr objects.

Best regards,

Tuyen,
Duncan Grisby
2006-09-29 22:37:27 UTC
Permalink
Post by Tuyen Chau
Sorry if this question has been asked before. Does omniORB support
smart proxies? I'm porting an Orbix application that uses smart
proxies to cache values in client objects and avoid unnecessary remote
invocations. I can't find any mention of this in the omniORB
documentation. I'm hoping somebody has implemented smart proxies with
omniORB and could point me in the right direction.
You can register your own factories for proxy objects to do what you
want. I'm afraid it's not documented, however, so you'll have to read
the stub code to see how proxies are registered. You'll probably want to
use the -Wbvirtual_objref flag to omniidl's C++ backend so you can
override the object references' methods.

Cheers,

Duncan.
--
-- Duncan Grisby --
-- ***@grisby.org --
-- http://www.grisby.org --
Tuyen Chau
2006-10-11 05:48:30 UTC
Permalink
Post by Duncan Grisby
You can register your own factories for proxy objects to do what you
want. I'm afraid it's not documented, however, so you'll have to read
the stub code to see how proxies are registered. You'll probably want to
use the -Wbvirtual_objref flag to omniidl's C++ backend so you can
override the object references' methods.
Cheers,
Duncan.
Many thanks to Duncan, I finally got the client proxies working.

To help the next person with the same question as mine, I thought I'd
write this up as a list of instructions you need to follow to create
your client proxies. Let's say you want to create proxies for Echo
interface, here are the steps you should follow,

1. Derive from the default proxy class, _objref_Echo. The tricky part
here is the constructor. You can't just assume the constructor of the
super class will do the right things for you by invoking it. You have
to copy the stub code, or your proxy class will not work and you will
get a nil pointer back at run time. So here's what the code should look
like,

class ProxyEcho : public virtual _objref_Echo {
public:
ProxyEcho(omniIOR* ior, omniIdentity* ident) :
omniObjRef(::Echo::_PD_repoId, ior, ident, 1),
_objref_Echo(ior, ident) {

_PR_setobj(this);
}

2. Derive from the default proxy object factory class, _pof_Echo and
override the newObjRef() function to instantiate your proxy class,
instead of the default proxy class. Here's what the code should look like,

class EchoProxyFactoryClass : public virtual _pof_Echo {
public:
virtual omniObjRef* newObjRef(omniIOR* ior, omniIdentity* ident) {
return new ProxyEcho(ior, ident, -1);
}
};

3. Create a new proxy object factory instance. The trick here is you
have to create it after the default one in the stub code gets created.
With Orbix, you can just create it by defining a global instance. With
omniORB, there's still a chance your global object gets instantiated
before the default one in the stubs, so you should create yours with the
"new" operator somewhere in your initialization, ie.

EchoProxyFactoryClass *myEchoProxyFactory = new EchoProxyFactoryClass();

4. Compile the IDL with -Wbvirtual_objref. This option declares all
object reference functions as virtual so your proxy class can override them.

5. If you compile your client code on Windows like I do, use -GR option
to the compiler to enable RTTI. This will allow you to use dynamic_cast
operator to convert a pointer to the default proxy class to a pointer to
your proxy class.

That's it. Enjoy your proxies!
Duncan Grisby
2006-09-29 22:43:41 UTC
Permalink
Post by Jeffrey Coffman
I am looking for masters project ideas and thought I would querey the
group to see if anyone had some ideas for project involving CORBA or
anything that could be added to omniORB? I had thought adding AMI
support would be a good project but may be to big for one person to
finish in a timely manner. Any ideas or suggestions?
How big is your project meant to be? Coincidentally, I've been talking
to someone else about doing AMI, or at least some of it, as a project.
It probably is a suitable thing to do, at least doing the support in the
ORB core. It may be too much grunt work to do the full C++ mapping.

The other kind of thing you could consider doing is to implement one of
the various CORBA services like the trader service, or do a
database-backed naming service.

Cheers,

Duncan.
--
-- Duncan Grisby --
-- ***@grisby.org --
-- http://www.grisby.org --
Duncan Grisby
2006-10-12 00:05:32 UTC
Permalink
Post by Tuyen Chau
Many thanks to Duncan, I finally got the client proxies working.
Thanks for writing that up. Perhaps you could put it on the omniORB Wiki
in the UsefulTips section:

http://www.omniorb-support.com/omniwiki/UsefulTips


Cheers,

Duncan.
--
-- Duncan Grisby --
-- ***@grisby.org --
-- http://www.grisby.org --
Loading...