[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ExternalDatabase.objectForName()



On Wed, 06 Sep 2000, Martin Harper wrote:
> Falko Braeutigam wrote:
> 
> > On Wed, 06 Sep 2000, Martin Harper wrote:
> > > The ability to get hold of an object based on it's unique string name,
> > > using objectForName(), is really handy, but is there any way to get hold
> > > of an object based on it's unique ID ( as got from container().id() ),
> > > short of making a hashtable solely designed to map unique IDs to
> > > OzoneProxys?
> > No! The object ID is _not_ meant to be used by client applications. It makes no
> > sense to use the OID. On all places where you would like to use the ID of an
> > object you can use the proxy itself. In fact, the only data field of proxies
> > _is_ the OID of the database object they refer to.
> >
> > Falko
> 
> Well, my problem is that I'm doing some Ozone stuff on one computer, and at the end
> of that I send an event to a process on a seperate computer. Within that event I
> need to include some reference to a couple of these objects. The second process can
> then access the database to do lots of funky things with these objects.
> 
> Now, OzoneProxys are externalizeable, which is good, but sadly I'm working to a
> spec which insists that the reference to the object that is sent over the network
> must be a long (on a DataOutputStream). So I can't just shunt the entire thing down
> the cable.

I see. Try the following: get the long value of the ObjectID of the proxy:

	long id = proxy.remoteID().value();

and send this long id down the cable. On the other computer you build a new
proxy from the ObjectID value via:

	ExternalDatabase db = ... ;
	long id = ... ;
	<your_type> proxy = (...)new OzoneProxy( new ObjectID( id ), database );

This newly created proxy can be used just like any other proxy. No explicite
mapping is needed.

This of course is totally unportable but should do exactly what you need ;)


Falko
-- 
______________________________________________________________________
Falko Braeutigam                              mailto:falko@smb-tec.com
SMB GmbH                                        http://www.smb-tec.com